@@ -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,705 +72,705 @@ 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 requirment. |
|
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 | - * |
|
291 | - * } |
|
292 | - * @param bool $default Not yet implemented. |
|
293 | - * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
294 | - */ |
|
295 | - function geodir_custom_field_save($request_field = array(), $default = false) |
|
296 | - { |
|
297 | - |
|
298 | - global $wpdb, $plugin_prefix; |
|
299 | - |
|
300 | - $old_html_variable = ''; |
|
301 | - |
|
302 | - $data_type = trim($request_field['data_type']); |
|
303 | - |
|
304 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
305 | - |
|
306 | - // some servers fail if a POST value is VARCHAR so we change it. |
|
307 | - if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){ |
|
308 | - $request_field['data_type'] = 'VARCHAR'; |
|
309 | - } |
|
310 | - |
|
311 | - $cf = trim($result_str, '_'); |
|
312 | - |
|
313 | - |
|
314 | - /*-------- check dublicate validation --------*/ |
|
315 | - |
|
316 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
317 | - $post_type = $request_field['listing_type']; |
|
318 | - |
|
319 | - if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') { |
|
320 | - $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name; |
|
321 | - } |
|
322 | - |
|
323 | - $check_html_variable = $wpdb->get_var( |
|
324 | - $wpdb->prepare( |
|
325 | - "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ", |
|
326 | - array($cf, $cehhtmlvar_name, $post_type) |
|
327 | - ) |
|
328 | - ); |
|
329 | - |
|
330 | - |
|
331 | - if (!$check_html_variable || $request_field['field_type'] == 'fieldset') { |
|
332 | - |
|
333 | - if ($cf != '') { |
|
334 | - |
|
335 | - $post_meta_info = $wpdb->get_row( |
|
336 | - $wpdb->prepare( |
|
337 | - "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d", |
|
338 | - array($cf) |
|
339 | - ) |
|
340 | - ); |
|
341 | - |
|
342 | - } |
|
343 | - |
|
344 | - if (!empty($post_meta_info)) { |
|
345 | - $post_val = $post_meta_info; |
|
346 | - $old_html_variable = $post_val->htmlvar_name; |
|
347 | - |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - |
|
352 | - if ($post_type == '') $post_type = 'gd_place'; |
|
353 | - |
|
354 | - |
|
355 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
356 | - |
|
357 | - $admin_title = $request_field['admin_title']; |
|
358 | - $site_title = $request_field['site_title']; |
|
359 | - $data_type = $request_field['data_type']; |
|
360 | - $field_type = $request_field['field_type']; |
|
361 | - $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
362 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
363 | - $admin_desc = $request_field['admin_desc']; |
|
364 | - $clabels = $request_field['clabels']; |
|
365 | - $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
366 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
367 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
368 | - $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
369 | - $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
370 | - $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
371 | - $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
372 | - $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; |
|
373 | - $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
374 | - $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; |
|
375 | - $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; |
|
376 | - $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
377 | - $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
378 | - $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
379 | - $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
380 | - $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 requirment. |
|
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 | + * |
|
291 | + * } |
|
292 | + * @param bool $default Not yet implemented. |
|
293 | + * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
294 | + */ |
|
295 | + function geodir_custom_field_save($request_field = array(), $default = false) |
|
296 | + { |
|
297 | + |
|
298 | + global $wpdb, $plugin_prefix; |
|
299 | + |
|
300 | + $old_html_variable = ''; |
|
301 | + |
|
302 | + $data_type = trim($request_field['data_type']); |
|
303 | + |
|
304 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
305 | + |
|
306 | + // some servers fail if a POST value is VARCHAR so we change it. |
|
307 | + if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){ |
|
308 | + $request_field['data_type'] = 'VARCHAR'; |
|
309 | + } |
|
310 | + |
|
311 | + $cf = trim($result_str, '_'); |
|
312 | + |
|
313 | + |
|
314 | + /*-------- check dublicate validation --------*/ |
|
315 | + |
|
316 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
317 | + $post_type = $request_field['listing_type']; |
|
318 | + |
|
319 | + if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') { |
|
320 | + $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name; |
|
321 | + } |
|
322 | + |
|
323 | + $check_html_variable = $wpdb->get_var( |
|
324 | + $wpdb->prepare( |
|
325 | + "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ", |
|
326 | + array($cf, $cehhtmlvar_name, $post_type) |
|
327 | + ) |
|
328 | + ); |
|
329 | + |
|
330 | + |
|
331 | + if (!$check_html_variable || $request_field['field_type'] == 'fieldset') { |
|
332 | + |
|
333 | + if ($cf != '') { |
|
334 | + |
|
335 | + $post_meta_info = $wpdb->get_row( |
|
336 | + $wpdb->prepare( |
|
337 | + "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d", |
|
338 | + array($cf) |
|
339 | + ) |
|
340 | + ); |
|
341 | + |
|
342 | + } |
|
343 | + |
|
344 | + if (!empty($post_meta_info)) { |
|
345 | + $post_val = $post_meta_info; |
|
346 | + $old_html_variable = $post_val->htmlvar_name; |
|
347 | + |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + |
|
352 | + if ($post_type == '') $post_type = 'gd_place'; |
|
353 | + |
|
354 | + |
|
355 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
356 | + |
|
357 | + $admin_title = $request_field['admin_title']; |
|
358 | + $site_title = $request_field['site_title']; |
|
359 | + $data_type = $request_field['data_type']; |
|
360 | + $field_type = $request_field['field_type']; |
|
361 | + $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
362 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
363 | + $admin_desc = $request_field['admin_desc']; |
|
364 | + $clabels = $request_field['clabels']; |
|
365 | + $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
366 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
367 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
368 | + $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
369 | + $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
370 | + $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
371 | + $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
372 | + $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; |
|
373 | + $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
374 | + $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; |
|
375 | + $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; |
|
376 | + $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
377 | + $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
378 | + $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
379 | + $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
380 | + $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; |
|
381 | 381 | |
382 | 382 | |
383 | - if(is_array($show_in)){ |
|
384 | - $show_in = implode(",", $request_field['show_in']); |
|
385 | - } |
|
383 | + if(is_array($show_in)){ |
|
384 | + $show_in = implode(",", $request_field['show_in']); |
|
385 | + } |
|
386 | 386 | |
387 | - if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') { |
|
388 | - $htmlvar_name = 'geodir_' . $htmlvar_name; |
|
389 | - } |
|
387 | + if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') { |
|
388 | + $htmlvar_name = 'geodir_' . $htmlvar_name; |
|
389 | + } |
|
390 | 390 | |
391 | - $option_values = ''; |
|
392 | - if (isset($request_field['option_values'])) |
|
393 | - $option_values = $request_field['option_values']; |
|
391 | + $option_values = ''; |
|
392 | + if (isset($request_field['option_values'])) |
|
393 | + $option_values = $request_field['option_values']; |
|
394 | 394 | |
395 | - $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0'; |
|
395 | + $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0'; |
|
396 | 396 | |
397 | - $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0'; |
|
397 | + $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0'; |
|
398 | 398 | |
399 | - if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
400 | - $price_pkg = implode(",", $request_field['show_on_pkg']); |
|
401 | - else { |
|
402 | - $package_info = array(); |
|
399 | + if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
400 | + $price_pkg = implode(",", $request_field['show_on_pkg']); |
|
401 | + else { |
|
402 | + $package_info = array(); |
|
403 | 403 | |
404 | - $package_info = geodir_post_package_info($package_info, '', $post_type); |
|
405 | - $price_pkg = $package_info->pid; |
|
406 | - } |
|
404 | + $package_info = geodir_post_package_info($package_info, '', $post_type); |
|
405 | + $price_pkg = $package_info->pid; |
|
406 | + } |
|
407 | 407 | |
408 | 408 | |
409 | - if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
410 | - $extra_fields = $request_field['extra']; |
|
409 | + if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
410 | + $extra_fields = $request_field['extra']; |
|
411 | 411 | |
412 | - if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
413 | - $is_default = $request_field['is_default']; |
|
414 | - else |
|
415 | - $is_default = '0'; |
|
412 | + if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
413 | + $is_default = $request_field['is_default']; |
|
414 | + else |
|
415 | + $is_default = '0'; |
|
416 | 416 | |
417 | - if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
418 | - $is_admin = $request_field['is_admin']; |
|
419 | - else |
|
420 | - $is_admin = '0'; |
|
417 | + if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
418 | + $is_admin = $request_field['is_admin']; |
|
419 | + else |
|
420 | + $is_admin = '0'; |
|
421 | 421 | |
422 | 422 | |
423 | - if ($is_active == '') $is_active = 1; |
|
424 | - if ($is_required == '') $is_required = 0; |
|
423 | + if ($is_active == '') $is_active = 1; |
|
424 | + if ($is_required == '') $is_required = 0; |
|
425 | 425 | |
426 | 426 | |
427 | - if ($sort_order == '') { |
|
427 | + if ($sort_order == '') { |
|
428 | 428 | |
429 | - $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE); |
|
429 | + $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE); |
|
430 | 430 | |
431 | - $sort_order = (int)$last_order + 1; |
|
432 | - } |
|
431 | + $sort_order = (int)$last_order + 1; |
|
432 | + } |
|
433 | 433 | |
434 | - $default_value_add = ''; |
|
434 | + $default_value_add = ''; |
|
435 | 435 | |
436 | 436 | |
437 | - if (!empty($post_meta_info)) { |
|
438 | - switch ($field_type): |
|
437 | + if (!empty($post_meta_info)) { |
|
438 | + switch ($field_type): |
|
439 | 439 | |
440 | - case 'address': |
|
440 | + case 'address': |
|
441 | 441 | |
442 | - if ($htmlvar_name != '') { |
|
443 | - $prefix = $htmlvar_name . '_'; |
|
444 | - } |
|
445 | - $old_prefix = $old_html_variable . '_'; |
|
442 | + if ($htmlvar_name != '') { |
|
443 | + $prefix = $htmlvar_name . '_'; |
|
444 | + } |
|
445 | + $old_prefix = $old_html_variable . '_'; |
|
446 | 446 | |
447 | 447 | |
448 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; |
|
448 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; |
|
449 | 449 | |
450 | - if ($default_value != '') { |
|
451 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
452 | - } |
|
450 | + if ($default_value != '') { |
|
451 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
452 | + } |
|
453 | 453 | |
454 | - $wpdb->query($meta_field_add); |
|
454 | + $wpdb->query($meta_field_add); |
|
455 | 455 | |
456 | - if ($extra_fields != '') { |
|
456 | + if ($extra_fields != '') { |
|
457 | 457 | |
458 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
458 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
459 | 459 | |
460 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'"); |
|
461 | - if ($is_column) { |
|
462 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; |
|
460 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'"); |
|
461 | + if ($is_column) { |
|
462 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; |
|
463 | 463 | |
464 | - if ($default_value != '') { |
|
465 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
466 | - } |
|
464 | + if ($default_value != '') { |
|
465 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
466 | + } |
|
467 | 467 | |
468 | - $wpdb->query($meta_field_add); |
|
469 | - } else { |
|
468 | + $wpdb->query($meta_field_add); |
|
469 | + } else { |
|
470 | 470 | |
471 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
472 | - if ($default_value != '') { |
|
473 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
474 | - } |
|
475 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
471 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
472 | + if ($default_value != '') { |
|
473 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
474 | + } |
|
475 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
476 | 476 | |
477 | - } |
|
477 | + } |
|
478 | 478 | |
479 | 479 | |
480 | - } |
|
480 | + } |
|
481 | 481 | |
482 | 482 | |
483 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
483 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
484 | 484 | |
485 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'"); |
|
485 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'"); |
|
486 | 486 | |
487 | - if ($is_column) { |
|
488 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; |
|
487 | + if ($is_column) { |
|
488 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; |
|
489 | 489 | |
490 | - if ($default_value != '') { |
|
491 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
492 | - } |
|
490 | + if ($default_value != '') { |
|
491 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
492 | + } |
|
493 | 493 | |
494 | - $wpdb->query($meta_field_add); |
|
495 | - } else { |
|
496 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
497 | - if ($default_value != '') { |
|
498 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
499 | - } |
|
494 | + $wpdb->query($meta_field_add); |
|
495 | + } else { |
|
496 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
497 | + if ($default_value != '') { |
|
498 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
499 | + } |
|
500 | 500 | |
501 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
502 | - } |
|
501 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
502 | + } |
|
503 | 503 | |
504 | - } |
|
505 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
504 | + } |
|
505 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
506 | 506 | |
507 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'"); |
|
507 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'"); |
|
508 | 508 | |
509 | - if ($is_column) { |
|
509 | + if ($is_column) { |
|
510 | 510 | |
511 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; |
|
511 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; |
|
512 | 512 | |
513 | - if ($default_value != '') { |
|
514 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
515 | - } |
|
513 | + if ($default_value != '') { |
|
514 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
515 | + } |
|
516 | 516 | |
517 | - $wpdb->query($meta_field_add); |
|
518 | - } else { |
|
517 | + $wpdb->query($meta_field_add); |
|
518 | + } else { |
|
519 | 519 | |
520 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
521 | - if ($default_value != '') { |
|
522 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
523 | - } |
|
520 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
521 | + if ($default_value != '') { |
|
522 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
523 | + } |
|
524 | 524 | |
525 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
525 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
526 | 526 | |
527 | - } |
|
527 | + } |
|
528 | 528 | |
529 | - } |
|
530 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
529 | + } |
|
530 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
531 | 531 | |
532 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'"); |
|
532 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'"); |
|
533 | 533 | |
534 | - if ($is_column) { |
|
534 | + if ($is_column) { |
|
535 | 535 | |
536 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; |
|
536 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; |
|
537 | 537 | |
538 | - if ($default_value != '') { |
|
539 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
540 | - } |
|
538 | + if ($default_value != '') { |
|
539 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
540 | + } |
|
541 | 541 | |
542 | - $wpdb->query($meta_field_add); |
|
543 | - } else { |
|
542 | + $wpdb->query($meta_field_add); |
|
543 | + } else { |
|
544 | 544 | |
545 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
546 | - if ($default_value != '') { |
|
547 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
548 | - } |
|
545 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
546 | + if ($default_value != '') { |
|
547 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
548 | + } |
|
549 | 549 | |
550 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
550 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
551 | 551 | |
552 | - } |
|
552 | + } |
|
553 | 553 | |
554 | - } |
|
555 | - if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
554 | + } |
|
555 | + if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
556 | 556 | |
557 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'"); |
|
558 | - if ($is_column) { |
|
557 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'"); |
|
558 | + if ($is_column) { |
|
559 | 559 | |
560 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
560 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
561 | 561 | |
562 | - if ($default_value != '') { |
|
563 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
564 | - } |
|
562 | + if ($default_value != '') { |
|
563 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
564 | + } |
|
565 | 565 | |
566 | - $wpdb->query($meta_field_add); |
|
567 | - } else { |
|
566 | + $wpdb->query($meta_field_add); |
|
567 | + } else { |
|
568 | 568 | |
569 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
570 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
571 | - if ($default_value != '') { |
|
572 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
573 | - } |
|
569 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
570 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
571 | + if ($default_value != '') { |
|
572 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
573 | + } |
|
574 | 574 | |
575 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
575 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
576 | 576 | |
577 | - } |
|
577 | + } |
|
578 | 578 | |
579 | 579 | |
580 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'"); |
|
580 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'"); |
|
581 | 581 | |
582 | - if ($is_column) { |
|
583 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
582 | + if ($is_column) { |
|
583 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
584 | 584 | |
585 | - if ($default_value != '') { |
|
586 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
587 | - } |
|
585 | + if ($default_value != '') { |
|
586 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
587 | + } |
|
588 | 588 | |
589 | - $wpdb->query($meta_field_add); |
|
590 | - } else { |
|
589 | + $wpdb->query($meta_field_add); |
|
590 | + } else { |
|
591 | 591 | |
592 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
593 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
594 | - if ($default_value != '') { |
|
595 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
596 | - } |
|
592 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
593 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
594 | + if ($default_value != '') { |
|
595 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
596 | + } |
|
597 | 597 | |
598 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
599 | - } |
|
598 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
599 | + } |
|
600 | 600 | |
601 | - } |
|
602 | - if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
601 | + } |
|
602 | + if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
603 | 603 | |
604 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'"); |
|
604 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'"); |
|
605 | 605 | |
606 | - if ($is_column) { |
|
607 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
606 | + if ($is_column) { |
|
607 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
608 | 608 | |
609 | - if ($default_value != '') { |
|
610 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
611 | - } |
|
609 | + if ($default_value != '') { |
|
610 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
611 | + } |
|
612 | 612 | |
613 | - $wpdb->query($meta_field_add); |
|
614 | - } else { |
|
613 | + $wpdb->query($meta_field_add); |
|
614 | + } else { |
|
615 | 615 | |
616 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
616 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
617 | 617 | |
618 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
619 | - if ($default_value != '') { |
|
620 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
621 | - } |
|
618 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
619 | + if ($default_value != '') { |
|
620 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
621 | + } |
|
622 | 622 | |
623 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
624 | - } |
|
623 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
624 | + } |
|
625 | 625 | |
626 | 626 | |
627 | - } |
|
628 | - if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
627 | + } |
|
628 | + if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
629 | 629 | |
630 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'"); |
|
631 | - if ($is_column) { |
|
632 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
630 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'"); |
|
631 | + if ($is_column) { |
|
632 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
633 | 633 | |
634 | - if ($default_value != '') { |
|
635 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
636 | - } |
|
634 | + if ($default_value != '') { |
|
635 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
636 | + } |
|
637 | 637 | |
638 | - $wpdb->query($meta_field_add); |
|
638 | + $wpdb->query($meta_field_add); |
|
639 | 639 | |
640 | - } else { |
|
640 | + } else { |
|
641 | 641 | |
642 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
642 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
643 | 643 | |
644 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
645 | - if ($default_value != '') { |
|
646 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
647 | - } |
|
644 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
645 | + if ($default_value != '') { |
|
646 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
647 | + } |
|
648 | 648 | |
649 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
650 | - } |
|
649 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
650 | + } |
|
651 | 651 | |
652 | - } |
|
653 | - // show lat lng |
|
654 | - if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
655 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'"); |
|
652 | + } |
|
653 | + // show lat lng |
|
654 | + if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
655 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'"); |
|
656 | 656 | |
657 | - if ($is_column) { |
|
658 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
659 | - $meta_field_add .= " DEFAULT '1'"; |
|
657 | + if ($is_column) { |
|
658 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
659 | + $meta_field_add .= " DEFAULT '1'"; |
|
660 | 660 | |
661 | - $wpdb->query($meta_field_add); |
|
662 | - } else { |
|
663 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
661 | + $wpdb->query($meta_field_add); |
|
662 | + } else { |
|
663 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
664 | 664 | |
665 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
666 | - $meta_field_add .= " DEFAULT '1'"; |
|
665 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
666 | + $meta_field_add .= " DEFAULT '1'"; |
|
667 | 667 | |
668 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
669 | - } |
|
668 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
669 | + } |
|
670 | 670 | |
671 | - } |
|
672 | - }// end extra |
|
671 | + } |
|
672 | + }// end extra |
|
673 | 673 | |
674 | - break; |
|
674 | + break; |
|
675 | 675 | |
676 | - case 'checkbox': |
|
677 | - case 'multiselect': |
|
678 | - case 'select': |
|
679 | - case 'taxonomy': |
|
676 | + case 'checkbox': |
|
677 | + case 'multiselect': |
|
678 | + case 'select': |
|
679 | + case 'taxonomy': |
|
680 | 680 | |
681 | - $op_size = '500'; |
|
681 | + $op_size = '500'; |
|
682 | 682 | |
683 | - // only make the field as big as it needs to be. |
|
684 | - if(isset($option_values) && $option_values && $field_type=='select'){ |
|
685 | - $option_values_arr = explode(',',$option_values); |
|
686 | - if(is_array($option_values_arr)){ |
|
687 | - $op_max = 0; |
|
688 | - foreach($option_values_arr as $op_val){ |
|
689 | - if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);} |
|
690 | - } |
|
691 | - if($op_max){$op_size =$op_max; } |
|
692 | - } |
|
693 | - }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){ |
|
694 | - if(strlen($option_values)){ |
|
695 | - $op_size = strlen($option_values); |
|
696 | - } |
|
697 | - } |
|
683 | + // only make the field as big as it needs to be. |
|
684 | + if(isset($option_values) && $option_values && $field_type=='select'){ |
|
685 | + $option_values_arr = explode(',',$option_values); |
|
686 | + if(is_array($option_values_arr)){ |
|
687 | + $op_max = 0; |
|
688 | + foreach($option_values_arr as $op_val){ |
|
689 | + if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);} |
|
690 | + } |
|
691 | + if($op_max){$op_size =$op_max; } |
|
692 | + } |
|
693 | + }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){ |
|
694 | + if(strlen($option_values)){ |
|
695 | + $op_size = strlen($option_values); |
|
696 | + } |
|
697 | + } |
|
698 | 698 | |
699 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
699 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
700 | 700 | |
701 | - if ($default_value != '') { |
|
702 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
703 | - } |
|
701 | + if ($default_value != '') { |
|
702 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
703 | + } |
|
704 | 704 | |
705 | - $alter_result = $wpdb->query($meta_field_add); |
|
706 | - if($alter_result===false){ |
|
707 | - return __('Column change failed, you may have too many columns.','geodirectory'); |
|
708 | - } |
|
705 | + $alter_result = $wpdb->query($meta_field_add); |
|
706 | + if($alter_result===false){ |
|
707 | + return __('Column change failed, you may have too many columns.','geodirectory'); |
|
708 | + } |
|
709 | 709 | |
710 | - if (isset($request_field['cat_display_type'])) |
|
711 | - $extra_fields = $request_field['cat_display_type']; |
|
710 | + if (isset($request_field['cat_display_type'])) |
|
711 | + $extra_fields = $request_field['cat_display_type']; |
|
712 | 712 | |
713 | - if (isset($request_field['multi_display_type'])) |
|
714 | - $extra_fields = $request_field['multi_display_type']; |
|
713 | + if (isset($request_field['multi_display_type'])) |
|
714 | + $extra_fields = $request_field['multi_display_type']; |
|
715 | 715 | |
716 | 716 | |
717 | - break; |
|
717 | + break; |
|
718 | 718 | |
719 | - case 'textarea': |
|
720 | - case 'html': |
|
721 | - case 'url': |
|
722 | - case 'file': |
|
719 | + case 'textarea': |
|
720 | + case 'html': |
|
721 | + case 'url': |
|
722 | + case 'file': |
|
723 | 723 | |
724 | - $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL"); |
|
725 | - if($alter_result===false){ |
|
726 | - return __('Column change failed, you may have too many columns.','geodirectory'); |
|
727 | - } |
|
728 | - if (isset($request_field['advanced_editor'])) |
|
729 | - $extra_fields = $request_field['advanced_editor']; |
|
730 | - |
|
731 | - break; |
|
724 | + $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL"); |
|
725 | + if($alter_result===false){ |
|
726 | + return __('Column change failed, you may have too many columns.','geodirectory'); |
|
727 | + } |
|
728 | + if (isset($request_field['advanced_editor'])) |
|
729 | + $extra_fields = $request_field['advanced_editor']; |
|
730 | + |
|
731 | + break; |
|
732 | 732 | |
733 | - case 'fieldset': |
|
734 | - // Nothig happend for fieldset |
|
735 | - break; |
|
733 | + case 'fieldset': |
|
734 | + // Nothig happend for fieldset |
|
735 | + break; |
|
736 | 736 | |
737 | - default: |
|
738 | - if ($data_type != 'VARCHAR' && $data_type != '') { |
|
739 | - if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
740 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
741 | - } else { |
|
742 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
743 | - } |
|
744 | - |
|
745 | - if (is_numeric($default_value) && $default_value != '') { |
|
746 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
747 | - } |
|
748 | - } else { |
|
749 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
750 | - if ($default_value != '') { |
|
751 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
752 | - } |
|
753 | - } |
|
754 | - |
|
755 | - $alter_result = $wpdb->query($default_value_add); |
|
756 | - if($alter_result===false){ |
|
757 | - return __('Column change failed, you may have too many columns.','geodirectory'); |
|
758 | - } |
|
759 | - break; |
|
760 | - endswitch; |
|
761 | - |
|
762 | - $extra_field_query = ''; |
|
763 | - if (!empty($extra_fields)) { |
|
764 | - $extra_field_query = serialize($extra_fields); |
|
765 | - } |
|
766 | - |
|
767 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
768 | - |
|
769 | - $wpdb->query( |
|
770 | - |
|
771 | - $wpdb->prepare( |
|
772 | - |
|
773 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
737 | + default: |
|
738 | + if ($data_type != 'VARCHAR' && $data_type != '') { |
|
739 | + if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
740 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
741 | + } else { |
|
742 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
743 | + } |
|
744 | + |
|
745 | + if (is_numeric($default_value) && $default_value != '') { |
|
746 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
747 | + } |
|
748 | + } else { |
|
749 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
750 | + if ($default_value != '') { |
|
751 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
752 | + } |
|
753 | + } |
|
754 | + |
|
755 | + $alter_result = $wpdb->query($default_value_add); |
|
756 | + if($alter_result===false){ |
|
757 | + return __('Column change failed, you may have too many columns.','geodirectory'); |
|
758 | + } |
|
759 | + break; |
|
760 | + endswitch; |
|
761 | + |
|
762 | + $extra_field_query = ''; |
|
763 | + if (!empty($extra_fields)) { |
|
764 | + $extra_field_query = serialize($extra_fields); |
|
765 | + } |
|
766 | + |
|
767 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
768 | + |
|
769 | + $wpdb->query( |
|
770 | + |
|
771 | + $wpdb->prepare( |
|
772 | + |
|
773 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
774 | 774 | post_type = %s, |
775 | 775 | admin_title = %s, |
776 | 776 | site_title = %s, |
@@ -804,308 +804,308 @@ discard block |
||
804 | 804 | for_admin_use = %s |
805 | 805 | where id = %d", |
806 | 806 | |
807 | - 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) |
|
808 | - ) |
|
807 | + 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) |
|
808 | + ) |
|
809 | 809 | |
810 | - ); |
|
810 | + ); |
|
811 | 811 | |
812 | - $lastid = trim($cf); |
|
812 | + $lastid = trim($cf); |
|
813 | 813 | |
814 | 814 | |
815 | - $wpdb->query( |
|
816 | - $wpdb->prepare( |
|
817 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
815 | + $wpdb->query( |
|
816 | + $wpdb->prepare( |
|
817 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
818 | 818 | site_title=%s |
819 | 819 | where post_type = %s and htmlvar_name = %s", |
820 | - array($site_title, $post_type, $htmlvar_name) |
|
821 | - ) |
|
822 | - ); |
|
823 | - |
|
824 | - |
|
825 | - if ($cat_sort == '') |
|
826 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name))); |
|
827 | - |
|
828 | - |
|
829 | - /** |
|
830 | - * Called after all custom fields are saved for a post. |
|
831 | - * |
|
832 | - * @since 1.0.0 |
|
833 | - * @param int $lastid The post ID. |
|
834 | - */ |
|
835 | - do_action('geodir_after_custom_fields_updated', $lastid); |
|
836 | - |
|
837 | - } else { |
|
838 | - |
|
839 | - switch ($field_type): |
|
840 | - |
|
841 | - case 'address': |
|
842 | - |
|
843 | - $data_type = ''; |
|
844 | - |
|
845 | - if ($htmlvar_name != '') { |
|
846 | - $prefix = $htmlvar_name . '_'; |
|
847 | - } |
|
848 | - $old_prefix = $old_html_variable; |
|
849 | - |
|
850 | - //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; |
|
851 | - |
|
852 | - $meta_field_add = "VARCHAR( 254 ) NULL"; |
|
853 | - if ($default_value != '') { |
|
854 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
855 | - } |
|
856 | - |
|
857 | - geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); |
|
858 | - //$wpdb->query($meta_field_add); |
|
859 | - |
|
860 | - |
|
861 | - if (!empty($extra_fields)) { |
|
820 | + array($site_title, $post_type, $htmlvar_name) |
|
821 | + ) |
|
822 | + ); |
|
823 | + |
|
824 | + |
|
825 | + if ($cat_sort == '') |
|
826 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name))); |
|
827 | + |
|
828 | + |
|
829 | + /** |
|
830 | + * Called after all custom fields are saved for a post. |
|
831 | + * |
|
832 | + * @since 1.0.0 |
|
833 | + * @param int $lastid The post ID. |
|
834 | + */ |
|
835 | + do_action('geodir_after_custom_fields_updated', $lastid); |
|
836 | + |
|
837 | + } else { |
|
838 | + |
|
839 | + switch ($field_type): |
|
840 | + |
|
841 | + case 'address': |
|
842 | + |
|
843 | + $data_type = ''; |
|
844 | + |
|
845 | + if ($htmlvar_name != '') { |
|
846 | + $prefix = $htmlvar_name . '_'; |
|
847 | + } |
|
848 | + $old_prefix = $old_html_variable; |
|
849 | + |
|
850 | + //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; |
|
851 | + |
|
852 | + $meta_field_add = "VARCHAR( 254 ) NULL"; |
|
853 | + if ($default_value != '') { |
|
854 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
855 | + } |
|
856 | + |
|
857 | + geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); |
|
858 | + //$wpdb->query($meta_field_add); |
|
859 | + |
|
860 | + |
|
861 | + if (!empty($extra_fields)) { |
|
862 | 862 | |
863 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
864 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; |
|
865 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
866 | - if ($default_value != '') { |
|
867 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
868 | - } |
|
869 | - |
|
870 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
871 | - //$wpdb->query($meta_field_add); |
|
872 | - } |
|
873 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
874 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; |
|
875 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
876 | - if ($default_value != '') { |
|
877 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
878 | - } |
|
879 | - |
|
880 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
881 | - //$wpdb->query($meta_field_add); |
|
882 | - } |
|
883 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
884 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; |
|
885 | - |
|
886 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
887 | - if ($default_value != '') { |
|
888 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
889 | - } |
|
890 | - |
|
891 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
892 | - //$wpdb->query($meta_field_add); |
|
893 | - } |
|
894 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
895 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; |
|
896 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
897 | - if ($default_value != '') { |
|
898 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
899 | - } |
|
900 | - |
|
901 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
902 | - //$wpdb->query($meta_field_add); |
|
903 | - } |
|
904 | - if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
905 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
906 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
907 | - if ($default_value != '') { |
|
908 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
909 | - } |
|
910 | - |
|
911 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
912 | - //$wpdb->query($meta_field_add); |
|
913 | - |
|
914 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
915 | - |
|
916 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
917 | - if ($default_value != '') { |
|
918 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
919 | - } |
|
920 | - |
|
921 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
922 | - |
|
923 | - //$wpdb->query($meta_field_add); |
|
924 | - } |
|
925 | - if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
926 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
927 | - |
|
928 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
929 | - if ($default_value != '') { |
|
930 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
931 | - } |
|
932 | - |
|
933 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
934 | - |
|
935 | - //$wpdb->query($meta_field_add); |
|
936 | - } |
|
937 | - if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
938 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
939 | - |
|
940 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
941 | - if ($default_value != '') { |
|
942 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
943 | - } |
|
944 | - |
|
945 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
946 | - |
|
947 | - //$wpdb->query($meta_field_add); |
|
948 | - } |
|
949 | - // show lat lng |
|
950 | - if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
951 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
952 | - |
|
953 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
954 | - $meta_field_add .= " DEFAULT '1'"; |
|
955 | - |
|
956 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
957 | - //$wpdb->query($meta_field_add); |
|
958 | - } |
|
959 | - } |
|
960 | - |
|
961 | - break; |
|
962 | - |
|
963 | - case 'checkbox': |
|
964 | - $data_type = 'TINYINT'; |
|
965 | - |
|
966 | - $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
967 | - if ((int)$default_value === 1) { |
|
968 | - $meta_field_add .= " DEFAULT '1'"; |
|
969 | - } |
|
970 | - |
|
971 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
972 | - if ($add_result === false) { |
|
973 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
974 | - } |
|
975 | - break; |
|
976 | - case 'multiselect': |
|
977 | - case 'select': |
|
978 | - $data_type = 'VARCHAR'; |
|
979 | - $op_size = '500'; |
|
980 | - |
|
981 | - // only make the field as big as it needs to be. |
|
982 | - if (isset($option_values) && $option_values && $field_type == 'select') { |
|
983 | - $option_values_arr = explode(',', $option_values); |
|
984 | - |
|
985 | - if (is_array($option_values_arr)) { |
|
986 | - $op_max = 0; |
|
987 | - |
|
988 | - foreach ($option_values_arr as $op_val) { |
|
989 | - if (strlen($op_val) && strlen($op_val) > $op_max) { |
|
990 | - $op_max = strlen($op_val); |
|
991 | - } |
|
992 | - } |
|
993 | - |
|
994 | - if ($op_max) { |
|
995 | - $op_size = $op_max; |
|
996 | - } |
|
997 | - } |
|
998 | - } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') { |
|
999 | - if (strlen($option_values)) { |
|
1000 | - $op_size = strlen($option_values); |
|
1001 | - } |
|
1002 | - |
|
1003 | - if (isset($request_field['multi_display_type'])) { |
|
1004 | - $extra_fields = $request_field['multi_display_type']; |
|
1005 | - } |
|
1006 | - } |
|
1007 | - |
|
1008 | - $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
1009 | - if ($default_value != '') { |
|
1010 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1011 | - } |
|
1012 | - |
|
1013 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1014 | - if ($add_result === false) { |
|
1015 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1016 | - } |
|
1017 | - break; |
|
1018 | - case 'textarea': |
|
1019 | - case 'html': |
|
1020 | - case 'url': |
|
1021 | - case 'file': |
|
1022 | - |
|
1023 | - $data_type = 'TEXT'; |
|
1024 | - |
|
1025 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1026 | - |
|
1027 | - $meta_field_add = $data_type . " NULL "; |
|
1028 | - /*if($default_value != '') |
|
863 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
864 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; |
|
865 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
866 | + if ($default_value != '') { |
|
867 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
868 | + } |
|
869 | + |
|
870 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
871 | + //$wpdb->query($meta_field_add); |
|
872 | + } |
|
873 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
874 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; |
|
875 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
876 | + if ($default_value != '') { |
|
877 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
878 | + } |
|
879 | + |
|
880 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
881 | + //$wpdb->query($meta_field_add); |
|
882 | + } |
|
883 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
884 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; |
|
885 | + |
|
886 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
887 | + if ($default_value != '') { |
|
888 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
889 | + } |
|
890 | + |
|
891 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
892 | + //$wpdb->query($meta_field_add); |
|
893 | + } |
|
894 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
895 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; |
|
896 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
897 | + if ($default_value != '') { |
|
898 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
899 | + } |
|
900 | + |
|
901 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
902 | + //$wpdb->query($meta_field_add); |
|
903 | + } |
|
904 | + if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
905 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
906 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
907 | + if ($default_value != '') { |
|
908 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
909 | + } |
|
910 | + |
|
911 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
912 | + //$wpdb->query($meta_field_add); |
|
913 | + |
|
914 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
915 | + |
|
916 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
917 | + if ($default_value != '') { |
|
918 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
919 | + } |
|
920 | + |
|
921 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
922 | + |
|
923 | + //$wpdb->query($meta_field_add); |
|
924 | + } |
|
925 | + if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
926 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
927 | + |
|
928 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
929 | + if ($default_value != '') { |
|
930 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
931 | + } |
|
932 | + |
|
933 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
934 | + |
|
935 | + //$wpdb->query($meta_field_add); |
|
936 | + } |
|
937 | + if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
938 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
939 | + |
|
940 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
941 | + if ($default_value != '') { |
|
942 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
943 | + } |
|
944 | + |
|
945 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
946 | + |
|
947 | + //$wpdb->query($meta_field_add); |
|
948 | + } |
|
949 | + // show lat lng |
|
950 | + if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
951 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
952 | + |
|
953 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
954 | + $meta_field_add .= " DEFAULT '1'"; |
|
955 | + |
|
956 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
957 | + //$wpdb->query($meta_field_add); |
|
958 | + } |
|
959 | + } |
|
960 | + |
|
961 | + break; |
|
962 | + |
|
963 | + case 'checkbox': |
|
964 | + $data_type = 'TINYINT'; |
|
965 | + |
|
966 | + $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
967 | + if ((int)$default_value === 1) { |
|
968 | + $meta_field_add .= " DEFAULT '1'"; |
|
969 | + } |
|
970 | + |
|
971 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
972 | + if ($add_result === false) { |
|
973 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
974 | + } |
|
975 | + break; |
|
976 | + case 'multiselect': |
|
977 | + case 'select': |
|
978 | + $data_type = 'VARCHAR'; |
|
979 | + $op_size = '500'; |
|
980 | + |
|
981 | + // only make the field as big as it needs to be. |
|
982 | + if (isset($option_values) && $option_values && $field_type == 'select') { |
|
983 | + $option_values_arr = explode(',', $option_values); |
|
984 | + |
|
985 | + if (is_array($option_values_arr)) { |
|
986 | + $op_max = 0; |
|
987 | + |
|
988 | + foreach ($option_values_arr as $op_val) { |
|
989 | + if (strlen($op_val) && strlen($op_val) > $op_max) { |
|
990 | + $op_max = strlen($op_val); |
|
991 | + } |
|
992 | + } |
|
993 | + |
|
994 | + if ($op_max) { |
|
995 | + $op_size = $op_max; |
|
996 | + } |
|
997 | + } |
|
998 | + } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') { |
|
999 | + if (strlen($option_values)) { |
|
1000 | + $op_size = strlen($option_values); |
|
1001 | + } |
|
1002 | + |
|
1003 | + if (isset($request_field['multi_display_type'])) { |
|
1004 | + $extra_fields = $request_field['multi_display_type']; |
|
1005 | + } |
|
1006 | + } |
|
1007 | + |
|
1008 | + $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
1009 | + if ($default_value != '') { |
|
1010 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1011 | + } |
|
1012 | + |
|
1013 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1014 | + if ($add_result === false) { |
|
1015 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1016 | + } |
|
1017 | + break; |
|
1018 | + case 'textarea': |
|
1019 | + case 'html': |
|
1020 | + case 'url': |
|
1021 | + case 'file': |
|
1022 | + |
|
1023 | + $data_type = 'TEXT'; |
|
1024 | + |
|
1025 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1026 | + |
|
1027 | + $meta_field_add = $data_type . " NULL "; |
|
1028 | + /*if($default_value != '') |
|
1029 | 1029 | { $meta_field_add .= " DEFAULT '".$default_value."'"; }*/ |
1030 | 1030 | |
1031 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1032 | - if ($add_result === false) { |
|
1033 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1034 | - } |
|
1031 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1032 | + if ($add_result === false) { |
|
1033 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1034 | + } |
|
1035 | 1035 | |
1036 | - break; |
|
1036 | + break; |
|
1037 | 1037 | |
1038 | - case 'datepicker': |
|
1038 | + case 'datepicker': |
|
1039 | 1039 | |
1040 | - $data_type = 'DATE'; |
|
1040 | + $data_type = 'DATE'; |
|
1041 | 1041 | |
1042 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1042 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1043 | 1043 | |
1044 | - $meta_field_add = $data_type . " NULL "; |
|
1044 | + $meta_field_add = $data_type . " NULL "; |
|
1045 | 1045 | |
1046 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1047 | - if ($add_result === false) { |
|
1048 | - return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory'); |
|
1049 | - } |
|
1046 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1047 | + if ($add_result === false) { |
|
1048 | + return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory'); |
|
1049 | + } |
|
1050 | 1050 | |
1051 | - break; |
|
1051 | + break; |
|
1052 | 1052 | |
1053 | - case 'time': |
|
1053 | + case 'time': |
|
1054 | 1054 | |
1055 | - $data_type = 'TIME'; |
|
1055 | + $data_type = 'TIME'; |
|
1056 | 1056 | |
1057 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1057 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1058 | 1058 | |
1059 | - $meta_field_add = $data_type . " NULL "; |
|
1059 | + $meta_field_add = $data_type . " NULL "; |
|
1060 | 1060 | |
1061 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1062 | - if ($add_result === false) { |
|
1063 | - return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory'); |
|
1064 | - } |
|
1061 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1062 | + if ($add_result === false) { |
|
1063 | + return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory'); |
|
1064 | + } |
|
1065 | 1065 | |
1066 | - break; |
|
1066 | + break; |
|
1067 | 1067 | |
1068 | - default: |
|
1068 | + default: |
|
1069 | 1069 | |
1070 | - if ($data_type != 'VARCHAR' && $data_type != '') { |
|
1071 | - $meta_field_add = $data_type . " NULL "; |
|
1070 | + if ($data_type != 'VARCHAR' && $data_type != '') { |
|
1071 | + $meta_field_add = $data_type . " NULL "; |
|
1072 | 1072 | |
1073 | - if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
1074 | - $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
1075 | - } |
|
1073 | + if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
1074 | + $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
1075 | + } |
|
1076 | 1076 | |
1077 | - if (is_numeric($default_value) && $default_value != '') { |
|
1078 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1079 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1080 | - } |
|
1081 | - } else { |
|
1082 | - $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
1077 | + if (is_numeric($default_value) && $default_value != '') { |
|
1078 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1079 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1080 | + } |
|
1081 | + } else { |
|
1082 | + $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
1083 | 1083 | |
1084 | - if ($default_value != '') { |
|
1085 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1086 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1087 | - } |
|
1088 | - } |
|
1084 | + if ($default_value != '') { |
|
1085 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1086 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1087 | + } |
|
1088 | + } |
|
1089 | 1089 | |
1090 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1091 | - if ($add_result === false) { |
|
1092 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1093 | - } |
|
1094 | - break; |
|
1095 | - endswitch; |
|
1090 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1091 | + if ($add_result === false) { |
|
1092 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1093 | + } |
|
1094 | + break; |
|
1095 | + endswitch; |
|
1096 | 1096 | |
1097 | - $extra_field_query = ''; |
|
1098 | - if (!empty($extra_fields)) { |
|
1099 | - $extra_field_query = serialize($extra_fields); |
|
1100 | - } |
|
1097 | + $extra_field_query = ''; |
|
1098 | + if (!empty($extra_fields)) { |
|
1099 | + $extra_field_query = serialize($extra_fields); |
|
1100 | + } |
|
1101 | 1101 | |
1102 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
1102 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
1103 | 1103 | |
1104 | - $wpdb->query( |
|
1104 | + $wpdb->query( |
|
1105 | 1105 | |
1106 | - $wpdb->prepare( |
|
1106 | + $wpdb->prepare( |
|
1107 | 1107 | |
1108 | - "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1108 | + "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1109 | 1109 | post_type = %s, |
1110 | 1110 | admin_title = %s, |
1111 | 1111 | site_title = %s, |
@@ -1138,26 +1138,26 @@ discard block |
||
1138 | 1138 | validation_msg = %s, |
1139 | 1139 | for_admin_use = %s ", |
1140 | 1140 | |
1141 | - 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) |
|
1141 | + 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 | 1142 | |
1143 | - ) |
|
1143 | + ) |
|
1144 | 1144 | |
1145 | - ); |
|
1145 | + ); |
|
1146 | 1146 | |
1147 | - $lastid = $wpdb->insert_id; |
|
1147 | + $lastid = $wpdb->insert_id; |
|
1148 | 1148 | |
1149 | - $lastid = trim($lastid); |
|
1149 | + $lastid = trim($lastid); |
|
1150 | 1150 | |
1151 | - } |
|
1151 | + } |
|
1152 | 1152 | |
1153 | - return (int)$lastid; |
|
1153 | + return (int)$lastid; |
|
1154 | 1154 | |
1155 | 1155 | |
1156 | - } else { |
|
1157 | - return 'HTML Variable Name should be a unique name'; |
|
1158 | - } |
|
1156 | + } else { |
|
1157 | + return 'HTML Variable Name should be a unique name'; |
|
1158 | + } |
|
1159 | 1159 | |
1160 | - } |
|
1160 | + } |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1172,54 +1172,54 @@ discard block |
||
1172 | 1172 | function godir_set_field_order($field_ids = array()) |
1173 | 1173 | { |
1174 | 1174 | |
1175 | - global $wpdb; |
|
1175 | + global $wpdb; |
|
1176 | 1176 | |
1177 | - $count = 0; |
|
1178 | - if (!empty($field_ids)): |
|
1179 | - $post_meta_info = false; |
|
1180 | - foreach ($field_ids as $id) { |
|
1177 | + $count = 0; |
|
1178 | + if (!empty($field_ids)): |
|
1179 | + $post_meta_info = false; |
|
1180 | + foreach ($field_ids as $id) { |
|
1181 | 1181 | |
1182 | - $cf = trim($id, '_'); |
|
1182 | + $cf = trim($id, '_'); |
|
1183 | 1183 | |
1184 | - $post_meta_info = $wpdb->query( |
|
1185 | - $wpdb->prepare( |
|
1186 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1184 | + $post_meta_info = $wpdb->query( |
|
1185 | + $wpdb->prepare( |
|
1186 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1187 | 1187 | sort_order=%d |
1188 | 1188 | where id= %d", |
1189 | - array($count, $cf) |
|
1190 | - ) |
|
1191 | - ); |
|
1192 | - $count++; |
|
1193 | - } |
|
1194 | - |
|
1195 | - return $post_meta_info; |
|
1196 | - else: |
|
1197 | - return false; |
|
1198 | - endif; |
|
1189 | + array($count, $cf) |
|
1190 | + ) |
|
1191 | + ); |
|
1192 | + $count++; |
|
1193 | + } |
|
1194 | + |
|
1195 | + return $post_meta_info; |
|
1196 | + else: |
|
1197 | + return false; |
|
1198 | + endif; |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | |
1202 | 1202 | function geodir_get_cf_value($cf){ |
1203 | - global $gd_session; |
|
1204 | - $value = ''; |
|
1205 | - if (is_admin()) { |
|
1206 | - global $post,$gd_session; |
|
1207 | - |
|
1208 | - if (isset($_REQUEST['post'])) |
|
1209 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
1210 | - } |
|
1211 | - |
|
1212 | - if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) { |
|
1213 | - $post = $gd_ses_listing; |
|
1214 | - $value = isset($post[$cf['name']]) ? $post[$cf['name']] : ''; |
|
1215 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
1216 | - $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true); |
|
1217 | - } else { |
|
1218 | - if ($value == '') { |
|
1219 | - $value = $cf['default']; |
|
1220 | - } |
|
1221 | - } |
|
1222 | - return $value; |
|
1203 | + global $gd_session; |
|
1204 | + $value = ''; |
|
1205 | + if (is_admin()) { |
|
1206 | + global $post,$gd_session; |
|
1207 | + |
|
1208 | + if (isset($_REQUEST['post'])) |
|
1209 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
1210 | + } |
|
1211 | + |
|
1212 | + if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) { |
|
1213 | + $post = $gd_ses_listing; |
|
1214 | + $value = isset($post[$cf['name']]) ? $post[$cf['name']] : ''; |
|
1215 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
1216 | + $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true); |
|
1217 | + } else { |
|
1218 | + if ($value == '') { |
|
1219 | + $value = $cf['default']; |
|
1220 | + } |
|
1221 | + } |
|
1222 | + return $value; |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | /** |
@@ -1238,411 +1238,411 @@ discard block |
||
1238 | 1238 | * @param string $post_type Optional. The wordpress post type. |
1239 | 1239 | */ |
1240 | 1240 | function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') { |
1241 | - global $is_default, $mapzoom, $gd_session; |
|
1241 | + global $is_default, $mapzoom, $gd_session; |
|
1242 | 1242 | |
1243 | - $listing_type = $post_type; |
|
1243 | + $listing_type = $post_type; |
|
1244 | 1244 | |
1245 | - $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
1245 | + $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
1246 | 1246 | |
1247 | - foreach ($custom_fields as $key => $val) { |
|
1248 | - $val = stripslashes_deep($val); // strip slashes from labels |
|
1249 | - $name = $val['name']; |
|
1250 | - $type = $val['type']; |
|
1251 | - $is_default = $val['is_default']; |
|
1247 | + foreach ($custom_fields as $key => $val) { |
|
1248 | + $val = stripslashes_deep($val); // strip slashes from labels |
|
1249 | + $name = $val['name']; |
|
1250 | + $type = $val['type']; |
|
1251 | + $is_default = $val['is_default']; |
|
1252 | 1252 | |
1253 | - /* field available to site admin only for edit */ |
|
1254 | - $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
1255 | - if ($for_admin_use && !is_super_admin()) { |
|
1256 | - continue; |
|
1257 | - } |
|
1253 | + /* field available to site admin only for edit */ |
|
1254 | + $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
1255 | + if ($for_admin_use && !is_super_admin()) { |
|
1256 | + continue; |
|
1257 | + } |
|
1258 | 1258 | |
1259 | - if (is_admin()) { |
|
1260 | - global $post; |
|
1259 | + if (is_admin()) { |
|
1260 | + global $post; |
|
1261 | 1261 | |
1262 | - if (isset($_REQUEST['post'])) |
|
1263 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
1264 | - } |
|
1262 | + if (isset($_REQUEST['post'])) |
|
1263 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
1264 | + } |
|
1265 | 1265 | |
1266 | 1266 | |
1267 | 1267 | |
1268 | - /** |
|
1269 | - * Called before the custom fields info is output for submitting a post. |
|
1270 | - * |
|
1271 | - * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
1272 | - * |
|
1273 | - * @since 1.0.0 |
|
1274 | - * @param string $listing_type The post post type. |
|
1275 | - * @param int $package_id The price package ID for the post. |
|
1276 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1277 | - * @see 'geodir_after_custom_form_field_$name' |
|
1278 | - */ |
|
1279 | - do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1280 | - |
|
1281 | - |
|
1282 | - $custom_field = $val; |
|
1283 | - $html =''; |
|
1284 | - /** |
|
1285 | - * Filter the output for custom fields. |
|
1286 | - * |
|
1287 | - * Here we can remove or add new functions depending on the field type. |
|
1288 | - * |
|
1289 | - * @param string $html The html to be filtered (blank). |
|
1290 | - * @param array $custom_field The custom field array values. |
|
1291 | - */ |
|
1292 | - echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field); |
|
1293 | - |
|
1294 | - |
|
1295 | - |
|
1296 | - /** |
|
1297 | - * Called after the custom fields info is output for submitting a post. |
|
1298 | - * |
|
1299 | - * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
1300 | - * |
|
1301 | - * @since 1.0.0 |
|
1302 | - * @param string $listing_type The post post type. |
|
1303 | - * @param int $package_id The price package ID for the post. |
|
1304 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1305 | - * @see 'geodir_before_custom_form_field_$name' |
|
1306 | - */ |
|
1307 | - do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1308 | - |
|
1309 | - } |
|
1268 | + /** |
|
1269 | + * Called before the custom fields info is output for submitting a post. |
|
1270 | + * |
|
1271 | + * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
1272 | + * |
|
1273 | + * @since 1.0.0 |
|
1274 | + * @param string $listing_type The post post type. |
|
1275 | + * @param int $package_id The price package ID for the post. |
|
1276 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1277 | + * @see 'geodir_after_custom_form_field_$name' |
|
1278 | + */ |
|
1279 | + do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1280 | + |
|
1281 | + |
|
1282 | + $custom_field = $val; |
|
1283 | + $html =''; |
|
1284 | + /** |
|
1285 | + * Filter the output for custom fields. |
|
1286 | + * |
|
1287 | + * Here we can remove or add new functions depending on the field type. |
|
1288 | + * |
|
1289 | + * @param string $html The html to be filtered (blank). |
|
1290 | + * @param array $custom_field The custom field array values. |
|
1291 | + */ |
|
1292 | + echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field); |
|
1293 | + |
|
1294 | + |
|
1295 | + |
|
1296 | + /** |
|
1297 | + * Called after the custom fields info is output for submitting a post. |
|
1298 | + * |
|
1299 | + * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
1300 | + * |
|
1301 | + * @since 1.0.0 |
|
1302 | + * @param string $listing_type The post post type. |
|
1303 | + * @param int $package_id The price package ID for the post. |
|
1304 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1305 | + * @see 'geodir_before_custom_form_field_$name' |
|
1306 | + */ |
|
1307 | + do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1308 | + |
|
1309 | + } |
|
1310 | 1310 | |
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
1314 | 1314 | if (!function_exists('geodir_get_field_infoby')) { |
1315 | - /** |
|
1316 | - * Get custom field using key and value. |
|
1317 | - * |
|
1318 | - * @since 1.0.0 |
|
1319 | - * @package GeoDirectory |
|
1320 | - * @global object $wpdb WordPress Database object. |
|
1321 | - * @param string $key The key you want to look for. |
|
1322 | - * @param string $value The value of the key you want to look for. |
|
1323 | - * @param string $geodir_post_type The post type. |
|
1324 | - * @return bool|mixed Returns field info when available. otherwise returns false. |
|
1325 | - */ |
|
1326 | - function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
1327 | - { |
|
1328 | - |
|
1329 | - global $wpdb; |
|
1330 | - |
|
1331 | - $filter = $wpdb->get_row( |
|
1332 | - $wpdb->prepare( |
|
1333 | - "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
1334 | - array($geodir_post_type) |
|
1335 | - ) |
|
1336 | - ); |
|
1337 | - |
|
1338 | - if ($filter) { |
|
1339 | - return $filter; |
|
1340 | - } else { |
|
1341 | - return false; |
|
1342 | - } |
|
1343 | - |
|
1344 | - } |
|
1315 | + /** |
|
1316 | + * Get custom field using key and value. |
|
1317 | + * |
|
1318 | + * @since 1.0.0 |
|
1319 | + * @package GeoDirectory |
|
1320 | + * @global object $wpdb WordPress Database object. |
|
1321 | + * @param string $key The key you want to look for. |
|
1322 | + * @param string $value The value of the key you want to look for. |
|
1323 | + * @param string $geodir_post_type The post type. |
|
1324 | + * @return bool|mixed Returns field info when available. otherwise returns false. |
|
1325 | + */ |
|
1326 | + function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
1327 | + { |
|
1328 | + |
|
1329 | + global $wpdb; |
|
1330 | + |
|
1331 | + $filter = $wpdb->get_row( |
|
1332 | + $wpdb->prepare( |
|
1333 | + "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
1334 | + array($geodir_post_type) |
|
1335 | + ) |
|
1336 | + ); |
|
1337 | + |
|
1338 | + if ($filter) { |
|
1339 | + return $filter; |
|
1340 | + } else { |
|
1341 | + return false; |
|
1342 | + } |
|
1343 | + |
|
1344 | + } |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | |
1348 | 1348 | function geodir_field_icon_proccess($cf){ |
1349 | 1349 | |
1350 | 1350 | |
1351 | - if (strpos($cf['field_icon'], 'http') !== false) { |
|
1352 | - $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; |
|
1353 | - } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) { |
|
1354 | - $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
1355 | - }else{ |
|
1356 | - $field_icon = $cf['field_icon']; |
|
1357 | - } |
|
1351 | + if (strpos($cf['field_icon'], 'http') !== false) { |
|
1352 | + $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; |
|
1353 | + } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) { |
|
1354 | + $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
1355 | + }else{ |
|
1356 | + $field_icon = $cf['field_icon']; |
|
1357 | + } |
|
1358 | 1358 | |
1359 | - return $field_icon; |
|
1359 | + return $field_icon; |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | if (!function_exists('geodir_show_listing_info')) { |
1363 | - /** |
|
1364 | - * Show listing info depending on field location. |
|
1365 | - * |
|
1366 | - * @since 1.0.0 |
|
1367 | - * @since 1.5.7 Custom fields option values added to db translation. |
|
1368 | - * Changes to display url fields title. |
|
1369 | - * @package GeoDirectory |
|
1370 | - * @global object $wpdb WordPress Database object. |
|
1371 | - * @global object $post The current post object. |
|
1372 | - * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
1373 | - * |
|
1374 | - * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
1375 | - * @return string Returns listing info html. |
|
1376 | - */ |
|
1377 | - function geodir_show_listing_info($fields_location = '') { |
|
1378 | - global $post, $preview, $wpdb, $send_to_friend; |
|
1379 | - |
|
1380 | - $package_info = array(); |
|
1381 | - |
|
1382 | - $package_info = geodir_post_package_info($package_info, $post); |
|
1383 | - $post_package_id = $package_info->pid; |
|
1384 | - $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
1385 | - $send_to_friend = false; |
|
1386 | - |
|
1387 | - ob_start(); |
|
1388 | - $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
1389 | - |
|
1390 | - if (!empty($fields_info)) { |
|
1391 | - $post = stripslashes_deep($post); // strip slashes |
|
1363 | + /** |
|
1364 | + * Show listing info depending on field location. |
|
1365 | + * |
|
1366 | + * @since 1.0.0 |
|
1367 | + * @since 1.5.7 Custom fields option values added to db translation. |
|
1368 | + * Changes to display url fields title. |
|
1369 | + * @package GeoDirectory |
|
1370 | + * @global object $wpdb WordPress Database object. |
|
1371 | + * @global object $post The current post object. |
|
1372 | + * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
1373 | + * |
|
1374 | + * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
1375 | + * @return string Returns listing info html. |
|
1376 | + */ |
|
1377 | + function geodir_show_listing_info($fields_location = '') { |
|
1378 | + global $post, $preview, $wpdb, $send_to_friend; |
|
1379 | + |
|
1380 | + $package_info = array(); |
|
1381 | + |
|
1382 | + $package_info = geodir_post_package_info($package_info, $post); |
|
1383 | + $post_package_id = $package_info->pid; |
|
1384 | + $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
1385 | + $send_to_friend = false; |
|
1386 | + |
|
1387 | + ob_start(); |
|
1388 | + $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
1389 | + |
|
1390 | + if (!empty($fields_info)) { |
|
1391 | + $post = stripslashes_deep($post); // strip slashes |
|
1392 | 1392 | |
1393 | - //echo '<div class="geodir-company_info field-group">'; |
|
1394 | - global $field_set_start; |
|
1395 | - $field_set_start = 0; |
|
1396 | - |
|
1397 | - |
|
1398 | - |
|
1399 | - foreach ($fields_info as $type) { |
|
1400 | - $type = stripslashes_deep($type); // strip slashes |
|
1401 | - $html = ''; |
|
1402 | - $field_icon = geodir_field_icon_proccess($type); |
|
1403 | - $filed_type = $type['type']; |
|
1404 | - $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
1405 | - if($html_var=='post'){$html_var='post_address';} |
|
1406 | - |
|
1407 | - /** |
|
1408 | - * Filter the output for custom fields. |
|
1409 | - * |
|
1410 | - * Here we can remove or add new functions depending on the field type. |
|
1411 | - * |
|
1412 | - * @param string $html The html to be filtered (blank). |
|
1413 | - * @param string $fields_location The location the field is to be show. |
|
1414 | - * @param array $type The array of field values. |
|
1415 | - */ |
|
1416 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
1417 | - |
|
1418 | - $variables_array = array(); |
|
1419 | - |
|
1420 | - if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int)$type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { |
|
1421 | - continue; |
|
1422 | - } |
|
1423 | - |
|
1424 | - if ($type['type'] != 'fieldset'): |
|
1425 | - $variables_array['post_id'] = $post->ID; |
|
1426 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
1427 | - $variables_array['value'] = ''; |
|
1428 | - if (isset($post->{$type['htmlvar_name']})) |
|
1429 | - $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
1430 | - endif; |
|
1431 | - |
|
1432 | - |
|
1433 | - if ($html): |
|
1434 | - |
|
1435 | - /** |
|
1436 | - * Called before a custom fields is output on the frontend. |
|
1437 | - * |
|
1438 | - * @since 1.0.0 |
|
1439 | - * @param string $html_var The HTML variable name for the field. |
|
1440 | - */ |
|
1441 | - do_action("geodir_before_show_{$html_var}"); |
|
1442 | - /** |
|
1443 | - * Filter custom field output. |
|
1444 | - * |
|
1445 | - * @since 1.0.0 |
|
1446 | - * |
|
1447 | - * @param string $html_var The HTML variable name for the field. |
|
1448 | - * @param string $html Custom field unfiltered HTML. |
|
1449 | - * @param array $variables_array Custom field variables array. |
|
1450 | - */ |
|
1451 | - if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
1452 | - |
|
1453 | - /** |
|
1454 | - * Called after a custom fields is output on the frontend. |
|
1455 | - * |
|
1456 | - * @since 1.0.0 |
|
1457 | - * @param string $html_var The HTML variable name for the field. |
|
1458 | - */ |
|
1459 | - do_action("geodir_after_show_{$html_var}"); |
|
1460 | - |
|
1461 | - endif; |
|
1462 | - |
|
1463 | - } |
|
1464 | - |
|
1465 | - //echo '</div>'; |
|
1466 | - |
|
1467 | - } |
|
1468 | - |
|
1469 | - |
|
1470 | - return $html = ob_get_clean(); |
|
1471 | - |
|
1472 | - } |
|
1393 | + //echo '<div class="geodir-company_info field-group">'; |
|
1394 | + global $field_set_start; |
|
1395 | + $field_set_start = 0; |
|
1396 | + |
|
1397 | + |
|
1398 | + |
|
1399 | + foreach ($fields_info as $type) { |
|
1400 | + $type = stripslashes_deep($type); // strip slashes |
|
1401 | + $html = ''; |
|
1402 | + $field_icon = geodir_field_icon_proccess($type); |
|
1403 | + $filed_type = $type['type']; |
|
1404 | + $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
1405 | + if($html_var=='post'){$html_var='post_address';} |
|
1406 | + |
|
1407 | + /** |
|
1408 | + * Filter the output for custom fields. |
|
1409 | + * |
|
1410 | + * Here we can remove or add new functions depending on the field type. |
|
1411 | + * |
|
1412 | + * @param string $html The html to be filtered (blank). |
|
1413 | + * @param string $fields_location The location the field is to be show. |
|
1414 | + * @param array $type The array of field values. |
|
1415 | + */ |
|
1416 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
1417 | + |
|
1418 | + $variables_array = array(); |
|
1419 | + |
|
1420 | + if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int)$type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { |
|
1421 | + continue; |
|
1422 | + } |
|
1423 | + |
|
1424 | + if ($type['type'] != 'fieldset'): |
|
1425 | + $variables_array['post_id'] = $post->ID; |
|
1426 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
1427 | + $variables_array['value'] = ''; |
|
1428 | + if (isset($post->{$type['htmlvar_name']})) |
|
1429 | + $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
1430 | + endif; |
|
1431 | + |
|
1432 | + |
|
1433 | + if ($html): |
|
1434 | + |
|
1435 | + /** |
|
1436 | + * Called before a custom fields is output on the frontend. |
|
1437 | + * |
|
1438 | + * @since 1.0.0 |
|
1439 | + * @param string $html_var The HTML variable name for the field. |
|
1440 | + */ |
|
1441 | + do_action("geodir_before_show_{$html_var}"); |
|
1442 | + /** |
|
1443 | + * Filter custom field output. |
|
1444 | + * |
|
1445 | + * @since 1.0.0 |
|
1446 | + * |
|
1447 | + * @param string $html_var The HTML variable name for the field. |
|
1448 | + * @param string $html Custom field unfiltered HTML. |
|
1449 | + * @param array $variables_array Custom field variables array. |
|
1450 | + */ |
|
1451 | + if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
1452 | + |
|
1453 | + /** |
|
1454 | + * Called after a custom fields is output on the frontend. |
|
1455 | + * |
|
1456 | + * @since 1.0.0 |
|
1457 | + * @param string $html_var The HTML variable name for the field. |
|
1458 | + */ |
|
1459 | + do_action("geodir_after_show_{$html_var}"); |
|
1460 | + |
|
1461 | + endif; |
|
1462 | + |
|
1463 | + } |
|
1464 | + |
|
1465 | + //echo '</div>'; |
|
1466 | + |
|
1467 | + } |
|
1468 | + |
|
1469 | + |
|
1470 | + return $html = ob_get_clean(); |
|
1471 | + |
|
1472 | + } |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | if (!function_exists('geodir_default_date_format')) { |
1476 | - /** |
|
1477 | - * Returns default date format. |
|
1478 | - * |
|
1479 | - * @since 1.0.0 |
|
1480 | - * @package GeoDirectory |
|
1481 | - * @return mixed|string|void Returns default date format. |
|
1482 | - */ |
|
1483 | - function geodir_default_date_format() |
|
1484 | - { |
|
1485 | - if ($format = get_option('date_format')) |
|
1486 | - return $format; |
|
1487 | - else |
|
1488 | - return 'dd-mm-yy'; |
|
1489 | - } |
|
1476 | + /** |
|
1477 | + * Returns default date format. |
|
1478 | + * |
|
1479 | + * @since 1.0.0 |
|
1480 | + * @package GeoDirectory |
|
1481 | + * @return mixed|string|void Returns default date format. |
|
1482 | + */ |
|
1483 | + function geodir_default_date_format() |
|
1484 | + { |
|
1485 | + if ($format = get_option('date_format')) |
|
1486 | + return $format; |
|
1487 | + else |
|
1488 | + return 'dd-mm-yy'; |
|
1489 | + } |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | if (!function_exists('geodir_get_formated_date')) { |
1493 | - /** |
|
1494 | - * Returns formatted date. |
|
1495 | - * |
|
1496 | - * @since 1.0.0 |
|
1497 | - * @package GeoDirectory |
|
1498 | - * @param string $date Date string to convert. |
|
1499 | - * @return bool|int|string Returns formatted date. |
|
1500 | - */ |
|
1501 | - function geodir_get_formated_date($date) |
|
1502 | - { |
|
1503 | - return mysql2date(get_option('date_format'), $date); |
|
1504 | - } |
|
1493 | + /** |
|
1494 | + * Returns formatted date. |
|
1495 | + * |
|
1496 | + * @since 1.0.0 |
|
1497 | + * @package GeoDirectory |
|
1498 | + * @param string $date Date string to convert. |
|
1499 | + * @return bool|int|string Returns formatted date. |
|
1500 | + */ |
|
1501 | + function geodir_get_formated_date($date) |
|
1502 | + { |
|
1503 | + return mysql2date(get_option('date_format'), $date); |
|
1504 | + } |
|
1505 | 1505 | } |
1506 | 1506 | |
1507 | 1507 | if (!function_exists('geodir_get_formated_time')) { |
1508 | - /** |
|
1509 | - * Returns formatted time. |
|
1510 | - * |
|
1511 | - * @since 1.0.0 |
|
1512 | - * @package GeoDirectory |
|
1513 | - * @param string $time Time string to convert. |
|
1514 | - * @return bool|int|string Returns formatted time. |
|
1515 | - */ |
|
1516 | - function geodir_get_formated_time($time) |
|
1517 | - { |
|
1518 | - return mysql2date(get_option('time_format'), $time, $translate = true); |
|
1519 | - } |
|
1508 | + /** |
|
1509 | + * Returns formatted time. |
|
1510 | + * |
|
1511 | + * @since 1.0.0 |
|
1512 | + * @package GeoDirectory |
|
1513 | + * @param string $time Time string to convert. |
|
1514 | + * @return bool|int|string Returns formatted time. |
|
1515 | + */ |
|
1516 | + function geodir_get_formated_time($time) |
|
1517 | + { |
|
1518 | + return mysql2date(get_option('time_format'), $time, $translate = true); |
|
1519 | + } |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | |
1523 | 1523 | if (!function_exists('geodir_save_post_file_fields')) { |
1524 | - /** |
|
1525 | - * Save post file fields |
|
1526 | - * |
|
1527 | - * @since 1.0.0 |
|
1528 | - * @since 1.4.7 Added `$extra_fields` parameter. |
|
1529 | - * @package GeoDirectory |
|
1530 | - * @global object $wpdb WordPress Database object. |
|
1531 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1532 | - * @global object $current_user Current user object. |
|
1533 | - * @param int $post_id |
|
1534 | - * @param string $field_id |
|
1535 | - * @param array $post_image |
|
1536 | - * @param array $extra_fields Array of extra fields. |
|
1537 | - */ |
|
1538 | - function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
1539 | - { |
|
1524 | + /** |
|
1525 | + * Save post file fields |
|
1526 | + * |
|
1527 | + * @since 1.0.0 |
|
1528 | + * @since 1.4.7 Added `$extra_fields` parameter. |
|
1529 | + * @package GeoDirectory |
|
1530 | + * @global object $wpdb WordPress Database object. |
|
1531 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1532 | + * @global object $current_user Current user object. |
|
1533 | + * @param int $post_id |
|
1534 | + * @param string $field_id |
|
1535 | + * @param array $post_image |
|
1536 | + * @param array $extra_fields Array of extra fields. |
|
1537 | + */ |
|
1538 | + function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
1539 | + { |
|
1540 | 1540 | |
1541 | - global $wpdb, $plugin_prefix, $current_user; |
|
1541 | + global $wpdb, $plugin_prefix, $current_user; |
|
1542 | 1542 | |
1543 | - $post_type = get_post_type($post_id); |
|
1544 | - //echo $field_id; exit; |
|
1545 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1543 | + $post_type = get_post_type($post_id); |
|
1544 | + //echo $field_id; exit; |
|
1545 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1546 | 1546 | |
1547 | - $postcurr_images = array(); |
|
1548 | - $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
1549 | - $file_urls = ''; |
|
1547 | + $postcurr_images = array(); |
|
1548 | + $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
1549 | + $file_urls = ''; |
|
1550 | 1550 | |
1551 | - if (!empty($post_image)) { |
|
1551 | + if (!empty($post_image)) { |
|
1552 | 1552 | |
1553 | - $invalid_files = array(); |
|
1553 | + $invalid_files = array(); |
|
1554 | 1554 | |
1555 | - //Get and remove all old images of post from database to set by new order |
|
1556 | - $geodir_uploaddir = ''; |
|
1557 | - $uploads = wp_upload_dir(); |
|
1558 | - $uploads_dir = $uploads['path']; |
|
1555 | + //Get and remove all old images of post from database to set by new order |
|
1556 | + $geodir_uploaddir = ''; |
|
1557 | + $uploads = wp_upload_dir(); |
|
1558 | + $uploads_dir = $uploads['path']; |
|
1559 | 1559 | |
1560 | - $geodir_uploadpath = $uploads['path']; |
|
1561 | - $geodir_uploadurl = $uploads['url']; |
|
1562 | - $sub_dir = $uploads['subdir']; |
|
1560 | + $geodir_uploadpath = $uploads['path']; |
|
1561 | + $geodir_uploadurl = $uploads['url']; |
|
1562 | + $sub_dir = $uploads['subdir']; |
|
1563 | 1563 | |
1564 | - $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'] : ''; |
|
1564 | + $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'] : ''; |
|
1565 | 1565 | |
1566 | - for ($m = 0; $m < count($post_image); $m++) { |
|
1566 | + for ($m = 0; $m < count($post_image); $m++) { |
|
1567 | 1567 | |
1568 | - /* --------- start ------- */ |
|
1568 | + /* --------- start ------- */ |
|
1569 | 1569 | |
1570 | - 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)))) { |
|
1570 | + 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)))) { |
|
1571 | 1571 | |
1572 | 1572 | |
1573 | - $curr_img_url = $post_image[$m]; |
|
1574 | - $image_name_arr = explode('/', $curr_img_url); |
|
1575 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
1576 | - $filename = end($image_name_arr); |
|
1577 | - $img_name_arr = explode('.', $filename); |
|
1573 | + $curr_img_url = $post_image[$m]; |
|
1574 | + $image_name_arr = explode('/', $curr_img_url); |
|
1575 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
1576 | + $filename = end($image_name_arr); |
|
1577 | + $img_name_arr = explode('.', $filename); |
|
1578 | 1578 | |
1579 | - $arr_file_type = wp_check_filetype($filename); |
|
1579 | + $arr_file_type = wp_check_filetype($filename); |
|
1580 | 1580 | |
1581 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
1582 | - continue; |
|
1583 | - } |
|
1581 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
1582 | + continue; |
|
1583 | + } |
|
1584 | 1584 | |
1585 | - $uploaded_file_type = $arr_file_type['type']; |
|
1586 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
1585 | + $uploaded_file_type = $arr_file_type['type']; |
|
1586 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
1587 | 1587 | |
1588 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
1589 | - continue; // Invalid file type. |
|
1590 | - } |
|
1588 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
1589 | + continue; // Invalid file type. |
|
1590 | + } |
|
1591 | 1591 | |
1592 | - // Set an array containing a list of acceptable formats |
|
1593 | - //$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'); |
|
1592 | + // Set an array containing a list of acceptable formats |
|
1593 | + //$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'); |
|
1594 | 1594 | |
1595 | - if (!function_exists('wp_handle_upload')) |
|
1596 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1595 | + if (!function_exists('wp_handle_upload')) |
|
1596 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1597 | 1597 | |
1598 | - if (!is_dir($geodir_uploadpath)) |
|
1599 | - mkdir($geodir_uploadpath); |
|
1598 | + if (!is_dir($geodir_uploadpath)) |
|
1599 | + mkdir($geodir_uploadpath); |
|
1600 | 1600 | |
1601 | - $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
1602 | - $explode_sub_dir = explode("/", $sub_dir); |
|
1603 | - if ($curr_img_dir == end($explode_sub_dir)) { |
|
1604 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
1605 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
1606 | - } else { |
|
1607 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1608 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1609 | - } |
|
1601 | + $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
1602 | + $explode_sub_dir = explode("/", $sub_dir); |
|
1603 | + if ($curr_img_dir == end($explode_sub_dir)) { |
|
1604 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
1605 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
1606 | + } else { |
|
1607 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1608 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1609 | + } |
|
1610 | 1610 | |
1611 | - $uploaded_file = ''; |
|
1612 | - if (file_exists($img_path)) |
|
1613 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1611 | + $uploaded_file = ''; |
|
1612 | + if (file_exists($img_path)) |
|
1613 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1614 | 1614 | |
1615 | - if ($curr_img_dir != $geodir_uploaddir) { |
|
1616 | - if (file_exists($img_path)) |
|
1617 | - unlink($img_path); |
|
1618 | - } |
|
1615 | + if ($curr_img_dir != $geodir_uploaddir) { |
|
1616 | + if (file_exists($img_path)) |
|
1617 | + unlink($img_path); |
|
1618 | + } |
|
1619 | 1619 | |
1620 | - if (!empty($uploaded_file)) |
|
1621 | - $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
1620 | + if (!empty($uploaded_file)) |
|
1621 | + $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
1622 | 1622 | |
1623 | - } else { |
|
1624 | - $file_urls = $post_image[$m]; |
|
1625 | - } |
|
1626 | - } |
|
1623 | + } else { |
|
1624 | + $file_urls = $post_image[$m]; |
|
1625 | + } |
|
1626 | + } |
|
1627 | 1627 | |
1628 | 1628 | |
1629 | - } |
|
1629 | + } |
|
1630 | 1630 | |
1631 | - //Remove all old attachments and temp images |
|
1632 | - if (!empty($postcurr_images)) { |
|
1631 | + //Remove all old attachments and temp images |
|
1632 | + if (!empty($postcurr_images)) { |
|
1633 | 1633 | |
1634 | - if ($file_urls != $postcurr_images) { |
|
1635 | - $invalid_files[] = (object)array('src' => $postcurr_images); |
|
1636 | - $invalid_files = (object)$invalid_files; |
|
1637 | - } |
|
1638 | - } |
|
1634 | + if ($file_urls != $postcurr_images) { |
|
1635 | + $invalid_files[] = (object)array('src' => $postcurr_images); |
|
1636 | + $invalid_files = (object)$invalid_files; |
|
1637 | + } |
|
1638 | + } |
|
1639 | 1639 | |
1640 | - geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
1640 | + geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
1641 | 1641 | |
1642 | - if (!empty($invalid_files)) |
|
1643 | - geodir_remove_attachments($invalid_files); |
|
1642 | + if (!empty($invalid_files)) |
|
1643 | + geodir_remove_attachments($invalid_files); |
|
1644 | 1644 | |
1645 | - } |
|
1645 | + } |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | |
@@ -1657,76 +1657,76 @@ discard block |
||
1657 | 1657 | */ |
1658 | 1658 | function geodir_custom_upload_mimes($existing_mimes = array()) |
1659 | 1659 | { |
1660 | - $existing_mimes['wif'] = 'text/plain'; |
|
1661 | - $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
1662 | - $existing_mimes['gif'] = 'image/gif'; |
|
1663 | - $existing_mimes['png'] = 'image/png'; |
|
1664 | - $existing_mimes['pdf'] = 'application/pdf'; |
|
1665 | - $existing_mimes['txt'] = 'text/text'; |
|
1666 | - $existing_mimes['csv'] = 'application/octet-stream'; |
|
1667 | - $existing_mimes['doc'] = 'application/msword'; |
|
1668 | - $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
1669 | - $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
1670 | - $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
1671 | - return $existing_mimes; |
|
1660 | + $existing_mimes['wif'] = 'text/plain'; |
|
1661 | + $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
1662 | + $existing_mimes['gif'] = 'image/gif'; |
|
1663 | + $existing_mimes['png'] = 'image/png'; |
|
1664 | + $existing_mimes['pdf'] = 'application/pdf'; |
|
1665 | + $existing_mimes['txt'] = 'text/text'; |
|
1666 | + $existing_mimes['csv'] = 'application/octet-stream'; |
|
1667 | + $existing_mimes['doc'] = 'application/msword'; |
|
1668 | + $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
1669 | + $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
1670 | + $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
1671 | + return $existing_mimes; |
|
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | if (!function_exists('geodir_plupload_action')) { |
1675 | 1675 | |
1676 | - /** |
|
1677 | - * Get upload directory path details |
|
1678 | - * |
|
1679 | - * @since 1.0.0 |
|
1680 | - * @package GeoDirectory |
|
1681 | - * @global object $current_user Current user object. |
|
1682 | - * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
1683 | - * @return mixed Returns upload directory details as an array. |
|
1684 | - */ |
|
1685 | - function geodir_upload_dir($upload) |
|
1686 | - { |
|
1687 | - global $current_user; |
|
1688 | - $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
1689 | - $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
1690 | - $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
1691 | - return $upload; |
|
1692 | - } |
|
1693 | - |
|
1694 | - /** |
|
1695 | - * Handles place file and image upload. |
|
1696 | - * |
|
1697 | - * @since 1.0.0 |
|
1698 | - * @package GeoDirectory |
|
1699 | - */ |
|
1700 | - function geodir_plupload_action() |
|
1701 | - { |
|
1702 | - // check ajax noonce |
|
1703 | - $imgid = $_POST["imgid"]; |
|
1704 | - |
|
1705 | - check_ajax_referer($imgid . 'pluploadan'); |
|
1706 | - |
|
1707 | - // handle custom file uploaddir |
|
1708 | - add_filter('upload_dir', 'geodir_upload_dir'); |
|
1709 | - |
|
1710 | - // change file orinetation if needed |
|
1711 | - $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
1712 | - |
|
1713 | - // handle file upload |
|
1714 | - $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action')); |
|
1715 | - // remove handle custom file uploaddir |
|
1716 | - remove_filter('upload_dir', 'geodir_upload_dir'); |
|
1717 | - |
|
1718 | - if(!isset($status['url']) && isset($status['error'])){ |
|
1719 | - print_r($status); |
|
1720 | - } |
|
1721 | - |
|
1722 | - // send the uploaded file url in response |
|
1723 | - if (isset($status['url'])) { |
|
1724 | - echo $status['url']; |
|
1725 | - } else { |
|
1726 | - echo 'x'; |
|
1727 | - } |
|
1728 | - exit; |
|
1729 | - } |
|
1676 | + /** |
|
1677 | + * Get upload directory path details |
|
1678 | + * |
|
1679 | + * @since 1.0.0 |
|
1680 | + * @package GeoDirectory |
|
1681 | + * @global object $current_user Current user object. |
|
1682 | + * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
1683 | + * @return mixed Returns upload directory details as an array. |
|
1684 | + */ |
|
1685 | + function geodir_upload_dir($upload) |
|
1686 | + { |
|
1687 | + global $current_user; |
|
1688 | + $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
1689 | + $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
1690 | + $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
1691 | + return $upload; |
|
1692 | + } |
|
1693 | + |
|
1694 | + /** |
|
1695 | + * Handles place file and image upload. |
|
1696 | + * |
|
1697 | + * @since 1.0.0 |
|
1698 | + * @package GeoDirectory |
|
1699 | + */ |
|
1700 | + function geodir_plupload_action() |
|
1701 | + { |
|
1702 | + // check ajax noonce |
|
1703 | + $imgid = $_POST["imgid"]; |
|
1704 | + |
|
1705 | + check_ajax_referer($imgid . 'pluploadan'); |
|
1706 | + |
|
1707 | + // handle custom file uploaddir |
|
1708 | + add_filter('upload_dir', 'geodir_upload_dir'); |
|
1709 | + |
|
1710 | + // change file orinetation if needed |
|
1711 | + $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
1712 | + |
|
1713 | + // handle file upload |
|
1714 | + $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action')); |
|
1715 | + // remove handle custom file uploaddir |
|
1716 | + remove_filter('upload_dir', 'geodir_upload_dir'); |
|
1717 | + |
|
1718 | + if(!isset($status['url']) && isset($status['error'])){ |
|
1719 | + print_r($status); |
|
1720 | + } |
|
1721 | + |
|
1722 | + // send the uploaded file url in response |
|
1723 | + if (isset($status['url'])) { |
|
1724 | + echo $status['url']; |
|
1725 | + } else { |
|
1726 | + echo 'x'; |
|
1727 | + } |
|
1728 | + exit; |
|
1729 | + } |
|
1730 | 1730 | } |
1731 | 1731 | |
1732 | 1732 | /** |
@@ -1741,17 +1741,17 @@ discard block |
||
1741 | 1741 | */ |
1742 | 1742 | function geodir_get_video($post_id) |
1743 | 1743 | { |
1744 | - global $wpdb, $plugin_prefix; |
|
1744 | + global $wpdb, $plugin_prefix; |
|
1745 | 1745 | |
1746 | - $post_type = get_post_type($post_id); |
|
1746 | + $post_type = get_post_type($post_id); |
|
1747 | 1747 | |
1748 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1748 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1749 | 1749 | |
1750 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1750 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1751 | 1751 | |
1752 | - if ($results) { |
|
1753 | - return $results[0]->geodir_video; |
|
1754 | - } |
|
1752 | + if ($results) { |
|
1753 | + return $results[0]->geodir_video; |
|
1754 | + } |
|
1755 | 1755 | |
1756 | 1756 | } |
1757 | 1757 | |
@@ -1767,40 +1767,40 @@ discard block |
||
1767 | 1767 | */ |
1768 | 1768 | function geodir_get_special_offers($post_id) |
1769 | 1769 | { |
1770 | - global $wpdb, $plugin_prefix; |
|
1770 | + global $wpdb, $plugin_prefix; |
|
1771 | 1771 | |
1772 | - $post_type = get_post_type($post_id); |
|
1772 | + $post_type = get_post_type($post_id); |
|
1773 | 1773 | |
1774 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1774 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1775 | 1775 | |
1776 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1776 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1777 | 1777 | |
1778 | - if ($results) { |
|
1779 | - return $results[0]->geodir_special_offers; |
|
1780 | - } |
|
1778 | + if ($results) { |
|
1779 | + return $results[0]->geodir_special_offers; |
|
1780 | + } |
|
1781 | 1781 | |
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | if (!function_exists('geodir_max_upload_size')) { |
1785 | - /** |
|
1786 | - * Get max upload file size |
|
1787 | - * |
|
1788 | - * @since 1.0.0 |
|
1789 | - * @package GeoDirectory |
|
1790 | - * @return mixed|void Returns max upload file size. |
|
1791 | - */ |
|
1792 | - function geodir_max_upload_size() |
|
1793 | - { |
|
1794 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2); |
|
1795 | - |
|
1796 | - if ($max_filesize > 0 && $max_filesize < 1) { |
|
1797 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
1798 | - } else { |
|
1799 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
1800 | - } |
|
1801 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
1802 | - return apply_filters('geodir_default_image_upload_size_limit', $max_filesize); |
|
1803 | - } |
|
1785 | + /** |
|
1786 | + * Get max upload file size |
|
1787 | + * |
|
1788 | + * @since 1.0.0 |
|
1789 | + * @package GeoDirectory |
|
1790 | + * @return mixed|void Returns max upload file size. |
|
1791 | + */ |
|
1792 | + function geodir_max_upload_size() |
|
1793 | + { |
|
1794 | + $max_filesize = (float)get_option('geodir_upload_max_filesize', 2); |
|
1795 | + |
|
1796 | + if ($max_filesize > 0 && $max_filesize < 1) { |
|
1797 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
1798 | + } else { |
|
1799 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
1800 | + } |
|
1801 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
1802 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize); |
|
1803 | + } |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | |
@@ -1818,33 +1818,33 @@ discard block |
||
1818 | 1818 | */ |
1819 | 1819 | function geodir_add_custom_sort_options($fields, $post_type) |
1820 | 1820 | { |
1821 | - global $wpdb; |
|
1821 | + global $wpdb; |
|
1822 | 1822 | |
1823 | - if ($post_type != '') { |
|
1823 | + if ($post_type != '') { |
|
1824 | 1824 | |
1825 | - $all_postypes = geodir_get_posttypes(); |
|
1825 | + $all_postypes = geodir_get_posttypes(); |
|
1826 | 1826 | |
1827 | - if (in_array($post_type, $all_postypes)) { |
|
1827 | + if (in_array($post_type, $all_postypes)) { |
|
1828 | 1828 | |
1829 | - $custom_fields = $wpdb->get_results( |
|
1830 | - $wpdb->prepare( |
|
1831 | - "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", |
|
1832 | - array($post_type) |
|
1833 | - ), 'ARRAY_A' |
|
1834 | - ); |
|
1829 | + $custom_fields = $wpdb->get_results( |
|
1830 | + $wpdb->prepare( |
|
1831 | + "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", |
|
1832 | + array($post_type) |
|
1833 | + ), 'ARRAY_A' |
|
1834 | + ); |
|
1835 | 1835 | |
1836 | - if (!empty($custom_fields)) { |
|
1836 | + if (!empty($custom_fields)) { |
|
1837 | 1837 | |
1838 | - foreach ($custom_fields as $val) { |
|
1839 | - $fields[] = $val; |
|
1840 | - } |
|
1841 | - } |
|
1838 | + foreach ($custom_fields as $val) { |
|
1839 | + $fields[] = $val; |
|
1840 | + } |
|
1841 | + } |
|
1842 | 1842 | |
1843 | - } |
|
1843 | + } |
|
1844 | 1844 | |
1845 | - } |
|
1845 | + } |
|
1846 | 1846 | |
1847 | - return $fields; |
|
1847 | + return $fields; |
|
1848 | 1848 | } |
1849 | 1849 | |
1850 | 1850 | |
@@ -1860,76 +1860,76 @@ discard block |
||
1860 | 1860 | function geodir_get_custom_sort_options($post_type = '') |
1861 | 1861 | { |
1862 | 1862 | |
1863 | - global $wpdb; |
|
1864 | - |
|
1865 | - if ($post_type != '') { |
|
1866 | - |
|
1867 | - $all_postypes = geodir_get_posttypes(); |
|
1868 | - |
|
1869 | - if (!in_array($post_type, $all_postypes)) |
|
1870 | - return false; |
|
1871 | - |
|
1872 | - $fields = array(); |
|
1873 | - |
|
1874 | - $fields[] = array( |
|
1875 | - 'post_type' => $post_type, |
|
1876 | - 'data_type' => '', |
|
1877 | - 'field_type' => 'random', |
|
1878 | - 'site_title' => 'Random', |
|
1879 | - 'htmlvar_name' => 'post_title', |
|
1880 | - 'field_icon' => 'fa fa-random', |
|
1881 | - 'description' => __('Random sort (not recommended for large sites)', 'geodirectory') |
|
1882 | - ); |
|
1883 | - |
|
1884 | - $fields[] = array( |
|
1885 | - 'post_type' => $post_type, |
|
1886 | - 'data_type' => '', |
|
1887 | - 'field_type' => 'datetime', |
|
1888 | - 'site_title' => __('Add date', 'geodirectory'), |
|
1889 | - 'htmlvar_name' => 'post_date', |
|
1890 | - 'field_icon' => 'fa fa-calendar', |
|
1891 | - 'description' => __('Sort by date added', 'geodirectory') |
|
1892 | - ); |
|
1893 | - $fields[] = array( |
|
1894 | - 'post_type' => $post_type, |
|
1895 | - 'data_type' => '', |
|
1896 | - 'field_type' => 'bigint', |
|
1897 | - 'site_title' => __('Review', 'geodirectory'), |
|
1898 | - 'htmlvar_name' => 'comment_count', |
|
1899 | - 'field_icon' => 'fa fa-commenting-o', |
|
1900 | - 'description' => __('Sort by the number of reviews', 'geodirectory') |
|
1901 | - ); |
|
1902 | - $fields[] = array( |
|
1903 | - 'post_type' => $post_type, |
|
1904 | - 'data_type' => '', |
|
1905 | - 'field_type' => 'float', |
|
1906 | - 'site_title' => __('Rating', 'geodirectory'), |
|
1907 | - 'htmlvar_name' => 'overall_rating', |
|
1908 | - 'field_icon' => 'fa fa-star-o', |
|
1909 | - 'description' => __('Sort by the overall rating value', 'geodirectory') |
|
1910 | - ); |
|
1911 | - $fields[] = array( |
|
1912 | - 'post_type' => $post_type, |
|
1913 | - 'data_type' => '', |
|
1914 | - 'field_type' => 'text', |
|
1915 | - 'site_title' => __('Title', 'geodirectory'), |
|
1916 | - 'htmlvar_name' => 'post_title', |
|
1917 | - 'field_icon' => 'fa fa-sort-alpha-desc', |
|
1918 | - 'description' => __('Sort alphabetically by title', 'geodirectory') |
|
1919 | - ); |
|
1920 | - |
|
1921 | - /** |
|
1922 | - * Hook to add custom sort options. |
|
1923 | - * |
|
1924 | - * @since 1.0.0 |
|
1925 | - * @param array $fields Unmodified sort options array. |
|
1926 | - * @param string $post_type Post type. |
|
1927 | - */ |
|
1928 | - return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); |
|
1929 | - |
|
1930 | - } |
|
1931 | - |
|
1932 | - return false; |
|
1863 | + global $wpdb; |
|
1864 | + |
|
1865 | + if ($post_type != '') { |
|
1866 | + |
|
1867 | + $all_postypes = geodir_get_posttypes(); |
|
1868 | + |
|
1869 | + if (!in_array($post_type, $all_postypes)) |
|
1870 | + return false; |
|
1871 | + |
|
1872 | + $fields = array(); |
|
1873 | + |
|
1874 | + $fields[] = array( |
|
1875 | + 'post_type' => $post_type, |
|
1876 | + 'data_type' => '', |
|
1877 | + 'field_type' => 'random', |
|
1878 | + 'site_title' => 'Random', |
|
1879 | + 'htmlvar_name' => 'post_title', |
|
1880 | + 'field_icon' => 'fa fa-random', |
|
1881 | + 'description' => __('Random sort (not recommended for large sites)', 'geodirectory') |
|
1882 | + ); |
|
1883 | + |
|
1884 | + $fields[] = array( |
|
1885 | + 'post_type' => $post_type, |
|
1886 | + 'data_type' => '', |
|
1887 | + 'field_type' => 'datetime', |
|
1888 | + 'site_title' => __('Add date', 'geodirectory'), |
|
1889 | + 'htmlvar_name' => 'post_date', |
|
1890 | + 'field_icon' => 'fa fa-calendar', |
|
1891 | + 'description' => __('Sort by date added', 'geodirectory') |
|
1892 | + ); |
|
1893 | + $fields[] = array( |
|
1894 | + 'post_type' => $post_type, |
|
1895 | + 'data_type' => '', |
|
1896 | + 'field_type' => 'bigint', |
|
1897 | + 'site_title' => __('Review', 'geodirectory'), |
|
1898 | + 'htmlvar_name' => 'comment_count', |
|
1899 | + 'field_icon' => 'fa fa-commenting-o', |
|
1900 | + 'description' => __('Sort by the number of reviews', 'geodirectory') |
|
1901 | + ); |
|
1902 | + $fields[] = array( |
|
1903 | + 'post_type' => $post_type, |
|
1904 | + 'data_type' => '', |
|
1905 | + 'field_type' => 'float', |
|
1906 | + 'site_title' => __('Rating', 'geodirectory'), |
|
1907 | + 'htmlvar_name' => 'overall_rating', |
|
1908 | + 'field_icon' => 'fa fa-star-o', |
|
1909 | + 'description' => __('Sort by the overall rating value', 'geodirectory') |
|
1910 | + ); |
|
1911 | + $fields[] = array( |
|
1912 | + 'post_type' => $post_type, |
|
1913 | + 'data_type' => '', |
|
1914 | + 'field_type' => 'text', |
|
1915 | + 'site_title' => __('Title', 'geodirectory'), |
|
1916 | + 'htmlvar_name' => 'post_title', |
|
1917 | + 'field_icon' => 'fa fa-sort-alpha-desc', |
|
1918 | + 'description' => __('Sort alphabetically by title', 'geodirectory') |
|
1919 | + ); |
|
1920 | + |
|
1921 | + /** |
|
1922 | + * Hook to add custom sort options. |
|
1923 | + * |
|
1924 | + * @since 1.0.0 |
|
1925 | + * @param array $fields Unmodified sort options array. |
|
1926 | + * @param string $post_type Post type. |
|
1927 | + */ |
|
1928 | + return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); |
|
1929 | + |
|
1930 | + } |
|
1931 | + |
|
1932 | + return false; |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | |
@@ -1945,117 +1945,117 @@ discard block |
||
1945 | 1945 | function godir_set_sort_field_order($field_ids = array()) |
1946 | 1946 | { |
1947 | 1947 | |
1948 | - global $wpdb; |
|
1948 | + global $wpdb; |
|
1949 | 1949 | |
1950 | - $count = 0; |
|
1951 | - if (!empty($field_ids)): |
|
1952 | - foreach ($field_ids as $id) { |
|
1950 | + $count = 0; |
|
1951 | + if (!empty($field_ids)): |
|
1952 | + foreach ($field_ids as $id) { |
|
1953 | 1953 | |
1954 | - $cf = trim($id, '_'); |
|
1954 | + $cf = trim($id, '_'); |
|
1955 | 1955 | |
1956 | - $post_meta_info = $wpdb->query( |
|
1957 | - $wpdb->prepare( |
|
1958 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1956 | + $post_meta_info = $wpdb->query( |
|
1957 | + $wpdb->prepare( |
|
1958 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1959 | 1959 | sort_order=%d |
1960 | 1960 | where id= %d", |
1961 | - array($count, $cf) |
|
1962 | - ) |
|
1963 | - ); |
|
1964 | - $count++; |
|
1965 | - } |
|
1966 | - |
|
1967 | - return $field_ids; |
|
1968 | - else: |
|
1969 | - return false; |
|
1970 | - endif; |
|
1961 | + array($count, $cf) |
|
1962 | + ) |
|
1963 | + ); |
|
1964 | + $count++; |
|
1965 | + } |
|
1966 | + |
|
1967 | + return $field_ids; |
|
1968 | + else: |
|
1969 | + return false; |
|
1970 | + endif; |
|
1971 | 1971 | } |
1972 | 1972 | |
1973 | 1973 | |
1974 | 1974 | if (!function_exists('geodir_custom_sort_field_save')) { |
1975 | - /** |
|
1976 | - * Save or Update custom sort fields into the database. |
|
1977 | - * |
|
1978 | - * @since 1.0.0 |
|
1979 | - * @package GeoDirectory |
|
1980 | - * @global object $wpdb WordPress Database object. |
|
1981 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1982 | - * @param array $request_field { |
|
1983 | - * Attributes of the Request field. |
|
1984 | - * |
|
1985 | - * @type string $action Ajax action name. |
|
1986 | - * @type string $manage_field_type Manage field type Default "sorting_options". |
|
1987 | - * @type string $create_field Do you want to create this field?. |
|
1988 | - * @type string $field_ins_upd Field created or updated?. |
|
1989 | - * @type string $_wpnonce Nonce value. |
|
1990 | - * @type string $listing_type The Post type. |
|
1991 | - * @type string $field_type Field Type. |
|
1992 | - * @type string $field_id Field ID. |
|
1993 | - * @type string $data_type Data Type. |
|
1994 | - * @type string $htmlvar_name HTML variable name. |
|
1995 | - * @type string $site_title Section title which you wish to display in frontend. |
|
1996 | - * @type string $is_default Is this default sorting?. |
|
1997 | - * @type string $is_active If not active then the field will not be displayed anywhere. |
|
1998 | - * @type string $sort_order Sort Order. |
|
1999 | - * |
|
2000 | - * } |
|
2001 | - * @param bool $default Not yet implemented. |
|
2002 | - * @return int Returns the last affected db table row id. |
|
2003 | - */ |
|
2004 | - function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
2005 | - { |
|
2006 | - |
|
2007 | - global $wpdb, $plugin_prefix; |
|
2008 | - |
|
2009 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
2010 | - |
|
2011 | - $cf = trim($result_str, '_'); |
|
2012 | - |
|
2013 | - /*-------- check dublicate validation --------*/ |
|
2014 | - |
|
2015 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2016 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2017 | - |
|
2018 | - $post_type = $request_field['listing_type']; |
|
2019 | - $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
2020 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2021 | - $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
2022 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2023 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
2024 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
2025 | - $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
2026 | - $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
2027 | - $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
2028 | - $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
2029 | - $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
2030 | - |
|
2031 | - $default_order = ''; |
|
2032 | - if ($is_default != '') { |
|
2033 | - $default_order = $is_default; |
|
2034 | - $is_default = '1'; |
|
2035 | - } |
|
2036 | - |
|
2037 | - |
|
2038 | - $check_html_variable = $wpdb->get_var( |
|
2039 | - $wpdb->prepare( |
|
2040 | - "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
2041 | - array($cehhtmlvar_name, $post_type, $field_type) |
|
2042 | - ) |
|
2043 | - ); |
|
2044 | - |
|
2045 | - if ($is_default == 1) { |
|
2046 | - |
|
2047 | - $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type))); |
|
2048 | - |
|
2049 | - } |
|
2050 | - |
|
2051 | - |
|
2052 | - if (!$check_html_variable) { |
|
2053 | - |
|
2054 | - $wpdb->query( |
|
2055 | - |
|
2056 | - $wpdb->prepare( |
|
2057 | - |
|
2058 | - "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1975 | + /** |
|
1976 | + * Save or Update custom sort fields into the database. |
|
1977 | + * |
|
1978 | + * @since 1.0.0 |
|
1979 | + * @package GeoDirectory |
|
1980 | + * @global object $wpdb WordPress Database object. |
|
1981 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1982 | + * @param array $request_field { |
|
1983 | + * Attributes of the Request field. |
|
1984 | + * |
|
1985 | + * @type string $action Ajax action name. |
|
1986 | + * @type string $manage_field_type Manage field type Default "sorting_options". |
|
1987 | + * @type string $create_field Do you want to create this field?. |
|
1988 | + * @type string $field_ins_upd Field created or updated?. |
|
1989 | + * @type string $_wpnonce Nonce value. |
|
1990 | + * @type string $listing_type The Post type. |
|
1991 | + * @type string $field_type Field Type. |
|
1992 | + * @type string $field_id Field ID. |
|
1993 | + * @type string $data_type Data Type. |
|
1994 | + * @type string $htmlvar_name HTML variable name. |
|
1995 | + * @type string $site_title Section title which you wish to display in frontend. |
|
1996 | + * @type string $is_default Is this default sorting?. |
|
1997 | + * @type string $is_active If not active then the field will not be displayed anywhere. |
|
1998 | + * @type string $sort_order Sort Order. |
|
1999 | + * |
|
2000 | + * } |
|
2001 | + * @param bool $default Not yet implemented. |
|
2002 | + * @return int Returns the last affected db table row id. |
|
2003 | + */ |
|
2004 | + function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
2005 | + { |
|
2006 | + |
|
2007 | + global $wpdb, $plugin_prefix; |
|
2008 | + |
|
2009 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
2010 | + |
|
2011 | + $cf = trim($result_str, '_'); |
|
2012 | + |
|
2013 | + /*-------- check dublicate validation --------*/ |
|
2014 | + |
|
2015 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2016 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2017 | + |
|
2018 | + $post_type = $request_field['listing_type']; |
|
2019 | + $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
2020 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2021 | + $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
2022 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2023 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
2024 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
2025 | + $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
2026 | + $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
2027 | + $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
2028 | + $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
2029 | + $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
2030 | + |
|
2031 | + $default_order = ''; |
|
2032 | + if ($is_default != '') { |
|
2033 | + $default_order = $is_default; |
|
2034 | + $is_default = '1'; |
|
2035 | + } |
|
2036 | + |
|
2037 | + |
|
2038 | + $check_html_variable = $wpdb->get_var( |
|
2039 | + $wpdb->prepare( |
|
2040 | + "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
2041 | + array($cehhtmlvar_name, $post_type, $field_type) |
|
2042 | + ) |
|
2043 | + ); |
|
2044 | + |
|
2045 | + if ($is_default == 1) { |
|
2046 | + |
|
2047 | + $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type))); |
|
2048 | + |
|
2049 | + } |
|
2050 | + |
|
2051 | + |
|
2052 | + if (!$check_html_variable) { |
|
2053 | + |
|
2054 | + $wpdb->query( |
|
2055 | + |
|
2056 | + $wpdb->prepare( |
|
2057 | + |
|
2058 | + "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2059 | 2059 | post_type = %s, |
2060 | 2060 | data_type = %s, |
2061 | 2061 | field_type = %s, |
@@ -2070,23 +2070,23 @@ discard block |
||
2070 | 2070 | asc_title = %s, |
2071 | 2071 | desc_title = %s", |
2072 | 2072 | |
2073 | - 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) |
|
2074 | - ) |
|
2073 | + 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) |
|
2074 | + ) |
|
2075 | 2075 | |
2076 | - ); |
|
2076 | + ); |
|
2077 | 2077 | |
2078 | 2078 | |
2079 | - $lastid = $wpdb->insert_id; |
|
2079 | + $lastid = $wpdb->insert_id; |
|
2080 | 2080 | |
2081 | - $lastid = trim($lastid); |
|
2081 | + $lastid = trim($lastid); |
|
2082 | 2082 | |
2083 | - } else { |
|
2083 | + } else { |
|
2084 | 2084 | |
2085 | - $wpdb->query( |
|
2085 | + $wpdb->query( |
|
2086 | 2086 | |
2087 | - $wpdb->prepare( |
|
2087 | + $wpdb->prepare( |
|
2088 | 2088 | |
2089 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2089 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2090 | 2090 | post_type = %s, |
2091 | 2091 | data_type = %s, |
2092 | 2092 | field_type = %s, |
@@ -2102,123 +2102,123 @@ discard block |
||
2102 | 2102 | desc_title = %s |
2103 | 2103 | where id = %d", |
2104 | 2104 | |
2105 | - 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) |
|
2106 | - ) |
|
2105 | + 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) |
|
2106 | + ) |
|
2107 | 2107 | |
2108 | - ); |
|
2108 | + ); |
|
2109 | 2109 | |
2110 | - $lastid = trim($cf); |
|
2110 | + $lastid = trim($cf); |
|
2111 | 2111 | |
2112 | - } |
|
2112 | + } |
|
2113 | 2113 | |
2114 | 2114 | |
2115 | - return (int)$lastid; |
|
2115 | + return (int)$lastid; |
|
2116 | 2116 | |
2117 | - } |
|
2117 | + } |
|
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | |
2121 | 2121 | if (!function_exists('geodir_custom_sort_field_delete')) { |
2122 | - /** |
|
2123 | - * Delete a custom sort field using field id. |
|
2124 | - * @since 1.0.0 |
|
2125 | - * @package GeoDirectory |
|
2126 | - * @global object $wpdb WordPress Database object. |
|
2127 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2128 | - * @param string $field_id The field ID. |
|
2129 | - * @return int|string Returns field id when successful deletion, else returns 0. |
|
2130 | - */ |
|
2131 | - function geodir_custom_sort_field_delete($field_id = '') |
|
2132 | - { |
|
2133 | - |
|
2134 | - global $wpdb, $plugin_prefix; |
|
2135 | - if ($field_id != '') { |
|
2136 | - $cf = trim($field_id, '_'); |
|
2137 | - |
|
2138 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
2139 | - |
|
2140 | - return $field_id; |
|
2141 | - |
|
2142 | - } else |
|
2143 | - return 0; |
|
2144 | - |
|
2145 | - } |
|
2122 | + /** |
|
2123 | + * Delete a custom sort field using field id. |
|
2124 | + * @since 1.0.0 |
|
2125 | + * @package GeoDirectory |
|
2126 | + * @global object $wpdb WordPress Database object. |
|
2127 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2128 | + * @param string $field_id The field ID. |
|
2129 | + * @return int|string Returns field id when successful deletion, else returns 0. |
|
2130 | + */ |
|
2131 | + function geodir_custom_sort_field_delete($field_id = '') |
|
2132 | + { |
|
2133 | + |
|
2134 | + global $wpdb, $plugin_prefix; |
|
2135 | + if ($field_id != '') { |
|
2136 | + $cf = trim($field_id, '_'); |
|
2137 | + |
|
2138 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
2139 | + |
|
2140 | + return $field_id; |
|
2141 | + |
|
2142 | + } else |
|
2143 | + return 0; |
|
2144 | + |
|
2145 | + } |
|
2146 | 2146 | } |
2147 | 2147 | |
2148 | 2148 | |
2149 | 2149 | if (!function_exists('geodir_custom_sort_field_adminhtml')) { |
2150 | - /** |
|
2151 | - * Custom sort field admin html. |
|
2152 | - * |
|
2153 | - * @since 1.0.0 |
|
2154 | - * @package GeoDirectory |
|
2155 | - * @global object $wpdb WordPress Database object. |
|
2156 | - * @param string $field_type The form field type. |
|
2157 | - * @param object|int $result_str The custom field results object or row id. |
|
2158 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
2159 | - * @param bool $default when set to true field will be for admin use only. |
|
2160 | - */ |
|
2161 | - function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
2162 | - { |
|
2163 | - global $wpdb; |
|
2164 | - $cf = $result_str; |
|
2165 | - if (!is_object($cf)) { |
|
2166 | - $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf))); |
|
2167 | - } else { |
|
2168 | - $field_info = $cf; |
|
2169 | - $result_str = $cf->id; |
|
2170 | - } |
|
2171 | - |
|
2172 | - $field_info = stripslashes_deep($field_info); // strip slashes |
|
2173 | - |
|
2174 | - if (!isset($field_info->post_type)) { |
|
2175 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2176 | - } else { |
|
2177 | - $post_type = $field_info->post_type; |
|
2178 | - } |
|
2179 | - |
|
2180 | - |
|
2181 | - $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
2182 | - |
|
2183 | - $site_title = ''; |
|
2184 | - if ($site_title == '') |
|
2185 | - $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
2186 | - |
|
2187 | - if ($site_title == '') { |
|
2188 | - $fields = geodir_get_custom_sort_options($post_type); |
|
2189 | - |
|
2190 | - foreach ($fields as $val) { |
|
2191 | - $val = stripslashes_deep($val); // strip slashes |
|
2192 | - |
|
2193 | - if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { |
|
2194 | - $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
2195 | - } |
|
2196 | - } |
|
2197 | - } |
|
2198 | - |
|
2199 | - if ($htmlvar_name == '') |
|
2200 | - $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
2201 | - |
|
2202 | - $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
2203 | - |
|
2204 | - $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
2205 | - $cso_arr = geodir_get_custom_sort_options($post_type); |
|
2206 | - |
|
2207 | - $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
2208 | - foreach($cso_arr as $cso){ |
|
2209 | - if($cur_field_type==$cso['field_type']){ |
|
2210 | - |
|
2211 | - if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) { |
|
2212 | - $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
2213 | - }elseif(isset($cso['field_icon']) && $cso['field_icon']){ |
|
2214 | - $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>'; |
|
2215 | - } |
|
2216 | - |
|
2217 | - } |
|
2218 | - } |
|
2219 | - |
|
2220 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
2221 | - ?> |
|
2150 | + /** |
|
2151 | + * Custom sort field admin html. |
|
2152 | + * |
|
2153 | + * @since 1.0.0 |
|
2154 | + * @package GeoDirectory |
|
2155 | + * @global object $wpdb WordPress Database object. |
|
2156 | + * @param string $field_type The form field type. |
|
2157 | + * @param object|int $result_str The custom field results object or row id. |
|
2158 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
2159 | + * @param bool $default when set to true field will be for admin use only. |
|
2160 | + */ |
|
2161 | + function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
2162 | + { |
|
2163 | + global $wpdb; |
|
2164 | + $cf = $result_str; |
|
2165 | + if (!is_object($cf)) { |
|
2166 | + $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf))); |
|
2167 | + } else { |
|
2168 | + $field_info = $cf; |
|
2169 | + $result_str = $cf->id; |
|
2170 | + } |
|
2171 | + |
|
2172 | + $field_info = stripslashes_deep($field_info); // strip slashes |
|
2173 | + |
|
2174 | + if (!isset($field_info->post_type)) { |
|
2175 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2176 | + } else { |
|
2177 | + $post_type = $field_info->post_type; |
|
2178 | + } |
|
2179 | + |
|
2180 | + |
|
2181 | + $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
2182 | + |
|
2183 | + $site_title = ''; |
|
2184 | + if ($site_title == '') |
|
2185 | + $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
2186 | + |
|
2187 | + if ($site_title == '') { |
|
2188 | + $fields = geodir_get_custom_sort_options($post_type); |
|
2189 | + |
|
2190 | + foreach ($fields as $val) { |
|
2191 | + $val = stripslashes_deep($val); // strip slashes |
|
2192 | + |
|
2193 | + if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { |
|
2194 | + $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
2195 | + } |
|
2196 | + } |
|
2197 | + } |
|
2198 | + |
|
2199 | + if ($htmlvar_name == '') |
|
2200 | + $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
2201 | + |
|
2202 | + $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
2203 | + |
|
2204 | + $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
2205 | + $cso_arr = geodir_get_custom_sort_options($post_type); |
|
2206 | + |
|
2207 | + $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
2208 | + foreach($cso_arr as $cso){ |
|
2209 | + if($cur_field_type==$cso['field_type']){ |
|
2210 | + |
|
2211 | + if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) { |
|
2212 | + $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
2213 | + }elseif(isset($cso['field_icon']) && $cso['field_icon']){ |
|
2214 | + $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>'; |
|
2215 | + } |
|
2216 | + |
|
2217 | + } |
|
2218 | + } |
|
2219 | + |
|
2220 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
2221 | + ?> |
|
2222 | 2222 | |
2223 | 2223 | <li class="text" id="licontainer_<?php echo $result_str;?>"> |
2224 | 2224 | <form><!-- we need to wrap in a fom so we can use radio buttons with same name --> |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | ondblclick="show_hide('field_frm<?php echo $result_str;?>')"> |
2228 | 2228 | <?php |
2229 | 2229 | |
2230 | - ?> |
|
2230 | + ?> |
|
2231 | 2231 | |
2232 | 2232 | <div title="<?php _e('Click to remove field', 'geodirectory');?>" |
2233 | 2233 | onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)" |
@@ -2242,17 +2242,17 @@ discard block |
||
2242 | 2242 | |
2243 | 2243 | <div id="field_frm<?php echo $result_str;?>" class="field_frm" |
2244 | 2244 | style="display:<?php if ($field_ins_upd == 'submit') { |
2245 | - echo 'block;'; |
|
2246 | - } else { |
|
2247 | - echo 'none;'; |
|
2248 | - } ?>"> |
|
2245 | + echo 'block;'; |
|
2246 | + } else { |
|
2247 | + echo 'none;'; |
|
2248 | + } ?>"> |
|
2249 | 2249 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
2250 | 2250 | <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> |
2251 | 2251 | <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> |
2252 | 2252 | <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/> |
2253 | 2253 | <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) { |
2254 | - echo $field_info->data_type; |
|
2255 | - }?>"/> |
|
2254 | + echo $field_info->data_type; |
|
2255 | + }?>"/> |
|
2256 | 2256 | <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/> |
2257 | 2257 | |
2258 | 2258 | |
@@ -2275,14 +2275,14 @@ discard block |
||
2275 | 2275 | |
2276 | 2276 | <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled" value="1" |
2277 | 2277 | <?php if ($value == '1') { |
2278 | - echo 'checked'; |
|
2279 | - } ?>/> |
|
2278 | + echo 'checked'; |
|
2279 | + } ?>/> |
|
2280 | 2280 | <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> |
2281 | 2281 | |
2282 | 2282 | <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0" |
2283 | 2283 | <?php if ($value == '0' || !$value) { |
2284 | - echo 'checked'; |
|
2285 | - } ?>/> |
|
2284 | + echo 'checked'; |
|
2285 | + } ?>/> |
|
2286 | 2286 | <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> |
2287 | 2287 | |
2288 | 2288 | </div> |
@@ -2319,8 +2319,8 @@ discard block |
||
2319 | 2319 | |
2320 | 2320 | <input type="radio" name="is_default" |
2321 | 2321 | value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') { |
2322 | - echo 'checked="checked"'; |
|
2323 | - } ?>/> |
|
2322 | + echo 'checked="checked"'; |
|
2323 | + } ?>/> |
|
2324 | 2324 | </div> |
2325 | 2325 | |
2326 | 2326 | </li> |
@@ -2340,14 +2340,14 @@ discard block |
||
2340 | 2340 | |
2341 | 2341 | <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled" value="1" |
2342 | 2342 | <?php if ($value == '1') { |
2343 | - echo 'checked'; |
|
2344 | - } ?>/> |
|
2343 | + echo 'checked'; |
|
2344 | + } ?>/> |
|
2345 | 2345 | <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> |
2346 | 2346 | |
2347 | 2347 | <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0" |
2348 | 2348 | <?php if ($value == '0' || !$value) { |
2349 | - echo 'checked'; |
|
2350 | - } ?>/> |
|
2349 | + echo 'checked'; |
|
2350 | + } ?>/> |
|
2351 | 2351 | <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> |
2352 | 2352 | |
2353 | 2353 | </div> |
@@ -2383,8 +2383,8 @@ discard block |
||
2383 | 2383 | |
2384 | 2384 | <input type="radio" name="is_default" |
2385 | 2385 | value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') { |
2386 | - echo 'checked="checked"'; |
|
2387 | - } ?>/> |
|
2386 | + echo 'checked="checked"'; |
|
2387 | + } ?>/> |
|
2388 | 2388 | </div> |
2389 | 2389 | |
2390 | 2390 | </li> |
@@ -2426,8 +2426,8 @@ discard block |
||
2426 | 2426 | |
2427 | 2427 | <input type="checkbox" name="is_default" |
2428 | 2428 | value="<?php echo $field_type; ?>" <?php if (isset($value) && $value == '1') { |
2429 | - echo 'checked="checked"'; |
|
2430 | - } ?>/> |
|
2429 | + echo 'checked="checked"'; |
|
2430 | + } ?>/> |
|
2431 | 2431 | </div> |
2432 | 2432 | |
2433 | 2433 | |
@@ -2450,14 +2450,14 @@ discard block |
||
2450 | 2450 | |
2451 | 2451 | <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled" value="1" |
2452 | 2452 | <?php if ($value == '1') { |
2453 | - echo 'checked'; |
|
2454 | - } ?>/> |
|
2453 | + echo 'checked'; |
|
2454 | + } ?>/> |
|
2455 | 2455 | <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2456 | 2456 | |
2457 | 2457 | <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0" |
2458 | 2458 | <?php if ($value == '0' || !$value) { |
2459 | - echo 'checked'; |
|
2460 | - } ?>/> |
|
2459 | + echo 'checked'; |
|
2460 | + } ?>/> |
|
2461 | 2461 | <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2462 | 2462 | |
2463 | 2463 | </div> |
@@ -2467,8 +2467,8 @@ discard block |
||
2467 | 2467 | |
2468 | 2468 | <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" |
2469 | 2469 | value="<?php if (isset($field_info->sort_order)) { |
2470 | - echo esc_attr($field_info->sort_order); |
|
2471 | - }?>" size="50"/> |
|
2470 | + echo esc_attr($field_info->sort_order); |
|
2471 | + }?>" size="50"/> |
|
2472 | 2472 | |
2473 | 2473 | |
2474 | 2474 | |
@@ -2492,38 +2492,38 @@ discard block |
||
2492 | 2492 | </form> |
2493 | 2493 | </li> <?php |
2494 | 2494 | |
2495 | - } |
|
2495 | + } |
|
2496 | 2496 | } |
2497 | 2497 | |
2498 | 2498 | if (!function_exists('check_field_visibility')) { |
2499 | - /** |
|
2500 | - * Check field visibility as per price package. |
|
2501 | - * |
|
2502 | - * @since 1.0.0 |
|
2503 | - * @package GeoDirectory |
|
2504 | - * @global object $wpdb WordPress Database object. |
|
2505 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
2506 | - * @param int|string $package_id The package ID. |
|
2507 | - * @param string $field_name The field name. |
|
2508 | - * @param string $post_type Optional. The wordpress post type. |
|
2509 | - * @return bool Returns true when field visible, otherwise false. |
|
2510 | - */ |
|
2511 | - function check_field_visibility($package_id, $field_name, $post_type) |
|
2512 | - { |
|
2513 | - global $wpdb, $geodir_addon_list; |
|
2514 | - if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) { |
|
2515 | - return true; |
|
2516 | - } |
|
2517 | - if (!$package_id || !$field_name || !$post_type) { |
|
2518 | - return true; |
|
2519 | - } |
|
2520 | - $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)); |
|
2521 | - |
|
2522 | - if ($wpdb->get_var($sql)) { |
|
2523 | - return true; |
|
2524 | - } |
|
2525 | - return false; |
|
2526 | - } |
|
2499 | + /** |
|
2500 | + * Check field visibility as per price package. |
|
2501 | + * |
|
2502 | + * @since 1.0.0 |
|
2503 | + * @package GeoDirectory |
|
2504 | + * @global object $wpdb WordPress Database object. |
|
2505 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
2506 | + * @param int|string $package_id The package ID. |
|
2507 | + * @param string $field_name The field name. |
|
2508 | + * @param string $post_type Optional. The wordpress post type. |
|
2509 | + * @return bool Returns true when field visible, otherwise false. |
|
2510 | + */ |
|
2511 | + function check_field_visibility($package_id, $field_name, $post_type) |
|
2512 | + { |
|
2513 | + global $wpdb, $geodir_addon_list; |
|
2514 | + if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) { |
|
2515 | + return true; |
|
2516 | + } |
|
2517 | + if (!$package_id || !$field_name || !$post_type) { |
|
2518 | + return true; |
|
2519 | + } |
|
2520 | + $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)); |
|
2521 | + |
|
2522 | + if ($wpdb->get_var($sql)) { |
|
2523 | + return true; |
|
2524 | + } |
|
2525 | + return false; |
|
2526 | + } |
|
2527 | 2527 | } |
2528 | 2528 | |
2529 | 2529 | /** |
@@ -2538,43 +2538,43 @@ discard block |
||
2538 | 2538 | */ |
2539 | 2539 | function geodir_string_to_options($input = '', $translated = false) |
2540 | 2540 | { |
2541 | - $return = array(); |
|
2542 | - if ($input != '') { |
|
2543 | - $input = trim($input); |
|
2544 | - $input = rtrim($input, ","); |
|
2545 | - $input = ltrim($input, ","); |
|
2546 | - $input = trim($input); |
|
2547 | - } |
|
2548 | - |
|
2549 | - $input_arr = explode(',', $input); |
|
2550 | - |
|
2551 | - if (!empty($input_arr)) { |
|
2552 | - foreach ($input_arr as $input_str) { |
|
2553 | - $input_str = trim($input_str); |
|
2554 | - |
|
2555 | - if (strpos($input_str, "/") !== false) { |
|
2556 | - $input_str = explode("/", $input_str, 2); |
|
2557 | - $label = trim($input_str[0]); |
|
2558 | - if ($translated && $label != '') { |
|
2559 | - $label = __($label, 'geodirectory'); |
|
2560 | - } |
|
2561 | - $label = ucfirst($label); |
|
2562 | - $value = trim($input_str[1]); |
|
2563 | - } else { |
|
2564 | - if ($translated && $input_str != '') { |
|
2565 | - $input_str = __($input_str, 'geodirectory'); |
|
2566 | - } |
|
2567 | - $label = ucfirst($input_str); |
|
2568 | - $value = $input_str; |
|
2569 | - } |
|
2570 | - |
|
2571 | - if ($label != '') { |
|
2572 | - $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL); |
|
2573 | - } |
|
2574 | - } |
|
2575 | - } |
|
2576 | - |
|
2577 | - return $return; |
|
2541 | + $return = array(); |
|
2542 | + if ($input != '') { |
|
2543 | + $input = trim($input); |
|
2544 | + $input = rtrim($input, ","); |
|
2545 | + $input = ltrim($input, ","); |
|
2546 | + $input = trim($input); |
|
2547 | + } |
|
2548 | + |
|
2549 | + $input_arr = explode(',', $input); |
|
2550 | + |
|
2551 | + if (!empty($input_arr)) { |
|
2552 | + foreach ($input_arr as $input_str) { |
|
2553 | + $input_str = trim($input_str); |
|
2554 | + |
|
2555 | + if (strpos($input_str, "/") !== false) { |
|
2556 | + $input_str = explode("/", $input_str, 2); |
|
2557 | + $label = trim($input_str[0]); |
|
2558 | + if ($translated && $label != '') { |
|
2559 | + $label = __($label, 'geodirectory'); |
|
2560 | + } |
|
2561 | + $label = ucfirst($label); |
|
2562 | + $value = trim($input_str[1]); |
|
2563 | + } else { |
|
2564 | + if ($translated && $input_str != '') { |
|
2565 | + $input_str = __($input_str, 'geodirectory'); |
|
2566 | + } |
|
2567 | + $label = ucfirst($input_str); |
|
2568 | + $value = $input_str; |
|
2569 | + } |
|
2570 | + |
|
2571 | + if ($label != '') { |
|
2572 | + $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL); |
|
2573 | + } |
|
2574 | + } |
|
2575 | + } |
|
2576 | + |
|
2577 | + return $return; |
|
2578 | 2578 | } |
2579 | 2579 | |
2580 | 2580 | /** |
@@ -2589,59 +2589,59 @@ discard block |
||
2589 | 2589 | */ |
2590 | 2590 | function geodir_string_values_to_options($option_values = '', $translated = false) |
2591 | 2591 | { |
2592 | - $options = array(); |
|
2593 | - if ($option_values == '') { |
|
2594 | - return NULL; |
|
2595 | - } |
|
2596 | - |
|
2597 | - if (strpos($option_values, "{/optgroup}") !== false) { |
|
2598 | - $option_values_arr = explode("{/optgroup}", $option_values); |
|
2599 | - |
|
2600 | - foreach ($option_values_arr as $optgroup) { |
|
2601 | - if (strpos($optgroup, "{optgroup}") !== false) { |
|
2602 | - $optgroup_arr = explode("{optgroup}", $optgroup); |
|
2603 | - |
|
2604 | - $count = 0; |
|
2605 | - foreach ($optgroup_arr as $optgroup_str) { |
|
2606 | - $count++; |
|
2607 | - $optgroup_str = trim($optgroup_str); |
|
2608 | - |
|
2609 | - $optgroup_label = ''; |
|
2610 | - if (strpos($optgroup_str, "|") !== false) { |
|
2611 | - $optgroup_str_arr = explode("|", $optgroup_str, 2); |
|
2612 | - $optgroup_label = trim($optgroup_str_arr[0]); |
|
2613 | - if ($translated && $optgroup_label != '') { |
|
2614 | - $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
2615 | - } |
|
2616 | - $optgroup_label = ucfirst($optgroup_label); |
|
2617 | - $optgroup_str = $optgroup_str_arr[1]; |
|
2618 | - } |
|
2619 | - |
|
2620 | - $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
2621 | - |
|
2622 | - if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) { |
|
2623 | - $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start')); |
|
2624 | - $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end')); |
|
2625 | - $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
2626 | - } |
|
2627 | - $options = array_merge($options, $optgroup3); |
|
2628 | - } |
|
2629 | - } else { |
|
2630 | - $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
2631 | - $options = array_merge($options, $optgroup1); |
|
2632 | - } |
|
2633 | - } |
|
2634 | - } else { |
|
2635 | - $options = geodir_string_to_options($option_values, $translated); |
|
2636 | - } |
|
2637 | - |
|
2638 | - return $options; |
|
2592 | + $options = array(); |
|
2593 | + if ($option_values == '') { |
|
2594 | + return NULL; |
|
2595 | + } |
|
2596 | + |
|
2597 | + if (strpos($option_values, "{/optgroup}") !== false) { |
|
2598 | + $option_values_arr = explode("{/optgroup}", $option_values); |
|
2599 | + |
|
2600 | + foreach ($option_values_arr as $optgroup) { |
|
2601 | + if (strpos($optgroup, "{optgroup}") !== false) { |
|
2602 | + $optgroup_arr = explode("{optgroup}", $optgroup); |
|
2603 | + |
|
2604 | + $count = 0; |
|
2605 | + foreach ($optgroup_arr as $optgroup_str) { |
|
2606 | + $count++; |
|
2607 | + $optgroup_str = trim($optgroup_str); |
|
2608 | + |
|
2609 | + $optgroup_label = ''; |
|
2610 | + if (strpos($optgroup_str, "|") !== false) { |
|
2611 | + $optgroup_str_arr = explode("|", $optgroup_str, 2); |
|
2612 | + $optgroup_label = trim($optgroup_str_arr[0]); |
|
2613 | + if ($translated && $optgroup_label != '') { |
|
2614 | + $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
2615 | + } |
|
2616 | + $optgroup_label = ucfirst($optgroup_label); |
|
2617 | + $optgroup_str = $optgroup_str_arr[1]; |
|
2618 | + } |
|
2619 | + |
|
2620 | + $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
2621 | + |
|
2622 | + if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) { |
|
2623 | + $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start')); |
|
2624 | + $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end')); |
|
2625 | + $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
2626 | + } |
|
2627 | + $options = array_merge($options, $optgroup3); |
|
2628 | + } |
|
2629 | + } else { |
|
2630 | + $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
2631 | + $options = array_merge($options, $optgroup1); |
|
2632 | + } |
|
2633 | + } |
|
2634 | + } else { |
|
2635 | + $options = geodir_string_to_options($option_values, $translated); |
|
2636 | + } |
|
2637 | + |
|
2638 | + return $options; |
|
2639 | 2639 | } |
2640 | 2640 | |
2641 | 2641 | |
2642 | 2642 | function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){ |
2643 | - ob_start(); |
|
2644 | - ?> |
|
2643 | + ob_start(); |
|
2644 | + ?> |
|
2645 | 2645 | <li> |
2646 | 2646 | <label for="data_type""><?php _e('Field Data Type ? :', 'geodirectory'); ?></label> |
2647 | 2647 | <div class="gd-cf-input-wrap"> |
@@ -2650,16 +2650,16 @@ discard block |
||
2650 | 2650 | onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');"> |
2651 | 2651 | <option |
2652 | 2652 | value="XVARCHAR" <?php if (isset($field_info->data_type) && $field_info->data_type == 'VARCHAR') { |
2653 | - echo 'selected="selected"'; |
|
2654 | - } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option> |
|
2653 | + echo 'selected="selected"'; |
|
2654 | + } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option> |
|
2655 | 2655 | <option |
2656 | 2656 | value="INT" <?php if (isset($field_info->data_type) && $field_info->data_type == 'INT') { |
2657 | - echo 'selected="selected"'; |
|
2658 | - } ?>><?php _e('NUMBER', 'geodirectory'); ?></option> |
|
2657 | + echo 'selected="selected"'; |
|
2658 | + } ?>><?php _e('NUMBER', 'geodirectory'); ?></option> |
|
2659 | 2659 | <option |
2660 | 2660 | value="FLOAT" <?php if (isset($field_info->data_type) && $field_info->data_type == 'FLOAT') { |
2661 | - echo 'selected="selected"'; |
|
2662 | - } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option> |
|
2661 | + echo 'selected="selected"'; |
|
2662 | + } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option> |
|
2663 | 2663 | </select> |
2664 | 2664 | <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span> |
2665 | 2665 | |
@@ -2672,8 +2672,8 @@ discard block |
||
2672 | 2672 | <select name="decimal_point" id="decimal_point"> |
2673 | 2673 | <option value=""><?php echo _e('Select', 'geodirectory'); ?></option> |
2674 | 2674 | <?php for ($i = 1; $i <= 10; $i++) { |
2675 | - $decimal_point = isset($field_info->decimal_point) ? $field_info->decimal_point : ''; |
|
2676 | - $selected = $i == $decimal_point ? 'selected="selected"' : ''; ?> |
|
2675 | + $decimal_point = isset($field_info->decimal_point) ? $field_info->decimal_point : ''; |
|
2676 | + $selected = $i == $decimal_point ? 'selected="selected"' : ''; ?> |
|
2677 | 2677 | <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option> |
2678 | 2678 | <?php } ?> |
2679 | 2679 | </select> |
@@ -2682,8 +2682,8 @@ discard block |
||
2682 | 2682 | </li> |
2683 | 2683 | <?php |
2684 | 2684 | |
2685 | - $output = ob_get_clean(); |
|
2686 | - return $output; |
|
2685 | + $output = ob_get_clean(); |
|
2686 | + return $output; |
|
2687 | 2687 | } |
2688 | 2688 | add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4); |
2689 | 2689 | |
@@ -2721,9 +2721,9 @@ discard block |
||
2721 | 2721 | |
2722 | 2722 | |
2723 | 2723 | function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){ |
2724 | - if($field_info->htmlvar_name != 'geodir_special_offers'){return '';} |
|
2725 | - ob_start(); |
|
2726 | - ?> |
|
2724 | + if($field_info->htmlvar_name != 'geodir_special_offers'){return '';} |
|
2725 | + ob_start(); |
|
2726 | + ?> |
|
2727 | 2727 | <li> |
2728 | 2728 | <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'); ?> |
2729 | 2729 | <div class="gdcf-tooltip"> |
@@ -2734,13 +2734,13 @@ discard block |
||
2734 | 2734 | <div class="gd-cf-input-wrap"> |
2735 | 2735 | |
2736 | 2736 | <?php |
2737 | - $selected = ''; |
|
2738 | - if (isset($field_info->extra_fields)) |
|
2739 | - $advanced_editor = unserialize($field_info->extra_fields); |
|
2737 | + $selected = ''; |
|
2738 | + if (isset($field_info->extra_fields)) |
|
2739 | + $advanced_editor = unserialize($field_info->extra_fields); |
|
2740 | 2740 | |
2741 | - if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) |
|
2742 | - $selected = 'checked="checked"'; |
|
2743 | - ?> |
|
2741 | + if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) |
|
2742 | + $selected = 'checked="checked"'; |
|
2743 | + ?> |
|
2744 | 2744 | |
2745 | 2745 | <input type="checkbox" name="advanced_editor[]" id="advanced_editor" |
2746 | 2746 | value="1" <?php echo $selected; ?>/> |
@@ -2749,22 +2749,22 @@ discard block |
||
2749 | 2749 | </li> |
2750 | 2750 | <?php |
2751 | 2751 | |
2752 | - $output = ob_get_clean(); |
|
2753 | - return $output; |
|
2752 | + $output = ob_get_clean(); |
|
2753 | + return $output; |
|
2754 | 2754 | } |
2755 | 2755 | add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4); |
2756 | 2756 | |
2757 | 2757 | |
2758 | 2758 | function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){ |
2759 | - ob_start(); |
|
2760 | - |
|
2761 | - $value = ''; |
|
2762 | - if (isset($field_info->validation_pattern)) { |
|
2763 | - $value = esc_attr($field_info->validation_pattern); |
|
2764 | - }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){ |
|
2765 | - $value = esc_attr($cf['defaults']['validation_pattern']); |
|
2766 | - } |
|
2767 | - ?> |
|
2759 | + ob_start(); |
|
2760 | + |
|
2761 | + $value = ''; |
|
2762 | + if (isset($field_info->validation_pattern)) { |
|
2763 | + $value = esc_attr($field_info->validation_pattern); |
|
2764 | + }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){ |
|
2765 | + $value = esc_attr($cf['defaults']['validation_pattern']); |
|
2766 | + } |
|
2767 | + ?> |
|
2768 | 2768 | <li> |
2769 | 2769 | <label for="validation_pattern" class="gd-cf-tooltip-wrap"> |
2770 | 2770 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?> |
@@ -2778,13 +2778,13 @@ discard block |
||
2778 | 2778 | </div> |
2779 | 2779 | </li> |
2780 | 2780 | <?php |
2781 | - $value = ''; |
|
2782 | - if (isset($field_info->validation_msg)) { |
|
2783 | - $value = esc_attr($field_info->validation_msg); |
|
2784 | - }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){ |
|
2785 | - $value = esc_attr($cf['defaults']['validation_msg']); |
|
2786 | - } |
|
2787 | - ?> |
|
2781 | + $value = ''; |
|
2782 | + if (isset($field_info->validation_msg)) { |
|
2783 | + $value = esc_attr($field_info->validation_msg); |
|
2784 | + }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){ |
|
2785 | + $value = esc_attr($cf['defaults']['validation_msg']); |
|
2786 | + } |
|
2787 | + ?> |
|
2788 | 2788 | <li> |
2789 | 2789 | <label for="validation_msg" class="gd-cf-tooltip-wrap"> |
2790 | 2790 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?> |
@@ -2799,21 +2799,21 @@ discard block |
||
2799 | 2799 | </li> |
2800 | 2800 | <?php |
2801 | 2801 | |
2802 | - $output = ob_get_clean(); |
|
2803 | - return $output; |
|
2802 | + $output = ob_get_clean(); |
|
2803 | + return $output; |
|
2804 | 2804 | } |
2805 | 2805 | add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4); |
2806 | 2806 | |
2807 | 2807 | |
2808 | 2808 | function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){ |
2809 | - ob_start(); |
|
2810 | - global $post_type; |
|
2811 | - |
|
2812 | - if (!isset($field_info->post_type)) { |
|
2813 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2814 | - } else |
|
2815 | - $post_type = $field_info->post_type; |
|
2816 | - ?> |
|
2809 | + ob_start(); |
|
2810 | + global $post_type; |
|
2811 | + |
|
2812 | + if (!isset($field_info->post_type)) { |
|
2813 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2814 | + } else |
|
2815 | + $post_type = $field_info->post_type; |
|
2816 | + ?> |
|
2817 | 2817 | <li style="display: none;"> |
2818 | 2818 | <label for="htmlvar_name" class="gd-cf-tooltip-wrap"> |
2819 | 2819 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?> |
@@ -2824,15 +2824,15 @@ discard block |
||
2824 | 2824 | <div class="gd-cf-input-wrap"> |
2825 | 2825 | <select name="htmlvar_name" id="htmlvar_name"> |
2826 | 2826 | <?php |
2827 | - $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
2827 | + $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
2828 | 2828 | |
2829 | - foreach ($gd_taxonomy as $gd_tax) { |
|
2830 | - ?> |
|
2829 | + foreach ($gd_taxonomy as $gd_tax) { |
|
2830 | + ?> |
|
2831 | 2831 | <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) { |
2832 | - echo 'selected="selected"'; |
|
2833 | - }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
2834 | - } |
|
2835 | - ?> |
|
2832 | + echo 'selected="selected"'; |
|
2833 | + }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
2834 | + } |
|
2835 | + ?> |
|
2836 | 2836 | </select> |
2837 | 2837 | </div> |
2838 | 2838 | </li> |
@@ -2848,49 +2848,49 @@ discard block |
||
2848 | 2848 | |
2849 | 2849 | <select name="cat_display_type" id="cat_display_type"> |
2850 | 2850 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') { |
2851 | - echo 'selected="selected"'; |
|
2852 | - }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option> |
|
2851 | + echo 'selected="selected"'; |
|
2852 | + }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option> |
|
2853 | 2853 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') { |
2854 | - echo 'selected="selected"'; |
|
2855 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
2854 | + echo 'selected="selected"'; |
|
2855 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
2856 | 2856 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') { |
2857 | - echo 'selected="selected"'; |
|
2858 | - }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option> |
|
2857 | + echo 'selected="selected"'; |
|
2858 | + }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option> |
|
2859 | 2859 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') { |
2860 | - echo 'selected="selected"'; |
|
2861 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
2860 | + echo 'selected="selected"'; |
|
2861 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
2862 | 2862 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') { |
2863 | - echo 'selected="selected"'; |
|
2864 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
2863 | + echo 'selected="selected"'; |
|
2864 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
2865 | 2865 | </select> |
2866 | 2866 | </div> |
2867 | 2867 | </li> |
2868 | 2868 | <?php |
2869 | 2869 | |
2870 | - $output = ob_get_clean(); |
|
2871 | - return $output; |
|
2870 | + $output = ob_get_clean(); |
|
2871 | + return $output; |
|
2872 | 2872 | } |
2873 | 2873 | add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4); |
2874 | 2874 | |
2875 | 2875 | |
2876 | 2876 | function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){ |
2877 | 2877 | |
2878 | - ob_start(); |
|
2879 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
2880 | - $address = unserialize($field_info->extra_fields); |
|
2881 | - } |
|
2878 | + ob_start(); |
|
2879 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
2880 | + $address = unserialize($field_info->extra_fields); |
|
2881 | + } |
|
2882 | 2882 | |
2883 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2884 | - ?> |
|
2883 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2884 | + ?> |
|
2885 | 2885 | <?php |
2886 | - /** |
|
2887 | - * Called on the add custom fields settings page before the address field is output. |
|
2888 | - * |
|
2889 | - * @since 1.0.0 |
|
2890 | - * @param array $address The address settings array. |
|
2891 | - * @param object $field_info Extra fields info. |
|
2892 | - */ |
|
2893 | - do_action('geodir_address_extra_admin_fields', $address, $field_info); ?> |
|
2886 | + /** |
|
2887 | + * Called on the add custom fields settings page before the address field is output. |
|
2888 | + * |
|
2889 | + * @since 1.0.0 |
|
2890 | + * @param array $address The address settings array. |
|
2891 | + * @param object $field_info Extra fields info. |
|
2892 | + */ |
|
2893 | + do_action('geodir_address_extra_admin_fields', $address, $field_info); ?> |
|
2894 | 2894 | |
2895 | 2895 | <li> |
2896 | 2896 | <label for="show_zip" class="gd-cf-tooltip-wrap"> |
@@ -2903,14 +2903,14 @@ discard block |
||
2903 | 2903 | |
2904 | 2904 | <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled" value="1" |
2905 | 2905 | <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') { |
2906 | - echo 'checked'; |
|
2907 | - } ?>/> |
|
2906 | + echo 'checked'; |
|
2907 | + } ?>/> |
|
2908 | 2908 | <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> |
2909 | 2909 | |
2910 | 2910 | <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0" |
2911 | 2911 | <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) { |
2912 | - echo 'checked'; |
|
2913 | - } ?>/> |
|
2912 | + echo 'checked'; |
|
2913 | + } ?>/> |
|
2914 | 2914 | <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> |
2915 | 2915 | |
2916 | 2916 | |
@@ -2927,8 +2927,8 @@ discard block |
||
2927 | 2927 | <div class="gd-cf-input-wrap"> |
2928 | 2928 | <input type="text" name="extra[zip_lable]" id="zip_lable" |
2929 | 2929 | value="<?php if (isset($address['zip_lable'])) { |
2930 | - echo esc_attr($address['zip_lable']); |
|
2931 | - }?>"/> |
|
2930 | + echo esc_attr($address['zip_lable']); |
|
2931 | + }?>"/> |
|
2932 | 2932 | </div> |
2933 | 2933 | </li> |
2934 | 2934 | |
@@ -2945,8 +2945,8 @@ discard block |
||
2945 | 2945 | <div class="gd-cf-input-wrap"> |
2946 | 2946 | <input type="text" name="extra[map_lable]" id="map_lable" |
2947 | 2947 | value="<?php if (isset($address['map_lable'])) { |
2948 | - echo esc_attr($address['map_lable']); |
|
2949 | - }?>"/> |
|
2948 | + echo esc_attr($address['map_lable']); |
|
2949 | + }?>"/> |
|
2950 | 2950 | </div> |
2951 | 2951 | </li> |
2952 | 2952 | |
@@ -2961,14 +2961,14 @@ discard block |
||
2961 | 2961 | |
2962 | 2962 | <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled" value="1" |
2963 | 2963 | <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') { |
2964 | - echo 'checked'; |
|
2965 | - } ?>/> |
|
2964 | + echo 'checked'; |
|
2965 | + } ?>/> |
|
2966 | 2966 | <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2967 | 2967 | |
2968 | 2968 | <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0" |
2969 | 2969 | <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) { |
2970 | - echo 'checked'; |
|
2971 | - } ?>/> |
|
2970 | + echo 'checked'; |
|
2971 | + } ?>/> |
|
2972 | 2972 | <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2973 | 2973 | |
2974 | 2974 | </div> |
@@ -2985,14 +2985,14 @@ discard block |
||
2985 | 2985 | |
2986 | 2986 | <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled" value="1" |
2987 | 2987 | <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') { |
2988 | - echo 'checked'; |
|
2989 | - } ?>/> |
|
2988 | + echo 'checked'; |
|
2989 | + } ?>/> |
|
2990 | 2990 | <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2991 | 2991 | |
2992 | 2992 | <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0" |
2993 | 2993 | <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) { |
2994 | - echo 'checked'; |
|
2995 | - } ?>/> |
|
2994 | + echo 'checked'; |
|
2995 | + } ?>/> |
|
2996 | 2996 | <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2997 | 2997 | |
2998 | 2998 | </div> |
@@ -3009,8 +3009,8 @@ discard block |
||
3009 | 3009 | <div class="gd-cf-input-wrap"> |
3010 | 3010 | <input type="text" name="extra[mapview_lable]" id="mapview_lable" |
3011 | 3011 | value="<?php if (isset($address['mapview_lable'])) { |
3012 | - echo esc_attr($address['mapview_lable']); |
|
3013 | - }?>"/> |
|
3012 | + echo esc_attr($address['mapview_lable']); |
|
3013 | + }?>"/> |
|
3014 | 3014 | </div> |
3015 | 3015 | </li> |
3016 | 3016 | <li> |
@@ -3024,29 +3024,29 @@ discard block |
||
3024 | 3024 | |
3025 | 3025 | <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled" value="1" |
3026 | 3026 | <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') { |
3027 | - echo 'checked'; |
|
3028 | - } ?>/> |
|
3027 | + echo 'checked'; |
|
3028 | + } ?>/> |
|
3029 | 3029 | <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3030 | 3030 | |
3031 | 3031 | <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0" |
3032 | 3032 | <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) { |
3033 | - echo 'checked'; |
|
3034 | - } ?>/> |
|
3033 | + echo 'checked'; |
|
3034 | + } ?>/> |
|
3035 | 3035 | <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3036 | 3036 | |
3037 | 3037 | </div> |
3038 | 3038 | </li> |
3039 | 3039 | <?php |
3040 | 3040 | |
3041 | - $output = ob_get_clean(); |
|
3042 | - return $output; |
|
3041 | + $output = ob_get_clean(); |
|
3042 | + return $output; |
|
3043 | 3043 | } |
3044 | 3044 | add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4); |
3045 | 3045 | |
3046 | 3046 | |
3047 | 3047 | function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){ |
3048 | - ob_start(); |
|
3049 | - ?> |
|
3048 | + ob_start(); |
|
3049 | + ?> |
|
3050 | 3050 | <li> |
3051 | 3051 | <label for="multi_display_type" class="gd-cf-tooltip-wrap"> |
3052 | 3052 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?> |
@@ -3058,14 +3058,14 @@ discard block |
||
3058 | 3058 | |
3059 | 3059 | <select name="multi_display_type" id="multi_display_type"> |
3060 | 3060 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') { |
3061 | - echo 'selected="selected"'; |
|
3062 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
3061 | + echo 'selected="selected"'; |
|
3062 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
3063 | 3063 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') { |
3064 | - echo 'selected="selected"'; |
|
3065 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
3064 | + echo 'selected="selected"'; |
|
3065 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
3066 | 3066 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') { |
3067 | - echo 'selected="selected"'; |
|
3068 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
3067 | + echo 'selected="selected"'; |
|
3068 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
3069 | 3069 | </select> |
3070 | 3070 | |
3071 | 3071 | <br/> |
@@ -3073,17 +3073,17 @@ discard block |
||
3073 | 3073 | </li> |
3074 | 3074 | <?php |
3075 | 3075 | |
3076 | - $output = ob_get_clean(); |
|
3077 | - return $output; |
|
3076 | + $output = ob_get_clean(); |
|
3077 | + return $output; |
|
3078 | 3078 | } |
3079 | 3079 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4); |
3080 | 3080 | |
3081 | 3081 | |
3082 | 3082 | function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){ |
3083 | 3083 | |
3084 | - ob_start(); |
|
3085 | - $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
3086 | - ?> |
|
3084 | + ob_start(); |
|
3085 | + $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
3086 | + ?> |
|
3087 | 3087 | <li> |
3088 | 3088 | <label for="option_values" class="gd-cf-tooltip-wrap"> |
3089 | 3089 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?> |
@@ -3104,16 +3104,16 @@ discard block |
||
3104 | 3104 | <div class="gd-cf-input-wrap"> |
3105 | 3105 | <input type="text" name="option_values" id="option_values" |
3106 | 3106 | value="<?php if (isset($field_info->option_values)) { |
3107 | - echo esc_attr($field_info->option_values); |
|
3108 | - }?>"/> |
|
3107 | + echo esc_attr($field_info->option_values); |
|
3108 | + }?>"/> |
|
3109 | 3109 | <br/> |
3110 | 3110 | |
3111 | 3111 | </div> |
3112 | 3112 | </li> |
3113 | 3113 | <?php |
3114 | 3114 | |
3115 | - $output = ob_get_clean(); |
|
3116 | - return $output; |
|
3115 | + $output = ob_get_clean(); |
|
3116 | + return $output; |
|
3117 | 3117 | } |
3118 | 3118 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4); |
3119 | 3119 | add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4); |
@@ -3121,11 +3121,11 @@ discard block |
||
3121 | 3121 | |
3122 | 3122 | |
3123 | 3123 | function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){ |
3124 | - ob_start(); |
|
3125 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
3126 | - $extra = unserialize($field_info->extra_fields); |
|
3127 | - } |
|
3128 | - ?> |
|
3124 | + ob_start(); |
|
3125 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
3126 | + $extra = unserialize($field_info->extra_fields); |
|
3127 | + } |
|
3128 | + ?> |
|
3129 | 3129 | <li> |
3130 | 3130 | <label for="date_format" class="gd-cf-tooltip-wrap"> |
3131 | 3131 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?> |
@@ -3135,52 +3135,52 @@ discard block |
||
3135 | 3135 | </label> |
3136 | 3136 | <div class="gd-cf-input-wrap" style="overflow:inherit;"> |
3137 | 3137 | <?php |
3138 | - $date_formats = array( |
|
3139 | - 'm/d/Y', |
|
3140 | - 'd/m/Y', |
|
3141 | - 'Y/m/d', |
|
3142 | - 'm-d-Y', |
|
3143 | - 'd-m-Y', |
|
3144 | - 'Y-m-d', |
|
3145 | - 'F j, Y', |
|
3146 | - ); |
|
3147 | - /** |
|
3148 | - * Filter the custom field date format options. |
|
3149 | - * |
|
3150 | - * @since 1.6.5 |
|
3151 | - * @param array $date_formats The PHP date format array. |
|
3152 | - */ |
|
3153 | - $date_formats = apply_filters('geodir_date_formats',$date_formats); |
|
3154 | - ?> |
|
3138 | + $date_formats = array( |
|
3139 | + 'm/d/Y', |
|
3140 | + 'd/m/Y', |
|
3141 | + 'Y/m/d', |
|
3142 | + 'm-d-Y', |
|
3143 | + 'd-m-Y', |
|
3144 | + 'Y-m-d', |
|
3145 | + 'F j, Y', |
|
3146 | + ); |
|
3147 | + /** |
|
3148 | + * Filter the custom field date format options. |
|
3149 | + * |
|
3150 | + * @since 1.6.5 |
|
3151 | + * @param array $date_formats The PHP date format array. |
|
3152 | + */ |
|
3153 | + $date_formats = apply_filters('geodir_date_formats',$date_formats); |
|
3154 | + ?> |
|
3155 | 3155 | <select name="extra[date_format]" id="date_format"> |
3156 | 3156 | <?php |
3157 | - foreach($date_formats as $format){ |
|
3158 | - $selected = ''; |
|
3159 | - if(esc_attr($extra['date_format'])==$format){ |
|
3160 | - $selected = "selected='selected'"; |
|
3161 | - } |
|
3162 | - echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>"; |
|
3163 | - } |
|
3164 | - ?> |
|
3157 | + foreach($date_formats as $format){ |
|
3158 | + $selected = ''; |
|
3159 | + if(esc_attr($extra['date_format'])==$format){ |
|
3160 | + $selected = "selected='selected'"; |
|
3161 | + } |
|
3162 | + echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>"; |
|
3163 | + } |
|
3164 | + ?> |
|
3165 | 3165 | </select> |
3166 | 3166 | |
3167 | 3167 | </div> |
3168 | 3168 | </li> |
3169 | 3169 | <?php |
3170 | 3170 | |
3171 | - $output = ob_get_clean(); |
|
3172 | - return $output; |
|
3171 | + $output = ob_get_clean(); |
|
3172 | + return $output; |
|
3173 | 3173 | } |
3174 | 3174 | add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4); |
3175 | 3175 | |
3176 | 3176 | |
3177 | 3177 | function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){ |
3178 | - ob_start(); |
|
3179 | - $allowed_file_types = geodir_allowed_mime_types(); |
|
3178 | + ob_start(); |
|
3179 | + $allowed_file_types = geodir_allowed_mime_types(); |
|
3180 | 3180 | |
3181 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3182 | - $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*'); |
|
3183 | - ?> |
|
3181 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3182 | + $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*'); |
|
3183 | + ?> |
|
3184 | 3184 | <li> |
3185 | 3185 | <label for="gd_file_types" class="gd-cf-tooltip-wrap"> |
3186 | 3186 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?> |
@@ -3203,182 +3203,182 @@ discard block |
||
3203 | 3203 | </li> |
3204 | 3204 | <?php |
3205 | 3205 | |
3206 | - $output = ob_get_clean(); |
|
3207 | - return $output; |
|
3206 | + $output = ob_get_clean(); |
|
3207 | + return $output; |
|
3208 | 3208 | } |
3209 | 3209 | add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4); |
3210 | 3210 | |
3211 | 3211 | function geodir_default_custom_fields($post_type='gd_place',$package_id=''){ |
3212 | - $fields = array(); |
|
3213 | - $package = ($package_id=='') ? '' : array($package_id); |
|
3214 | - |
|
3215 | - $fields[] = array('listing_type' => $post_type, |
|
3216 | - 'data_type' => 'VARCHAR', |
|
3217 | - 'field_type' => 'taxonomy', |
|
3218 | - 'admin_title' => __('Category', 'geodirectory'), |
|
3219 | - 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), |
|
3220 | - 'site_title' => __('Category', 'geodirectory'), |
|
3221 | - 'htmlvar_name' => $post_type.'category', |
|
3222 | - 'default_value' => '', |
|
3223 | - 'is_default' => '1', |
|
3224 | - 'is_admin' => '1', |
|
3225 | - 'is_required' => '1', |
|
3226 | - 'show_in' => '[detail]', |
|
3227 | - 'show_on_pkg' => $package, |
|
3228 | - 'clabels' => __('Category', 'geodirectory')); |
|
3229 | - |
|
3230 | - $fields[] = array('listing_type' => $post_type, |
|
3231 | - 'data_type' => 'VARCHAR', |
|
3232 | - 'field_type' => 'address', |
|
3233 | - 'admin_title' => __('Address', 'geodirectory'), |
|
3234 | - 'admin_desc' => ADDRESS_MSG, |
|
3235 | - 'site_title' => __('Address', 'geodirectory'), |
|
3236 | - 'htmlvar_name' => 'post', |
|
3237 | - 'default_value' => '', |
|
3238 | - 'option_values' => '', |
|
3239 | - 'is_default' => '1', |
|
3240 | - 'is_admin' => '1', |
|
3241 | - 'is_required' => '1', |
|
3242 | - 'show_in' => '[detail],[mapbubble]', |
|
3243 | - 'show_on_pkg' => $package, |
|
3244 | - 'required_msg' => __('Address fields are required', 'geodirectory'), |
|
3245 | - 'clabels' => __('Address', 'geodirectory'), |
|
3246 | - 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), |
|
3247 | - 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), |
|
3248 | - 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), |
|
3249 | - 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), |
|
3250 | - 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), |
|
3251 | - 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), |
|
3252 | - 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
3253 | - 'show_latlng' => 1)); |
|
3254 | - |
|
3255 | - $fields[] = array('listing_type' => $post_type, |
|
3256 | - 'data_type' => 'VARCHAR', |
|
3257 | - 'field_type' => 'text', |
|
3258 | - 'admin_title' => __('Time', 'geodirectory'), |
|
3259 | - 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), |
|
3260 | - 'site_title' => __('Time', 'geodirectory'), |
|
3261 | - 'htmlvar_name' => 'timing', |
|
3262 | - 'default_value' => '', |
|
3263 | - 'option_values' => '', |
|
3264 | - 'is_default' => '1', |
|
3265 | - 'is_admin' => '1', |
|
3266 | - 'show_in' => '[detail],[mapbubble]', |
|
3267 | - 'show_on_pkg' => $package, |
|
3268 | - 'clabels' => __('Time', 'geodirectory')); |
|
3269 | - |
|
3270 | - $fields[] = array('listing_type' => $post_type, |
|
3271 | - 'data_type' => 'VARCHAR', |
|
3272 | - 'field_type' => 'phone', |
|
3273 | - 'admin_title' => __('Phone', 'geodirectory'), |
|
3274 | - 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), |
|
3275 | - 'site_title' => __('Phone', 'geodirectory'), |
|
3276 | - 'htmlvar_name' => 'contact', |
|
3277 | - 'default_value' => '', |
|
3278 | - 'option_values' => '', |
|
3279 | - 'is_default' => '1', |
|
3280 | - 'is_admin' => '1', |
|
3281 | - 'show_in' => '[detail],[mapbubble]', |
|
3282 | - 'show_on_pkg' => $package, |
|
3283 | - 'clabels' => __('Phone', 'geodirectory')); |
|
3284 | - |
|
3285 | - $fields[] = array('listing_type' => $post_type, |
|
3286 | - 'data_type' => 'VARCHAR', |
|
3287 | - 'field_type' => 'email', |
|
3288 | - 'admin_title' => __('Email', 'geodirectory'), |
|
3289 | - 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), |
|
3290 | - 'site_title' => __('Email', 'geodirectory'), |
|
3291 | - 'htmlvar_name' => 'email', |
|
3292 | - 'default_value' => '', |
|
3293 | - 'option_values' => '', |
|
3294 | - 'is_default' => '1', |
|
3295 | - 'is_admin' => '1', |
|
3296 | - 'show_in' => '[detail]', |
|
3297 | - 'show_on_pkg' => $package, |
|
3298 | - 'clabels' => __('Email', 'geodirectory')); |
|
3299 | - |
|
3300 | - $fields[] = array('listing_type' => $post_type, |
|
3301 | - 'data_type' => 'VARCHAR', |
|
3302 | - 'field_type' => 'url', |
|
3303 | - 'admin_title' => __('Website', 'geodirectory'), |
|
3304 | - 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), |
|
3305 | - 'site_title' => __('Website', 'geodirectory'), |
|
3306 | - 'htmlvar_name' => 'website', |
|
3307 | - 'default_value' => '', |
|
3308 | - 'option_values' => '', |
|
3309 | - 'is_default' => '1', |
|
3310 | - 'is_admin' => '1', |
|
3311 | - 'show_in' => '[detail]', |
|
3312 | - 'show_on_pkg' => $package, |
|
3313 | - 'clabels' => __('Website', 'geodirectory')); |
|
3314 | - |
|
3315 | - $fields[] = array('listing_type' => $post_type, |
|
3316 | - 'data_type' => 'VARCHAR', |
|
3317 | - 'field_type' => 'url', |
|
3318 | - 'admin_title' => __('Twitter', 'geodirectory'), |
|
3319 | - 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), |
|
3320 | - 'site_title' => __('Twitter', 'geodirectory'), |
|
3321 | - 'htmlvar_name' => 'twitter', |
|
3322 | - 'default_value' => '', |
|
3323 | - 'option_values' => '', |
|
3324 | - 'is_default' => '1', |
|
3325 | - 'is_admin' => '1', |
|
3326 | - 'show_in' => '[detail]', |
|
3327 | - 'show_on_pkg' => $package, |
|
3328 | - 'clabels' => __('Twitter', 'geodirectory')); |
|
3329 | - |
|
3330 | - $fields[] = array('listing_type' => $post_type, |
|
3331 | - 'data_type' => 'VARCHAR', |
|
3332 | - 'field_type' => 'url', |
|
3333 | - 'admin_title' => __('Facebook', 'geodirectory'), |
|
3334 | - 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), |
|
3335 | - 'site_title' => __('Facebook', 'geodirectory'), |
|
3336 | - 'htmlvar_name' => 'facebook', |
|
3337 | - 'default_value' => '', |
|
3338 | - 'option_values' => '', |
|
3339 | - 'is_default' => '1', |
|
3340 | - 'is_admin' => '1', |
|
3341 | - 'show_in' => '[detail]', |
|
3342 | - 'show_on_pkg' => $package, |
|
3343 | - 'clabels' => __('Facebook', 'geodirectory')); |
|
3344 | - |
|
3345 | - $fields[] = array('listing_type' => $post_type, |
|
3346 | - 'data_type' => 'TEXT', |
|
3347 | - 'field_type' => 'textarea', |
|
3348 | - 'admin_title' => __('Video', 'geodirectory'), |
|
3349 | - 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), |
|
3350 | - 'site_title' => __('Video', 'geodirectory'), |
|
3351 | - 'htmlvar_name' => 'video', |
|
3352 | - 'default_value' => '', |
|
3353 | - 'option_values' => '', |
|
3354 | - 'is_default' => '0', |
|
3355 | - 'is_admin' => '1', |
|
3356 | - 'show_in' => '[owntab]', |
|
3357 | - 'show_on_pkg' => $package, |
|
3358 | - 'clabels' => __('Video', 'geodirectory')); |
|
3359 | - |
|
3360 | - $fields[] = array('listing_type' => $post_type, |
|
3361 | - 'data_type' => 'TEXT', |
|
3362 | - 'field_type' => 'textarea', |
|
3363 | - 'admin_title' => __('Special Offers', 'geodirectory'), |
|
3364 | - 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), |
|
3365 | - 'site_title' => __('Special Offers', 'geodirectory'), |
|
3366 | - 'htmlvar_name' => 'special_offers', |
|
3367 | - 'default_value' => '', |
|
3368 | - 'option_values' => '', |
|
3369 | - 'is_default' => '0', |
|
3370 | - 'is_admin' => '1', |
|
3371 | - 'show_in' => '[owntab]', |
|
3372 | - 'show_on_pkg' => $package, |
|
3373 | - 'clabels' => __('Special Offers', 'geodirectory')); |
|
3374 | - |
|
3375 | - /** |
|
3376 | - * Filter the array of default custom fields DB table data. |
|
3377 | - * |
|
3378 | - * @since 1.6.6 |
|
3379 | - * @param string $fields The default custom fields as an array. |
|
3380 | - */ |
|
3381 | - $fields = apply_filters('geodir_default_custom_fields', $fields); |
|
3382 | - |
|
3383 | - return $fields; |
|
3212 | + $fields = array(); |
|
3213 | + $package = ($package_id=='') ? '' : array($package_id); |
|
3214 | + |
|
3215 | + $fields[] = array('listing_type' => $post_type, |
|
3216 | + 'data_type' => 'VARCHAR', |
|
3217 | + 'field_type' => 'taxonomy', |
|
3218 | + 'admin_title' => __('Category', 'geodirectory'), |
|
3219 | + 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), |
|
3220 | + 'site_title' => __('Category', 'geodirectory'), |
|
3221 | + 'htmlvar_name' => $post_type.'category', |
|
3222 | + 'default_value' => '', |
|
3223 | + 'is_default' => '1', |
|
3224 | + 'is_admin' => '1', |
|
3225 | + 'is_required' => '1', |
|
3226 | + 'show_in' => '[detail]', |
|
3227 | + 'show_on_pkg' => $package, |
|
3228 | + 'clabels' => __('Category', 'geodirectory')); |
|
3229 | + |
|
3230 | + $fields[] = array('listing_type' => $post_type, |
|
3231 | + 'data_type' => 'VARCHAR', |
|
3232 | + 'field_type' => 'address', |
|
3233 | + 'admin_title' => __('Address', 'geodirectory'), |
|
3234 | + 'admin_desc' => ADDRESS_MSG, |
|
3235 | + 'site_title' => __('Address', 'geodirectory'), |
|
3236 | + 'htmlvar_name' => 'post', |
|
3237 | + 'default_value' => '', |
|
3238 | + 'option_values' => '', |
|
3239 | + 'is_default' => '1', |
|
3240 | + 'is_admin' => '1', |
|
3241 | + 'is_required' => '1', |
|
3242 | + 'show_in' => '[detail],[mapbubble]', |
|
3243 | + 'show_on_pkg' => $package, |
|
3244 | + 'required_msg' => __('Address fields are required', 'geodirectory'), |
|
3245 | + 'clabels' => __('Address', 'geodirectory'), |
|
3246 | + 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), |
|
3247 | + 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), |
|
3248 | + 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), |
|
3249 | + 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), |
|
3250 | + 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), |
|
3251 | + 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), |
|
3252 | + 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
3253 | + 'show_latlng' => 1)); |
|
3254 | + |
|
3255 | + $fields[] = array('listing_type' => $post_type, |
|
3256 | + 'data_type' => 'VARCHAR', |
|
3257 | + 'field_type' => 'text', |
|
3258 | + 'admin_title' => __('Time', 'geodirectory'), |
|
3259 | + 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), |
|
3260 | + 'site_title' => __('Time', 'geodirectory'), |
|
3261 | + 'htmlvar_name' => 'timing', |
|
3262 | + 'default_value' => '', |
|
3263 | + 'option_values' => '', |
|
3264 | + 'is_default' => '1', |
|
3265 | + 'is_admin' => '1', |
|
3266 | + 'show_in' => '[detail],[mapbubble]', |
|
3267 | + 'show_on_pkg' => $package, |
|
3268 | + 'clabels' => __('Time', 'geodirectory')); |
|
3269 | + |
|
3270 | + $fields[] = array('listing_type' => $post_type, |
|
3271 | + 'data_type' => 'VARCHAR', |
|
3272 | + 'field_type' => 'phone', |
|
3273 | + 'admin_title' => __('Phone', 'geodirectory'), |
|
3274 | + 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), |
|
3275 | + 'site_title' => __('Phone', 'geodirectory'), |
|
3276 | + 'htmlvar_name' => 'contact', |
|
3277 | + 'default_value' => '', |
|
3278 | + 'option_values' => '', |
|
3279 | + 'is_default' => '1', |
|
3280 | + 'is_admin' => '1', |
|
3281 | + 'show_in' => '[detail],[mapbubble]', |
|
3282 | + 'show_on_pkg' => $package, |
|
3283 | + 'clabels' => __('Phone', 'geodirectory')); |
|
3284 | + |
|
3285 | + $fields[] = array('listing_type' => $post_type, |
|
3286 | + 'data_type' => 'VARCHAR', |
|
3287 | + 'field_type' => 'email', |
|
3288 | + 'admin_title' => __('Email', 'geodirectory'), |
|
3289 | + 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), |
|
3290 | + 'site_title' => __('Email', 'geodirectory'), |
|
3291 | + 'htmlvar_name' => 'email', |
|
3292 | + 'default_value' => '', |
|
3293 | + 'option_values' => '', |
|
3294 | + 'is_default' => '1', |
|
3295 | + 'is_admin' => '1', |
|
3296 | + 'show_in' => '[detail]', |
|
3297 | + 'show_on_pkg' => $package, |
|
3298 | + 'clabels' => __('Email', 'geodirectory')); |
|
3299 | + |
|
3300 | + $fields[] = array('listing_type' => $post_type, |
|
3301 | + 'data_type' => 'VARCHAR', |
|
3302 | + 'field_type' => 'url', |
|
3303 | + 'admin_title' => __('Website', 'geodirectory'), |
|
3304 | + 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), |
|
3305 | + 'site_title' => __('Website', 'geodirectory'), |
|
3306 | + 'htmlvar_name' => 'website', |
|
3307 | + 'default_value' => '', |
|
3308 | + 'option_values' => '', |
|
3309 | + 'is_default' => '1', |
|
3310 | + 'is_admin' => '1', |
|
3311 | + 'show_in' => '[detail]', |
|
3312 | + 'show_on_pkg' => $package, |
|
3313 | + 'clabels' => __('Website', 'geodirectory')); |
|
3314 | + |
|
3315 | + $fields[] = array('listing_type' => $post_type, |
|
3316 | + 'data_type' => 'VARCHAR', |
|
3317 | + 'field_type' => 'url', |
|
3318 | + 'admin_title' => __('Twitter', 'geodirectory'), |
|
3319 | + 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), |
|
3320 | + 'site_title' => __('Twitter', 'geodirectory'), |
|
3321 | + 'htmlvar_name' => 'twitter', |
|
3322 | + 'default_value' => '', |
|
3323 | + 'option_values' => '', |
|
3324 | + 'is_default' => '1', |
|
3325 | + 'is_admin' => '1', |
|
3326 | + 'show_in' => '[detail]', |
|
3327 | + 'show_on_pkg' => $package, |
|
3328 | + 'clabels' => __('Twitter', 'geodirectory')); |
|
3329 | + |
|
3330 | + $fields[] = array('listing_type' => $post_type, |
|
3331 | + 'data_type' => 'VARCHAR', |
|
3332 | + 'field_type' => 'url', |
|
3333 | + 'admin_title' => __('Facebook', 'geodirectory'), |
|
3334 | + 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), |
|
3335 | + 'site_title' => __('Facebook', 'geodirectory'), |
|
3336 | + 'htmlvar_name' => 'facebook', |
|
3337 | + 'default_value' => '', |
|
3338 | + 'option_values' => '', |
|
3339 | + 'is_default' => '1', |
|
3340 | + 'is_admin' => '1', |
|
3341 | + 'show_in' => '[detail]', |
|
3342 | + 'show_on_pkg' => $package, |
|
3343 | + 'clabels' => __('Facebook', 'geodirectory')); |
|
3344 | + |
|
3345 | + $fields[] = array('listing_type' => $post_type, |
|
3346 | + 'data_type' => 'TEXT', |
|
3347 | + 'field_type' => 'textarea', |
|
3348 | + 'admin_title' => __('Video', 'geodirectory'), |
|
3349 | + 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), |
|
3350 | + 'site_title' => __('Video', 'geodirectory'), |
|
3351 | + 'htmlvar_name' => 'video', |
|
3352 | + 'default_value' => '', |
|
3353 | + 'option_values' => '', |
|
3354 | + 'is_default' => '0', |
|
3355 | + 'is_admin' => '1', |
|
3356 | + 'show_in' => '[owntab]', |
|
3357 | + 'show_on_pkg' => $package, |
|
3358 | + 'clabels' => __('Video', 'geodirectory')); |
|
3359 | + |
|
3360 | + $fields[] = array('listing_type' => $post_type, |
|
3361 | + 'data_type' => 'TEXT', |
|
3362 | + 'field_type' => 'textarea', |
|
3363 | + 'admin_title' => __('Special Offers', 'geodirectory'), |
|
3364 | + 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), |
|
3365 | + 'site_title' => __('Special Offers', 'geodirectory'), |
|
3366 | + 'htmlvar_name' => 'special_offers', |
|
3367 | + 'default_value' => '', |
|
3368 | + 'option_values' => '', |
|
3369 | + 'is_default' => '0', |
|
3370 | + 'is_admin' => '1', |
|
3371 | + 'show_in' => '[owntab]', |
|
3372 | + 'show_on_pkg' => $package, |
|
3373 | + 'clabels' => __('Special Offers', 'geodirectory')); |
|
3374 | + |
|
3375 | + /** |
|
3376 | + * Filter the array of default custom fields DB table data. |
|
3377 | + * |
|
3378 | + * @since 1.6.6 |
|
3379 | + * @param string $fields The default custom fields as an array. |
|
3380 | + */ |
|
3381 | + $fields = apply_filters('geodir_default_custom_fields', $fields); |
|
3382 | + |
|
3383 | + return $fields; |
|
3384 | 3384 | } |
3385 | 3385 | \ No newline at end of file |