| @@ -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,702 +72,702 @@ 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_default IN ('1') ";
 | |
| 87 | - elseif ($default == 'custom') | |
| 88 | - $default_query = " and is_default = '0' "; | |
| 89 | - | |
| 90 | -    if ($fields_location == 'detail') {
 | |
| 91 | - $default_query = " and show_on_detail='1' "; | |
| 92 | -    } elseif ($fields_location == 'listing') {
 | |
| 93 | - $default_query = " and show_on_listing='1' "; | |
| 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_default IN ('1') ";
 | |
| 87 | + elseif ($default == 'custom') | |
| 88 | + $default_query = " and is_default = '0' "; | |
| 89 | + | |
| 90 | +	if ($fields_location == 'detail') {
 | |
| 91 | + $default_query = " and show_on_detail='1' "; | |
| 92 | +	} elseif ($fields_location == 'listing') {
 | |
| 93 | + $default_query = " and show_on_listing='1' "; | |
| 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 | 154 |  if (!function_exists('geodir_custom_field_adminhtml')) {
 | 
| 155 | - /** | |
| 156 | - * Adds admin html for custom fields. | |
| 157 | - * | |
| 158 | - * @since 1.0.0 | |
| 159 | - * @package GeoDirectory | |
| 160 | - * @global object $wpdb WordPress Database object. | |
| 161 | - * @param string $field_type The form field type. | |
| 162 | - * @param object|int $result_str The custom field results object or row id. | |
| 163 | - * @param string $field_ins_upd When set to "submit" displays form. | |
| 164 | - * @param bool $default when set to true field will be for admin use only. | |
| 165 | - */ | |
| 166 | - function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) | |
| 167 | -    {
 | |
| 168 | - global $wpdb; | |
| 169 | - $cf = $result_str; | |
| 170 | -        if (!is_object($cf)) {
 | |
| 171 | - | |
| 172 | -            $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
 | |
| 173 | - | |
| 174 | -        } else {
 | |
| 175 | - $field_info = $cf; | |
| 176 | - $result_str = $cf->id; | |
| 177 | - } | |
| 178 | - /** | |
| 179 | - * Contains custom field html. | |
| 180 | - * | |
| 181 | - * @since 1.0.0 | |
| 182 | - */ | |
| 183 | -        include('custom_field_html.php');
 | |
| 184 | - | |
| 185 | - } | |
| 155 | + /** | |
| 156 | + * Adds admin html for custom fields. | |
| 157 | + * | |
| 158 | + * @since 1.0.0 | |
| 159 | + * @package GeoDirectory | |
| 160 | + * @global object $wpdb WordPress Database object. | |
| 161 | + * @param string $field_type The form field type. | |
| 162 | + * @param object|int $result_str The custom field results object or row id. | |
| 163 | + * @param string $field_ins_upd When set to "submit" displays form. | |
| 164 | + * @param bool $default when set to true field will be for admin use only. | |
| 165 | + */ | |
| 166 | + function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) | |
| 167 | +	{
 | |
| 168 | + global $wpdb; | |
| 169 | + $cf = $result_str; | |
| 170 | +		if (!is_object($cf)) {
 | |
| 171 | + | |
| 172 | +			$field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
 | |
| 173 | + | |
| 174 | +		} else {
 | |
| 175 | + $field_info = $cf; | |
| 176 | + $result_str = $cf->id; | |
| 177 | + } | |
| 178 | + /** | |
| 179 | + * Contains custom field html. | |
| 180 | + * | |
| 181 | + * @since 1.0.0 | |
| 182 | + */ | |
| 183 | +		include('custom_field_html.php');
 | |
| 184 | + | |
| 185 | + } | |
| 186 | 186 | } | 
| 187 | 187 | |
| 188 | 188 |  if (!function_exists('geodir_custom_field_delete')) {
 | 
| 189 | - /** | |
| 190 | - * Delete custom field using field id. | |
| 191 | - * | |
| 192 | - * @since 1.0.0 | |
| 193 | - * @since 1.5.7 Delete field from sorting fields table when custom field deleted. | |
| 194 | - * @package GeoDirectory | |
| 195 | - * @global object $wpdb WordPress Database object. | |
| 196 | - * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 197 | - * @param string $field_id The custom field ID. | |
| 198 | - * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. | |
| 199 | - */ | |
| 200 | -    function geodir_custom_field_delete($field_id = '') {
 | |
| 201 | - global $wpdb, $plugin_prefix; | |
| 202 | - | |
| 203 | -        if ($field_id != '') {
 | |
| 204 | - $cf = trim($field_id, '_'); | |
| 205 | - | |
| 206 | -            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
 | |
| 207 | -                $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
 | |
| 208 | - | |
| 209 | - $post_type = $field->post_type; | |
| 210 | - $htmlvar_name = $field->htmlvar_name; | |
| 211 | - | |
| 212 | -                if ($post_type != '' && $htmlvar_name != '') {
 | |
| 213 | -                    $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)));
 | |
| 214 | - } | |
| 215 | - | |
| 216 | - /** | |
| 217 | - * Called after a custom field is deleted. | |
| 218 | - * | |
| 219 | - * @since 1.0.0 | |
| 220 | - * @param string $cf The fields ID. | |
| 221 | - * @param string $field->htmlvar_name The html variable name for the field. | |
| 222 | - * @param string $post_type The post type the field belongs to. | |
| 223 | - */ | |
| 224 | -                do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
 | |
| 225 | - | |
| 226 | -                if ($field->field_type == 'address') {
 | |
| 227 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
 | |
| 228 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
 | |
| 229 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
 | |
| 230 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
 | |
| 231 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
 | |
| 232 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
 | |
| 233 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
 | |
| 234 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
 | |
| 235 | -                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
 | |
| 236 | -                } else {
 | |
| 237 | -                    if ($field->field_type != 'fieldset') {
 | |
| 238 | -                        $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
 | |
| 239 | - } | |
| 240 | - } | |
| 241 | - | |
| 242 | - return $field_id; | |
| 243 | - } else | |
| 244 | - return 0; | |
| 245 | - } else | |
| 246 | - return 0; | |
| 247 | - } | |
| 189 | + /** | |
| 190 | + * Delete custom field using field id. | |
| 191 | + * | |
| 192 | + * @since 1.0.0 | |
| 193 | + * @since 1.5.7 Delete field from sorting fields table when custom field deleted. | |
| 194 | + * @package GeoDirectory | |
| 195 | + * @global object $wpdb WordPress Database object. | |
| 196 | + * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 197 | + * @param string $field_id The custom field ID. | |
| 198 | + * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. | |
| 199 | + */ | |
| 200 | +	function geodir_custom_field_delete($field_id = '') {
 | |
| 201 | + global $wpdb, $plugin_prefix; | |
| 202 | + | |
| 203 | +		if ($field_id != '') {
 | |
| 204 | + $cf = trim($field_id, '_'); | |
| 205 | + | |
| 206 | +			if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
 | |
| 207 | +				$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
 | |
| 208 | + | |
| 209 | + $post_type = $field->post_type; | |
| 210 | + $htmlvar_name = $field->htmlvar_name; | |
| 211 | + | |
| 212 | +				if ($post_type != '' && $htmlvar_name != '') {
 | |
| 213 | +					$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)));
 | |
| 214 | + } | |
| 215 | + | |
| 216 | + /** | |
| 217 | + * Called after a custom field is deleted. | |
| 218 | + * | |
| 219 | + * @since 1.0.0 | |
| 220 | + * @param string $cf The fields ID. | |
| 221 | + * @param string $field->htmlvar_name The html variable name for the field. | |
| 222 | + * @param string $post_type The post type the field belongs to. | |
| 223 | + */ | |
| 224 | +				do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
 | |
| 225 | + | |
| 226 | +				if ($field->field_type == 'address') {
 | |
| 227 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
 | |
| 228 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
 | |
| 229 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
 | |
| 230 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
 | |
| 231 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
 | |
| 232 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
 | |
| 233 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
 | |
| 234 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
 | |
| 235 | +					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
 | |
| 236 | +				} else {
 | |
| 237 | +					if ($field->field_type != 'fieldset') {
 | |
| 238 | +						$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
 | |
| 239 | + } | |
| 240 | + } | |
| 241 | + | |
| 242 | + return $field_id; | |
| 243 | + } else | |
| 244 | + return 0; | |
| 245 | + } else | |
| 246 | + return 0; | |
| 247 | + } | |
| 248 | 248 | } | 
| 249 | 249 | |
| 250 | 250 |  if (!function_exists('geodir_custom_field_save')) {
 | 
| 251 | - /** | |
| 252 | - * Save or Update custom fields into the database. | |
| 253 | - * | |
| 254 | - * @since 1.0.0 | |
| 255 | - * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. | |
| 256 | - * @package GeoDirectory | |
| 257 | - * @global object $wpdb WordPress Database object. | |
| 258 | - * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 259 | -     * @param array $request_field {
 | |
| 260 | - * Attributes of the request field array. | |
| 261 | - * | |
| 262 | - * @type string $action Ajax Action name. Default "geodir_ajax_action". | |
| 263 | - * @type string $manage_field_type Field type Default "custom_fields". | |
| 264 | - * @type string $create_field Create field Default "true". | |
| 265 | - * @type string $field_ins_upd Field ins upd Default "submit". | |
| 266 | - * @type string $_wpnonce WP nonce value. | |
| 267 | - * @type string $listing_type Listing type Example "gd_place". | |
| 268 | - * @type string $field_type Field type Example "radio". | |
| 269 | - * @type string $field_id Field id Example "12". | |
| 270 | - * @type string $data_type Data type Example "VARCHAR". | |
| 271 | - * @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere. | |
| 272 | - * @type array $show_on_pkg Package list to display this field. | |
| 273 | - * @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings. | |
| 274 | - * @type string $site_title Section title which you wish to display in frontend. | |
| 275 | - * @type string $admin_desc Section description which will appear in frontend. | |
| 276 | - * @type string $htmlvar_name Html variable name. This should be a unique name. | |
| 277 | - * @type string $clabels Section Title which will appear in backend. | |
| 278 | - * @type string $default_value The default value (for "link" this will be used as the link text). | |
| 279 | - * @type string $sort_order The display order of this field in backend. e.g. 5. | |
| 280 | - * @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. | |
| 281 | - * @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field. | |
| 282 | - * @type string $is_required Use "1" to set field as required. | |
| 283 | - * @type string $required_msg Enter text for error message if field required and have not full fill requirment. | |
| 284 | - * @type string $show_on_listing Want to show this on listing page?. | |
| 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'; | |
| 251 | + /** | |
| 252 | + * Save or Update custom fields into the database. | |
| 253 | + * | |
| 254 | + * @since 1.0.0 | |
| 255 | + * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. | |
| 256 | + * @package GeoDirectory | |
| 257 | + * @global object $wpdb WordPress Database object. | |
| 258 | + * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 259 | +	 * @param array $request_field {
 | |
| 260 | + * Attributes of the request field array. | |
| 261 | + * | |
| 262 | + * @type string $action Ajax Action name. Default "geodir_ajax_action". | |
| 263 | + * @type string $manage_field_type Field type Default "custom_fields". | |
| 264 | + * @type string $create_field Create field Default "true". | |
| 265 | + * @type string $field_ins_upd Field ins upd Default "submit". | |
| 266 | + * @type string $_wpnonce WP nonce value. | |
| 267 | + * @type string $listing_type Listing type Example "gd_place". | |
| 268 | + * @type string $field_type Field type Example "radio". | |
| 269 | + * @type string $field_id Field id Example "12". | |
| 270 | + * @type string $data_type Data type Example "VARCHAR". | |
| 271 | + * @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere. | |
| 272 | + * @type array $show_on_pkg Package list to display this field. | |
| 273 | + * @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings. | |
| 274 | + * @type string $site_title Section title which you wish to display in frontend. | |
| 275 | + * @type string $admin_desc Section description which will appear in frontend. | |
| 276 | + * @type string $htmlvar_name Html variable name. This should be a unique name. | |
| 277 | + * @type string $clabels Section Title which will appear in backend. | |
| 278 | + * @type string $default_value The default value (for "link" this will be used as the link text). | |
| 279 | + * @type string $sort_order The display order of this field in backend. e.g. 5. | |
| 280 | + * @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. | |
| 281 | + * @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field. | |
| 282 | + * @type string $is_required Use "1" to set field as required. | |
| 283 | + * @type string $required_msg Enter text for error message if field required and have not full fill requirment. | |
| 284 | + * @type string $show_on_listing Want to show this on listing page?. | |
| 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 | 353 | |
| 354 | 354 | |
| 355 | - $detail_table = $plugin_prefix . $post_type . '_detail'; | |
| 355 | + $detail_table = $plugin_prefix . $post_type . '_detail'; | |
| 356 | 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 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; | |
| 362 | - $admin_desc = $request_field['admin_desc']; | |
| 363 | - $clabels = $request_field['clabels']; | |
| 364 | - $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; | |
| 365 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; | |
| 366 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; | |
| 367 | - $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; | |
| 368 | - $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; | |
| 369 | - $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; | |
| 370 | - $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; | |
| 371 | - $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; | |
| 372 | - $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; | |
| 373 | - $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; | |
| 374 | - $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type | |
| 375 | - $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; | |
| 376 | - $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; | |
| 377 | - $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; | |
| 378 | - $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; | |
| 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 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; | |
| 362 | + $admin_desc = $request_field['admin_desc']; | |
| 363 | + $clabels = $request_field['clabels']; | |
| 364 | + $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; | |
| 365 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; | |
| 366 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; | |
| 367 | + $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; | |
| 368 | + $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; | |
| 369 | + $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; | |
| 370 | + $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; | |
| 371 | + $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; | |
| 372 | + $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; | |
| 373 | + $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; | |
| 374 | + $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type | |
| 375 | + $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; | |
| 376 | + $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; | |
| 377 | + $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; | |
| 378 | + $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; | |
| 379 | 379 | |
| 380 | -            if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
 | |
| 381 | - $htmlvar_name = 'geodir_' . $htmlvar_name; | |
| 382 | - } | |
| 380 | +			if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
 | |
| 381 | + $htmlvar_name = 'geodir_' . $htmlvar_name; | |
| 382 | + } | |
| 383 | 383 | |
| 384 | - $option_values = ''; | |
| 385 | - if (isset($request_field['option_values'])) | |
| 386 | - $option_values = $request_field['option_values']; | |
| 384 | + $option_values = ''; | |
| 385 | + if (isset($request_field['option_values'])) | |
| 386 | + $option_values = $request_field['option_values']; | |
| 387 | 387 | |
| 388 | - $cat_sort = ''; | |
| 389 | - if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort'])) | |
| 390 | -                $cat_sort = implode(",", $request_field['cat_sort']);
 | |
| 388 | + $cat_sort = ''; | |
| 389 | + if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort'])) | |
| 390 | +				$cat_sort = implode(",", $request_field['cat_sort']);
 | |
| 391 | 391 | |
| 392 | - $cat_filter = ''; | |
| 393 | - if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter'])) | |
| 394 | -                $cat_filter = implode(",", $request_field['cat_filter']);
 | |
| 392 | + $cat_filter = ''; | |
| 393 | + if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter'])) | |
| 394 | +				$cat_filter = implode(",", $request_field['cat_filter']);
 | |
| 395 | 395 | |
| 396 | - if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) | |
| 397 | -                $price_pkg = implode(",", $request_field['show_on_pkg']);
 | |
| 398 | -            else {
 | |
| 399 | - $package_info = array(); | |
| 396 | + if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) | |
| 397 | +				$price_pkg = implode(",", $request_field['show_on_pkg']);
 | |
| 398 | +			else {
 | |
| 399 | + $package_info = array(); | |
| 400 | 400 | |
| 401 | - $package_info = geodir_post_package_info($package_info, '', $post_type); | |
| 402 | - $price_pkg = $package_info->pid; | |
| 403 | - } | |
| 401 | + $package_info = geodir_post_package_info($package_info, '', $post_type); | |
| 402 | + $price_pkg = $package_info->pid; | |
| 403 | + } | |
| 404 | 404 | |
| 405 | 405 | |
| 406 | - if (isset($request_field['extra']) && !empty($request_field['extra'])) | |
| 407 | - $extra_fields = $request_field['extra']; | |
| 406 | + if (isset($request_field['extra']) && !empty($request_field['extra'])) | |
| 407 | + $extra_fields = $request_field['extra']; | |
| 408 | 408 | |
| 409 | - if (isset($request_field['is_default']) && $request_field['is_default'] != '') | |
| 410 | - $is_default = $request_field['is_default']; | |
| 411 | - else | |
| 412 | - $is_default = '0'; | |
| 409 | + if (isset($request_field['is_default']) && $request_field['is_default'] != '') | |
| 410 | + $is_default = $request_field['is_default']; | |
| 411 | + else | |
| 412 | + $is_default = '0'; | |
| 413 | 413 | |
| 414 | - if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') | |
| 415 | - $is_admin = $request_field['is_admin']; | |
| 416 | - else | |
| 417 | - $is_admin = '0'; | |
| 414 | + if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') | |
| 415 | + $is_admin = $request_field['is_admin']; | |
| 416 | + else | |
| 417 | + $is_admin = '0'; | |
| 418 | 418 | |
| 419 | 419 | |
| 420 | - if ($is_active == '') $is_active = 1; | |
| 421 | - if ($is_required == '') $is_required = 0; | |
| 420 | + if ($is_active == '') $is_active = 1; | |
| 421 | + if ($is_required == '') $is_required = 0; | |
| 422 | 422 | |
| 423 | 423 | |
| 424 | -            if ($sort_order == '') {
 | |
| 424 | +			if ($sort_order == '') {
 | |
| 425 | 425 | |
| 426 | -                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
 | |
| 426 | +				$last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
 | |
| 427 | 427 | |
| 428 | - $sort_order = (int)$last_order + 1; | |
| 429 | - } | |
| 428 | + $sort_order = (int)$last_order + 1; | |
| 429 | + } | |
| 430 | 430 | |
| 431 | - $default_value_add = ''; | |
| 431 | + $default_value_add = ''; | |
| 432 | 432 | |
| 433 | 433 | |
| 434 | -            if (!empty($post_meta_info)) {
 | |
| 435 | - switch ($field_type): | |
| 434 | +			if (!empty($post_meta_info)) {
 | |
| 435 | + switch ($field_type): | |
| 436 | 436 | |
| 437 | - case 'address': | |
| 437 | + case 'address': | |
| 438 | 438 | |
| 439 | -                        if ($htmlvar_name != '') {
 | |
| 440 | - $prefix = $htmlvar_name . '_'; | |
| 441 | - } | |
| 442 | - $old_prefix = $old_html_variable . '_'; | |
| 439 | +						if ($htmlvar_name != '') {
 | |
| 440 | + $prefix = $htmlvar_name . '_'; | |
| 441 | + } | |
| 442 | + $old_prefix = $old_html_variable . '_'; | |
| 443 | 443 | |
| 444 | 444 | |
| 445 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; | |
| 445 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; | |
| 446 | 446 | |
| 447 | -                        if ($default_value != '') {
 | |
| 448 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 449 | - } | |
| 447 | +						if ($default_value != '') {
 | |
| 448 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 449 | + } | |
| 450 | 450 | |
| 451 | - $wpdb->query($meta_field_add); | |
| 451 | + $wpdb->query($meta_field_add); | |
| 452 | 452 | |
| 453 | -                        if ($extra_fields != '') {
 | |
| 453 | +						if ($extra_fields != '') {
 | |
| 454 | 454 | |
| 455 | -                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
 | |
| 455 | +							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
 | |
| 456 | 456 | |
| 457 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
 | |
| 458 | -                                if ($is_column) {
 | |
| 459 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; | |
| 457 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
 | |
| 458 | +								if ($is_column) {
 | |
| 459 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; | |
| 460 | 460 | |
| 461 | -                                    if ($default_value != '') {
 | |
| 462 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 463 | - } | |
| 461 | +									if ($default_value != '') {
 | |
| 462 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 463 | + } | |
| 464 | 464 | |
| 465 | - $wpdb->query($meta_field_add); | |
| 466 | -                                } else {
 | |
| 465 | + $wpdb->query($meta_field_add); | |
| 466 | +								} else {
 | |
| 467 | 467 | |
| 468 | - $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 469 | -                                    if ($default_value != '') {
 | |
| 470 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 471 | - } | |
| 472 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); | |
| 468 | + $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 469 | +									if ($default_value != '') {
 | |
| 470 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 471 | + } | |
| 472 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); | |
| 473 | 473 | |
| 474 | - } | |
| 474 | + } | |
| 475 | 475 | |
| 476 | 476 | |
| 477 | - } | |
| 477 | + } | |
| 478 | 478 | |
| 479 | 479 | |
| 480 | -                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
 | |
| 480 | +							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
 | |
| 481 | 481 | |
| 482 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
 | |
| 482 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
 | |
| 483 | 483 | |
| 484 | -                                if ($is_column) {
 | |
| 485 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; | |
| 484 | +								if ($is_column) {
 | |
| 485 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; | |
| 486 | 486 | |
| 487 | -                                    if ($default_value != '') {
 | |
| 488 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 489 | - } | |
| 487 | +									if ($default_value != '') {
 | |
| 488 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 489 | + } | |
| 490 | 490 | |
| 491 | - $wpdb->query($meta_field_add); | |
| 492 | -                                } else {
 | |
| 493 | - $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 494 | -                                    if ($default_value != '') {
 | |
| 495 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 496 | - } | |
| 491 | + $wpdb->query($meta_field_add); | |
| 492 | +								} else {
 | |
| 493 | + $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 494 | +									if ($default_value != '') {
 | |
| 495 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 496 | + } | |
| 497 | 497 | |
| 498 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); | |
| 499 | - } | |
| 498 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); | |
| 499 | + } | |
| 500 | 500 | |
| 501 | - } | |
| 502 | -                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
 | |
| 501 | + } | |
| 502 | +							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
 | |
| 503 | 503 | |
| 504 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
 | |
| 504 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
 | |
| 505 | 505 | |
| 506 | -                                if ($is_column) {
 | |
| 506 | +								if ($is_column) {
 | |
| 507 | 507 | |
| 508 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; | |
| 508 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; | |
| 509 | 509 | |
| 510 | -                                    if ($default_value != '') {
 | |
| 511 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 512 | - } | |
| 510 | +									if ($default_value != '') {
 | |
| 511 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 512 | + } | |
| 513 | 513 | |
| 514 | - $wpdb->query($meta_field_add); | |
| 515 | -                                } else {
 | |
| 514 | + $wpdb->query($meta_field_add); | |
| 515 | +								} else {
 | |
| 516 | 516 | |
| 517 | - $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 518 | -                                    if ($default_value != '') {
 | |
| 519 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 520 | - } | |
| 517 | + $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 518 | +									if ($default_value != '') {
 | |
| 519 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 520 | + } | |
| 521 | 521 | |
| 522 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); | |
| 522 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); | |
| 523 | 523 | |
| 524 | - } | |
| 524 | + } | |
| 525 | 525 | |
| 526 | - } | |
| 527 | -                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
 | |
| 526 | + } | |
| 527 | +							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
 | |
| 528 | 528 | |
| 529 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
 | |
| 529 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
 | |
| 530 | 530 | |
| 531 | -                                if ($is_column) {
 | |
| 531 | +								if ($is_column) {
 | |
| 532 | 532 | |
| 533 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; | |
| 533 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; | |
| 534 | 534 | |
| 535 | -                                    if ($default_value != '') {
 | |
| 536 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 537 | - } | |
| 535 | +									if ($default_value != '') {
 | |
| 536 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 537 | + } | |
| 538 | 538 | |
| 539 | - $wpdb->query($meta_field_add); | |
| 540 | -                                } else {
 | |
| 539 | + $wpdb->query($meta_field_add); | |
| 540 | +								} else {
 | |
| 541 | 541 | |
| 542 | - $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 543 | -                                    if ($default_value != '') {
 | |
| 544 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 545 | - } | |
| 542 | + $meta_field_add = "VARCHAR( 50 ) NULL"; | |
| 543 | +									if ($default_value != '') {
 | |
| 544 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 545 | + } | |
| 546 | 546 | |
| 547 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); | |
| 547 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); | |
| 548 | 548 | |
| 549 | - } | |
| 549 | + } | |
| 550 | 550 | |
| 551 | - } | |
| 552 | -                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
 | |
| 551 | + } | |
| 552 | +							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
 | |
| 553 | 553 | |
| 554 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
 | |
| 555 | -                                if ($is_column) {
 | |
| 554 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
 | |
| 555 | +								if ($is_column) {
 | |
| 556 | 556 | |
| 557 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; | |
| 557 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; | |
| 558 | 558 | |
| 559 | -                                    if ($default_value != '') {
 | |
| 560 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 561 | - } | |
| 559 | +									if ($default_value != '') {
 | |
| 560 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 561 | + } | |
| 562 | 562 | |
| 563 | - $wpdb->query($meta_field_add); | |
| 564 | -                                } else {
 | |
| 563 | + $wpdb->query($meta_field_add); | |
| 564 | +								} else {
 | |
| 565 | 565 | |
| 566 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; | |
| 567 | - $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 568 | -                                    if ($default_value != '') {
 | |
| 569 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 570 | - } | |
| 566 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; | |
| 567 | + $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 568 | +									if ($default_value != '') {
 | |
| 569 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 570 | + } | |
| 571 | 571 | |
| 572 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); | |
| 572 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); | |
| 573 | 573 | |
| 574 | - } | |
| 574 | + } | |
| 575 | 575 | |
| 576 | 576 | |
| 577 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
 | |
| 577 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
 | |
| 578 | 578 | |
| 579 | -                                if ($is_column) {
 | |
| 580 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; | |
| 579 | +								if ($is_column) {
 | |
| 580 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; | |
| 581 | 581 | |
| 582 | -                                    if ($default_value != '') {
 | |
| 583 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 584 | - } | |
| 582 | +									if ($default_value != '') {
 | |
| 583 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 584 | + } | |
| 585 | 585 | |
| 586 | - $wpdb->query($meta_field_add); | |
| 587 | -                                } else {
 | |
| 586 | + $wpdb->query($meta_field_add); | |
| 587 | +								} else {
 | |
| 588 | 588 | |
| 589 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; | |
| 590 | - $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 591 | -                                    if ($default_value != '') {
 | |
| 592 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 593 | - } | |
| 589 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; | |
| 590 | + $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 591 | +									if ($default_value != '') {
 | |
| 592 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 593 | + } | |
| 594 | + | |
| 595 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); | |
| 596 | + } | |
| 597 | + | |
| 598 | + } | |
| 599 | +							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
 | |
| 594 | 600 | |
| 595 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); | |
| 596 | - } | |
| 601 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
 | |
| 597 | 602 | |
| 598 | - } | |
| 599 | -                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
 | |
| 603 | +								if ($is_column) {
 | |
| 604 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; | |
| 600 | 605 | |
| 601 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
 | |
| 606 | +									if ($default_value != '') {
 | |
| 607 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 608 | + } | |
| 602 | 609 | |
| 603 | -                                if ($is_column) {
 | |
| 604 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; | |
| 610 | + $wpdb->query($meta_field_add); | |
| 611 | +								} else {
 | |
| 605 | 612 | |
| 606 | -                                    if ($default_value != '') {
 | |
| 607 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 608 | - } | |
| 613 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; | |
| 609 | 614 | |
| 610 | - $wpdb->query($meta_field_add); | |
| 611 | -                                } else {
 | |
| 615 | + $meta_field_add = "VARCHAR( 15 ) NULL"; | |
| 616 | +									if ($default_value != '') {
 | |
| 617 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 618 | + } | |
| 612 | 619 | |
| 613 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; | |
| 620 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); | |
| 621 | + } | |
| 614 | 622 | |
| 615 | - $meta_field_add = "VARCHAR( 15 ) NULL"; | |
| 616 | -                                    if ($default_value != '') {
 | |
| 617 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 618 | - } | |
| 619 | 623 | |
| 620 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); | |
| 621 | - } | |
| 624 | + } | |
| 625 | +							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
 | |
| 622 | 626 | |
| 627 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
 | |
| 628 | +								if ($is_column) {
 | |
| 629 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; | |
| 623 | 630 | |
| 624 | - } | |
| 625 | -                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
 | |
| 631 | +									if ($default_value != '') {
 | |
| 632 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 633 | + } | |
| 634 | + | |
| 635 | + $wpdb->query($meta_field_add); | |
| 636 | + | |
| 637 | +								} else {
 | |
| 638 | + | |
| 639 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; | |
| 640 | + | |
| 641 | + $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 642 | +									if ($default_value != '') {
 | |
| 643 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 644 | + } | |
| 645 | + | |
| 646 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); | |
| 647 | + } | |
| 648 | + | |
| 649 | + } | |
| 650 | + // show lat lng | |
| 651 | +							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
 | |
| 652 | +								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
 | |
| 626 | 653 | |
| 627 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
 | |
| 628 | -                                if ($is_column) {
 | |
| 629 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; | |
| 654 | +								if ($is_column) {
 | |
| 655 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; | |
| 656 | + $meta_field_add .= " DEFAULT '1'"; | |
| 630 | 657 | |
| 631 | -                                    if ($default_value != '') {
 | |
| 632 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 633 | - } | |
| 658 | + $wpdb->query($meta_field_add); | |
| 659 | +								} else {
 | |
| 660 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; | |
| 634 | 661 | |
| 635 | - $wpdb->query($meta_field_add); | |
| 662 | + $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 663 | + $meta_field_add .= " DEFAULT '1'"; | |
| 636 | 664 | |
| 637 | -                                } else {
 | |
| 665 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); | |
| 666 | + } | |
| 638 | 667 | |
| 639 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; | |
| 668 | + } | |
| 669 | + }// end extra | |
| 640 | 670 | |
| 641 | - $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 642 | -                                    if ($default_value != '') {
 | |
| 643 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 644 | - } | |
| 671 | + break; | |
| 645 | 672 | |
| 646 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); | |
| 647 | - } | |
| 673 | + case 'checkbox': | |
| 674 | + case 'multiselect': | |
| 675 | + case 'select': | |
| 676 | + case 'taxonomy': | |
| 648 | 677 | |
| 649 | - } | |
| 650 | - // show lat lng | |
| 651 | -                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
 | |
| 652 | -                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
 | |
| 678 | + $op_size = '500'; | |
| 653 | 679 | |
| 654 | -                                if ($is_column) {
 | |
| 655 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; | |
| 656 | - $meta_field_add .= " DEFAULT '1'"; | |
| 680 | + // only make the field as big as it needs to be. | |
| 681 | +						if(isset($option_values) && $option_values && $field_type=='select'){
 | |
| 682 | +							$option_values_arr = explode(',',$option_values);
 | |
| 683 | +							if(is_array($option_values_arr)){
 | |
| 684 | + $op_max = 0; | |
| 685 | +								foreach($option_values_arr as $op_val){
 | |
| 686 | +									if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
 | |
| 687 | + } | |
| 688 | +								if($op_max){$op_size =$op_max; }
 | |
| 689 | + } | |
| 690 | +						}elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
 | |
| 691 | +							if(strlen($option_values)){
 | |
| 692 | + $op_size = strlen($option_values); | |
| 693 | + } | |
| 694 | + } | |
| 657 | 695 | |
| 658 | - $wpdb->query($meta_field_add); | |
| 659 | -                                } else {
 | |
| 660 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; | |
| 696 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; | |
| 661 | 697 | |
| 662 | - $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 663 | - $meta_field_add .= " DEFAULT '1'"; | |
| 698 | +						if ($default_value != '') {
 | |
| 699 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 700 | + } | |
| 664 | 701 | |
| 665 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); | |
| 666 | - } | |
| 702 | + $alter_result = $wpdb->query($meta_field_add); | |
| 703 | +						if($alter_result===false){
 | |
| 704 | +							return __('Column change failed, you may have too many columns.','geodirectory');
 | |
| 705 | + } | |
| 667 | 706 | |
| 668 | - } | |
| 669 | - }// end extra | |
| 707 | + if (isset($request_field['cat_display_type'])) | |
| 708 | + $extra_fields = $request_field['cat_display_type']; | |
| 670 | 709 | |
| 671 | - break; | |
| 710 | + if (isset($request_field['multi_display_type'])) | |
| 711 | + $extra_fields = $request_field['multi_display_type']; | |
| 672 | 712 | |
| 673 | - case 'checkbox': | |
| 674 | - case 'multiselect': | |
| 675 | - case 'select': | |
| 676 | - case 'taxonomy': | |
| 677 | 713 | |
| 678 | - $op_size = '500'; | |
| 714 | + break; | |
| 679 | 715 | |
| 680 | - // only make the field as big as it needs to be. | |
| 681 | -                        if(isset($option_values) && $option_values && $field_type=='select'){
 | |
| 682 | -                            $option_values_arr = explode(',',$option_values);
 | |
| 683 | -                            if(is_array($option_values_arr)){
 | |
| 684 | - $op_max = 0; | |
| 685 | -                                foreach($option_values_arr as $op_val){
 | |
| 686 | -                                    if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
 | |
| 687 | - } | |
| 688 | -                                if($op_max){$op_size =$op_max; }
 | |
| 689 | - } | |
| 690 | -                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
 | |
| 691 | -                            if(strlen($option_values)){
 | |
| 692 | - $op_size = strlen($option_values); | |
| 693 | - } | |
| 694 | - } | |
| 716 | + case 'textarea': | |
| 717 | + case 'html': | |
| 718 | + case 'url': | |
| 719 | + case 'file': | |
| 695 | 720 | |
| 696 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; | |
| 721 | +						$alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
 | |
| 722 | +						if($alter_result===false){
 | |
| 723 | +							return __('Column change failed, you may have too many columns.','geodirectory');
 | |
| 724 | + } | |
| 725 | + if (isset($request_field['advanced_editor'])) | |
| 726 | + $extra_fields = $request_field['advanced_editor']; | |
| 697 | 727 | |
| 698 | -                        if ($default_value != '') {
 | |
| 699 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 700 | - } | |
| 728 | + break; | |
| 701 | 729 | |
| 702 | - $alter_result = $wpdb->query($meta_field_add); | |
| 703 | -                        if($alter_result===false){
 | |
| 704 | -                            return __('Column change failed, you may have too many columns.','geodirectory');
 | |
| 705 | - } | |
| 730 | + case 'fieldset': | |
| 731 | + // Nothig happend for fieldset | |
| 732 | + break; | |
| 706 | 733 | |
| 707 | - if (isset($request_field['cat_display_type'])) | |
| 708 | - $extra_fields = $request_field['cat_display_type']; | |
| 734 | + default: | |
| 735 | +						if ($data_type != 'VARCHAR' && $data_type != '') {
 | |
| 736 | +							if ($data_type == 'FLOAT' && $decimal_point > 0) {
 | |
| 737 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; | |
| 738 | +							} else {
 | |
| 739 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; | |
| 740 | + } | |
| 709 | 741 | |
| 710 | - if (isset($request_field['multi_display_type'])) | |
| 711 | - $extra_fields = $request_field['multi_display_type']; | |
| 742 | +							if (is_numeric($default_value) && $default_value != '') {
 | |
| 743 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 744 | + } | |
| 745 | +						} else {
 | |
| 746 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; | |
| 747 | +							if ($default_value != '') {
 | |
| 748 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 749 | + } | |
| 750 | + } | |
| 712 | 751 | |
| 752 | + $alter_result = $wpdb->query($default_value_add); | |
| 753 | +						if($alter_result===false){
 | |
| 754 | +							return __('Column change failed, you may have too many columns.','geodirectory');
 | |
| 755 | + } | |
| 756 | + break; | |
| 757 | + endswitch; | |
| 713 | 758 | |
| 714 | - break; | |
| 759 | + $extra_field_query = ''; | |
| 760 | +				if (!empty($extra_fields)) {
 | |
| 761 | + $extra_field_query = serialize($extra_fields); | |
| 762 | + } | |
| 715 | 763 | |
| 716 | - case 'textarea': | |
| 717 | - case 'html': | |
| 718 | - case 'url': | |
| 719 | - case 'file': | |
| 764 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; | |
| 720 | 765 | |
| 721 | -                        $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
 | |
| 722 | -                        if($alter_result===false){
 | |
| 723 | -                            return __('Column change failed, you may have too many columns.','geodirectory');
 | |
| 724 | - } | |
| 725 | - if (isset($request_field['advanced_editor'])) | |
| 726 | - $extra_fields = $request_field['advanced_editor']; | |
| 727 | - | |
| 728 | - break; | |
| 766 | + $wpdb->query( | |
| 729 | 767 | |
| 730 | - case 'fieldset': | |
| 731 | - // Nothig happend for fieldset | |
| 732 | - break; | |
| 768 | + $wpdb->prepare( | |
| 733 | 769 | |
| 734 | - default: | |
| 735 | -                        if ($data_type != 'VARCHAR' && $data_type != '') {
 | |
| 736 | -                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
 | |
| 737 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; | |
| 738 | -                            } else {
 | |
| 739 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; | |
| 740 | - } | |
| 741 | - | |
| 742 | -                            if (is_numeric($default_value) && $default_value != '') {
 | |
| 743 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 744 | - } | |
| 745 | -                        } else {
 | |
| 746 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; | |
| 747 | -                            if ($default_value != '') {
 | |
| 748 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 749 | - } | |
| 750 | - } | |
| 751 | - | |
| 752 | - $alter_result = $wpdb->query($default_value_add); | |
| 753 | -                        if($alter_result===false){
 | |
| 754 | -                            return __('Column change failed, you may have too many columns.','geodirectory');
 | |
| 755 | - } | |
| 756 | - break; | |
| 757 | - endswitch; | |
| 758 | - | |
| 759 | - $extra_field_query = ''; | |
| 760 | -                if (!empty($extra_fields)) {
 | |
| 761 | - $extra_field_query = serialize($extra_fields); | |
| 762 | - } | |
| 763 | - | |
| 764 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; | |
| 765 | - | |
| 766 | - $wpdb->query( | |
| 767 | - | |
| 768 | - $wpdb->prepare( | |
| 769 | - | |
| 770 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set | |
| 770 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set | |
| 771 | 771 | post_type = %s, | 
| 772 | 772 | admin_title = %s, | 
| 773 | 773 | site_title = %s, | 
| @@ -799,308 +799,308 @@ discard block | ||
| 799 | 799 | for_admin_use = %s | 
| 800 | 800 | where id = %d", | 
| 801 | 801 | |
| 802 | - array($post_type, $admin_title, $site_title, $field_type, $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_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) | |
| 803 | - ) | |
| 802 | + array($post_type, $admin_title, $site_title, $field_type, $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_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) | |
| 803 | + ) | |
| 804 | 804 | |
| 805 | - ); | |
| 805 | + ); | |
| 806 | 806 | |
| 807 | - $lastid = trim($cf); | |
| 807 | + $lastid = trim($cf); | |
| 808 | 808 | |
| 809 | 809 | |
| 810 | - $wpdb->query( | |
| 811 | - $wpdb->prepare( | |
| 812 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 810 | + $wpdb->query( | |
| 811 | + $wpdb->prepare( | |
| 812 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 813 | 813 | site_title=%s | 
| 814 | 814 | where post_type = %s and htmlvar_name = %s", | 
| 815 | - array($site_title, $post_type, $htmlvar_name) | |
| 816 | - ) | |
| 817 | - ); | |
| 818 | - | |
| 819 | - | |
| 820 | - if ($cat_sort == '') | |
| 821 | -                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
 | |
| 822 | - | |
| 823 | - | |
| 824 | - /** | |
| 825 | - * Called after all custom fields are saved for a post. | |
| 826 | - * | |
| 827 | - * @since 1.0.0 | |
| 828 | - * @param int $lastid The post ID. | |
| 829 | - */ | |
| 830 | -                do_action('geodir_after_custom_fields_updated', $lastid);
 | |
| 831 | - | |
| 832 | -            } else {
 | |
| 833 | - | |
| 834 | - switch ($field_type): | |
| 835 | - | |
| 836 | - case 'address': | |
| 837 | - | |
| 838 | - $data_type = ''; | |
| 839 | - | |
| 840 | -                        if ($htmlvar_name != '') {
 | |
| 841 | - $prefix = $htmlvar_name . '_'; | |
| 842 | - } | |
| 843 | - $old_prefix = $old_html_variable; | |
| 844 | - | |
| 845 | - //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; | |
| 846 | - | |
| 847 | - $meta_field_add = "VARCHAR( 254 ) NULL"; | |
| 848 | -                        if ($default_value != '') {
 | |
| 849 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 850 | - } | |
| 851 | - | |
| 852 | - geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); | |
| 853 | - //$wpdb->query($meta_field_add); | |
| 854 | - | |
| 855 | - | |
| 856 | -                        if (!empty($extra_fields)) {
 | |
| 815 | + array($site_title, $post_type, $htmlvar_name) | |
| 816 | + ) | |
| 817 | + ); | |
| 818 | + | |
| 819 | + | |
| 820 | + if ($cat_sort == '') | |
| 821 | +					$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
 | |
| 822 | + | |
| 823 | + | |
| 824 | + /** | |
| 825 | + * Called after all custom fields are saved for a post. | |
| 826 | + * | |
| 827 | + * @since 1.0.0 | |
| 828 | + * @param int $lastid The post ID. | |
| 829 | + */ | |
| 830 | +				do_action('geodir_after_custom_fields_updated', $lastid);
 | |
| 831 | + | |
| 832 | +			} else {
 | |
| 833 | + | |
| 834 | + switch ($field_type): | |
| 835 | + | |
| 836 | + case 'address': | |
| 837 | + | |
| 838 | + $data_type = ''; | |
| 839 | + | |
| 840 | +						if ($htmlvar_name != '') {
 | |
| 841 | + $prefix = $htmlvar_name . '_'; | |
| 842 | + } | |
| 843 | + $old_prefix = $old_html_variable; | |
| 844 | + | |
| 845 | + //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; | |
| 846 | + | |
| 847 | + $meta_field_add = "VARCHAR( 254 ) NULL"; | |
| 848 | +						if ($default_value != '') {
 | |
| 849 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 850 | + } | |
| 851 | + | |
| 852 | + geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); | |
| 853 | + //$wpdb->query($meta_field_add); | |
| 854 | + | |
| 855 | + | |
| 856 | +						if (!empty($extra_fields)) {
 | |
| 857 | + | |
| 858 | +							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
 | |
| 859 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; | |
| 860 | + $meta_field_add = "VARCHAR( 30 ) NULL"; | |
| 861 | +								if ($default_value != '') {
 | |
| 862 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 863 | + } | |
| 864 | + | |
| 865 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); | |
| 866 | + //$wpdb->query($meta_field_add); | |
| 867 | + } | |
| 868 | +							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
 | |
| 869 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; | |
| 870 | + $meta_field_add = "VARCHAR( 30 ) NULL"; | |
| 871 | +								if ($default_value != '') {
 | |
| 872 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 873 | + } | |
| 874 | + | |
| 875 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); | |
| 876 | + //$wpdb->query($meta_field_add); | |
| 877 | + } | |
| 878 | +							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
 | |
| 879 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; | |
| 880 | + | |
| 881 | + $meta_field_add = "VARCHAR( 30 ) NULL"; | |
| 882 | +								if ($default_value != '') {
 | |
| 883 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 884 | + } | |
| 885 | + | |
| 886 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); | |
| 887 | + //$wpdb->query($meta_field_add); | |
| 888 | + } | |
| 889 | +							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
 | |
| 890 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; | |
| 891 | + $meta_field_add = "VARCHAR( 15 ) NULL"; | |
| 892 | +								if ($default_value != '') {
 | |
| 893 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 894 | + } | |
| 895 | + | |
| 896 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); | |
| 897 | + //$wpdb->query($meta_field_add); | |
| 898 | + } | |
| 899 | +							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
 | |
| 900 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; | |
| 901 | + $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 902 | +								if ($default_value != '') {
 | |
| 903 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 904 | + } | |
| 905 | + | |
| 906 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); | |
| 907 | + //$wpdb->query($meta_field_add); | |
| 908 | + | |
| 909 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; | |
| 857 | 910 | |
| 858 | -                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
 | |
| 859 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; | |
| 860 | - $meta_field_add = "VARCHAR( 30 ) NULL"; | |
| 861 | -                                if ($default_value != '') {
 | |
| 862 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 863 | - } | |
| 864 | - | |
| 865 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); | |
| 866 | - //$wpdb->query($meta_field_add); | |
| 867 | - } | |
| 868 | -                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
 | |
| 869 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; | |
| 870 | - $meta_field_add = "VARCHAR( 30 ) NULL"; | |
| 871 | -                                if ($default_value != '') {
 | |
| 872 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 873 | - } | |
| 874 | - | |
| 875 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); | |
| 876 | - //$wpdb->query($meta_field_add); | |
| 877 | - } | |
| 878 | -                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
 | |
| 879 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; | |
| 880 | - | |
| 881 | - $meta_field_add = "VARCHAR( 30 ) NULL"; | |
| 882 | -                                if ($default_value != '') {
 | |
| 883 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 884 | - } | |
| 885 | - | |
| 886 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); | |
| 887 | - //$wpdb->query($meta_field_add); | |
| 888 | - } | |
| 889 | -                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
 | |
| 890 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; | |
| 891 | - $meta_field_add = "VARCHAR( 15 ) NULL"; | |
| 892 | -                                if ($default_value != '') {
 | |
| 893 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 894 | - } | |
| 895 | - | |
| 896 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); | |
| 897 | - //$wpdb->query($meta_field_add); | |
| 898 | - } | |
| 899 | -                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
 | |
| 900 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; | |
| 901 | - $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 902 | -                                if ($default_value != '') {
 | |
| 903 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 904 | - } | |
| 905 | - | |
| 906 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); | |
| 907 | - //$wpdb->query($meta_field_add); | |
| 908 | - | |
| 909 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; | |
| 910 | - | |
| 911 | - $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 912 | -                                if ($default_value != '') {
 | |
| 913 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 914 | - } | |
| 915 | - | |
| 916 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); | |
| 917 | - | |
| 918 | - //$wpdb->query($meta_field_add); | |
| 919 | - } | |
| 920 | -                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
 | |
| 921 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; | |
| 922 | - | |
| 923 | - $meta_field_add = "VARCHAR( 15 ) NULL"; | |
| 924 | -                                if ($default_value != '') {
 | |
| 925 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 926 | - } | |
| 927 | - | |
| 928 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); | |
| 929 | - | |
| 930 | - //$wpdb->query($meta_field_add); | |
| 931 | - } | |
| 932 | -                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
 | |
| 933 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; | |
| 934 | - | |
| 935 | - $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 936 | -                                if ($default_value != '') {
 | |
| 937 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 938 | - } | |
| 939 | - | |
| 940 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); | |
| 941 | - | |
| 942 | - //$wpdb->query($meta_field_add); | |
| 943 | - } | |
| 944 | - // show lat lng | |
| 945 | -                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
 | |
| 946 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; | |
| 947 | - | |
| 948 | - $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 949 | - $meta_field_add .= " DEFAULT '1'"; | |
| 950 | - | |
| 951 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); | |
| 952 | - //$wpdb->query($meta_field_add); | |
| 953 | - } | |
| 954 | - } | |
| 955 | - | |
| 956 | - break; | |
| 957 | - | |
| 958 | - case 'checkbox': | |
| 959 | - $data_type = 'TINYINT'; | |
| 960 | - | |
| 961 | - $meta_field_add = $data_type . "( 1 ) NOT NULL "; | |
| 962 | -                        if ((int)$default_value === 1) {
 | |
| 963 | - $meta_field_add .= " DEFAULT '1'"; | |
| 964 | - } | |
| 965 | - | |
| 966 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 967 | -                        if ($add_result === false) {
 | |
| 968 | -                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 969 | - } | |
| 970 | - break; | |
| 971 | - case 'multiselect': | |
| 972 | - case 'select': | |
| 973 | - $data_type = 'VARCHAR'; | |
| 974 | - $op_size = '500'; | |
| 975 | - | |
| 976 | - // only make the field as big as it needs to be. | |
| 977 | -                        if (isset($option_values) && $option_values && $field_type == 'select') {
 | |
| 978 | -                            $option_values_arr = explode(',', $option_values);
 | |
| 979 | - | |
| 980 | -                            if (is_array($option_values_arr)) {
 | |
| 981 | - $op_max = 0; | |
| 982 | - | |
| 983 | -                                foreach ($option_values_arr as $op_val) {
 | |
| 984 | -                                    if (strlen($op_val) && strlen($op_val) > $op_max) {
 | |
| 985 | - $op_max = strlen($op_val); | |
| 986 | - } | |
| 987 | - } | |
| 988 | - | |
| 989 | -                                if ($op_max) {
 | |
| 990 | - $op_size = $op_max; | |
| 991 | - } | |
| 992 | - } | |
| 993 | -                        } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
 | |
| 994 | -                            if (strlen($option_values)) {
 | |
| 995 | - $op_size = strlen($option_values); | |
| 996 | - } | |
| 997 | - | |
| 998 | -                            if (isset($request_field['multi_display_type'])) {
 | |
| 999 | - $extra_fields = $request_field['multi_display_type']; | |
| 1000 | - } | |
| 1001 | - } | |
| 1002 | - | |
| 1003 | - $meta_field_add = $data_type . "( $op_size ) NULL "; | |
| 1004 | -                        if ($default_value != '') {
 | |
| 1005 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 1006 | - } | |
| 1007 | - | |
| 1008 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1009 | -                        if ($add_result === false) {
 | |
| 1010 | -                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 1011 | - } | |
| 1012 | - break; | |
| 1013 | - case 'textarea': | |
| 1014 | - case 'html': | |
| 1015 | - case 'url': | |
| 1016 | - case 'file': | |
| 1017 | - | |
| 1018 | - $data_type = 'TEXT'; | |
| 1019 | - | |
| 1020 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; | |
| 1021 | - | |
| 1022 | - $meta_field_add = $data_type . " NULL "; | |
| 1023 | - /*if($default_value != '') | |
| 911 | + $meta_field_add = "VARCHAR( 20 ) NULL"; | |
| 912 | +								if ($default_value != '') {
 | |
| 913 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 914 | + } | |
| 915 | + | |
| 916 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); | |
| 917 | + | |
| 918 | + //$wpdb->query($meta_field_add); | |
| 919 | + } | |
| 920 | +							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
 | |
| 921 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; | |
| 922 | + | |
| 923 | + $meta_field_add = "VARCHAR( 15 ) NULL"; | |
| 924 | +								if ($default_value != '') {
 | |
| 925 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 926 | + } | |
| 927 | + | |
| 928 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); | |
| 929 | + | |
| 930 | + //$wpdb->query($meta_field_add); | |
| 931 | + } | |
| 932 | +							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
 | |
| 933 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; | |
| 934 | + | |
| 935 | + $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 936 | +								if ($default_value != '') {
 | |
| 937 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 938 | + } | |
| 939 | + | |
| 940 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); | |
| 941 | + | |
| 942 | + //$wpdb->query($meta_field_add); | |
| 943 | + } | |
| 944 | + // show lat lng | |
| 945 | +							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
 | |
| 946 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; | |
| 947 | + | |
| 948 | + $meta_field_add = "VARCHAR( 3 ) NULL"; | |
| 949 | + $meta_field_add .= " DEFAULT '1'"; | |
| 950 | + | |
| 951 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); | |
| 952 | + //$wpdb->query($meta_field_add); | |
| 953 | + } | |
| 954 | + } | |
| 955 | + | |
| 956 | + break; | |
| 957 | + | |
| 958 | + case 'checkbox': | |
| 959 | + $data_type = 'TINYINT'; | |
| 960 | + | |
| 961 | + $meta_field_add = $data_type . "( 1 ) NOT NULL "; | |
| 962 | +						if ((int)$default_value === 1) {
 | |
| 963 | + $meta_field_add .= " DEFAULT '1'"; | |
| 964 | + } | |
| 965 | + | |
| 966 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 967 | +						if ($add_result === false) {
 | |
| 968 | +							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 969 | + } | |
| 970 | + break; | |
| 971 | + case 'multiselect': | |
| 972 | + case 'select': | |
| 973 | + $data_type = 'VARCHAR'; | |
| 974 | + $op_size = '500'; | |
| 975 | + | |
| 976 | + // only make the field as big as it needs to be. | |
| 977 | +						if (isset($option_values) && $option_values && $field_type == 'select') {
 | |
| 978 | +							$option_values_arr = explode(',', $option_values);
 | |
| 979 | + | |
| 980 | +							if (is_array($option_values_arr)) {
 | |
| 981 | + $op_max = 0; | |
| 982 | + | |
| 983 | +								foreach ($option_values_arr as $op_val) {
 | |
| 984 | +									if (strlen($op_val) && strlen($op_val) > $op_max) {
 | |
| 985 | + $op_max = strlen($op_val); | |
| 986 | + } | |
| 987 | + } | |
| 988 | + | |
| 989 | +								if ($op_max) {
 | |
| 990 | + $op_size = $op_max; | |
| 991 | + } | |
| 992 | + } | |
| 993 | +						} elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
 | |
| 994 | +							if (strlen($option_values)) {
 | |
| 995 | + $op_size = strlen($option_values); | |
| 996 | + } | |
| 997 | + | |
| 998 | +							if (isset($request_field['multi_display_type'])) {
 | |
| 999 | + $extra_fields = $request_field['multi_display_type']; | |
| 1000 | + } | |
| 1001 | + } | |
| 1002 | + | |
| 1003 | + $meta_field_add = $data_type . "( $op_size ) NULL "; | |
| 1004 | +						if ($default_value != '') {
 | |
| 1005 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 1006 | + } | |
| 1007 | + | |
| 1008 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1009 | +						if ($add_result === false) {
 | |
| 1010 | +							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 1011 | + } | |
| 1012 | + break; | |
| 1013 | + case 'textarea': | |
| 1014 | + case 'html': | |
| 1015 | + case 'url': | |
| 1016 | + case 'file': | |
| 1017 | + | |
| 1018 | + $data_type = 'TEXT'; | |
| 1019 | + | |
| 1020 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; | |
| 1021 | + | |
| 1022 | + $meta_field_add = $data_type . " NULL "; | |
| 1023 | + /*if($default_value != '') | |
| 1024 | 1024 |  					{ $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
 | 
| 1025 | 1025 | |
| 1026 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1027 | -                        if ($add_result === false) {
 | |
| 1028 | -                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 1029 | - } | |
| 1026 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1027 | +						if ($add_result === false) {
 | |
| 1028 | +							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 1029 | + } | |
| 1030 | 1030 | |
| 1031 | - break; | |
| 1031 | + break; | |
| 1032 | 1032 | |
| 1033 | - case 'datepicker': | |
| 1033 | + case 'datepicker': | |
| 1034 | 1034 | |
| 1035 | - $data_type = 'DATE'; | |
| 1035 | + $data_type = 'DATE'; | |
| 1036 | 1036 | |
| 1037 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; | |
| 1037 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; | |
| 1038 | 1038 | |
| 1039 | - $meta_field_add = $data_type . " NULL "; | |
| 1039 | + $meta_field_add = $data_type . " NULL "; | |
| 1040 | 1040 | |
| 1041 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1042 | -                        if ($add_result === false) {
 | |
| 1043 | -                            return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
 | |
| 1044 | - } | |
| 1041 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1042 | +						if ($add_result === false) {
 | |
| 1043 | +							return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
 | |
| 1044 | + } | |
| 1045 | 1045 | |
| 1046 | - break; | |
| 1046 | + break; | |
| 1047 | 1047 | |
| 1048 | - case 'time': | |
| 1048 | + case 'time': | |
| 1049 | 1049 | |
| 1050 | - $data_type = 'TIME'; | |
| 1050 | + $data_type = 'TIME'; | |
| 1051 | 1051 | |
| 1052 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; | |
| 1052 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; | |
| 1053 | 1053 | |
| 1054 | - $meta_field_add = $data_type . " NULL "; | |
| 1054 | + $meta_field_add = $data_type . " NULL "; | |
| 1055 | 1055 | |
| 1056 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1057 | -                        if ($add_result === false) {
 | |
| 1058 | -                            return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
 | |
| 1059 | - } | |
| 1056 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1057 | +						if ($add_result === false) {
 | |
| 1058 | +							return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
 | |
| 1059 | + } | |
| 1060 | 1060 | |
| 1061 | - break; | |
| 1061 | + break; | |
| 1062 | 1062 | |
| 1063 | - default: | |
| 1063 | + default: | |
| 1064 | 1064 | |
| 1065 | -                        if ($data_type != 'VARCHAR' && $data_type != '') {
 | |
| 1066 | - $meta_field_add = $data_type . " NULL "; | |
| 1065 | +						if ($data_type != 'VARCHAR' && $data_type != '') {
 | |
| 1066 | + $meta_field_add = $data_type . " NULL "; | |
| 1067 | 1067 | |
| 1068 | -                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
 | |
| 1069 | - $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; | |
| 1070 | - } | |
| 1068 | +							if ($data_type == 'FLOAT' && $decimal_point > 0) {
 | |
| 1069 | + $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; | |
| 1070 | + } | |
| 1071 | 1071 | |
| 1072 | -                            if (is_numeric($default_value) && $default_value != '') {
 | |
| 1073 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 1074 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 1075 | - } | |
| 1076 | -                        } else {
 | |
| 1077 | - $meta_field_add = " VARCHAR( 254 ) NULL "; | |
| 1072 | +							if (is_numeric($default_value) && $default_value != '') {
 | |
| 1073 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 1074 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 1075 | + } | |
| 1076 | +						} else {
 | |
| 1077 | + $meta_field_add = " VARCHAR( 254 ) NULL "; | |
| 1078 | 1078 | |
| 1079 | -                            if ($default_value != '') {
 | |
| 1080 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 1081 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 1082 | - } | |
| 1083 | - } | |
| 1079 | +							if ($default_value != '') {
 | |
| 1080 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; | |
| 1081 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; | |
| 1082 | + } | |
| 1083 | + } | |
| 1084 | 1084 | |
| 1085 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1086 | -                        if ($add_result === false) {
 | |
| 1087 | -                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 1088 | - } | |
| 1089 | - break; | |
| 1090 | - endswitch; | |
| 1085 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); | |
| 1086 | +						if ($add_result === false) {
 | |
| 1087 | +							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
 | |
| 1088 | + } | |
| 1089 | + break; | |
| 1090 | + endswitch; | |
| 1091 | 1091 | |
| 1092 | - $extra_field_query = ''; | |
| 1093 | -                if (!empty($extra_fields)) {
 | |
| 1094 | - $extra_field_query = serialize($extra_fields); | |
| 1095 | - } | |
| 1092 | + $extra_field_query = ''; | |
| 1093 | +				if (!empty($extra_fields)) {
 | |
| 1094 | + $extra_field_query = serialize($extra_fields); | |
| 1095 | + } | |
| 1096 | 1096 | |
| 1097 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; | |
| 1097 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; | |
| 1098 | 1098 | |
| 1099 | - $wpdb->query( | |
| 1099 | + $wpdb->query( | |
| 1100 | 1100 | |
| 1101 | - $wpdb->prepare( | |
| 1101 | + $wpdb->prepare( | |
| 1102 | 1102 | |
| 1103 | - "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set | |
| 1103 | + "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set | |
| 1104 | 1104 | post_type = %s, | 
| 1105 | 1105 | admin_title = %s, | 
| 1106 | 1106 | site_title = %s, | 
| @@ -1131,26 +1131,26 @@ discard block | ||
| 1131 | 1131 | validation_msg = %s, | 
| 1132 | 1132 | for_admin_use = %s ", | 
| 1133 | 1133 | |
| 1134 | - array($post_type, $admin_title, $site_title, $field_type, $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_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) | |
| 1134 | + array($post_type, $admin_title, $site_title, $field_type, $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_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) | |
| 1135 | 1135 | |
| 1136 | - ) | |
| 1136 | + ) | |
| 1137 | 1137 | |
| 1138 | - ); | |
| 1138 | + ); | |
| 1139 | 1139 | |
| 1140 | - $lastid = $wpdb->insert_id; | |
| 1140 | + $lastid = $wpdb->insert_id; | |
| 1141 | 1141 | |
| 1142 | - $lastid = trim($lastid); | |
| 1142 | + $lastid = trim($lastid); | |
| 1143 | 1143 | |
| 1144 | - } | |
| 1144 | + } | |
| 1145 | 1145 | |
| 1146 | - return (int)$lastid; | |
| 1146 | + return (int)$lastid; | |
| 1147 | 1147 | |
| 1148 | 1148 | |
| 1149 | -        } else {
 | |
| 1150 | - return 'HTML Variable Name should be a unique name'; | |
| 1151 | - } | |
| 1149 | +		} else {
 | |
| 1150 | + return 'HTML Variable Name should be a unique name'; | |
| 1151 | + } | |
| 1152 | 1152 | |
| 1153 | - } | |
| 1153 | + } | |
| 1154 | 1154 | } | 
| 1155 | 1155 | |
| 1156 | 1156 | /** | 
| @@ -1165,30 +1165,30 @@ discard block | ||
| 1165 | 1165 | function godir_set_field_order($field_ids = array()) | 
| 1166 | 1166 |  {
 | 
| 1167 | 1167 | |
| 1168 | - global $wpdb; | |
| 1168 | + global $wpdb; | |
| 1169 | 1169 | |
| 1170 | - $count = 0; | |
| 1171 | - if (!empty($field_ids)): | |
| 1172 | - $post_meta_info = false; | |
| 1173 | -        foreach ($field_ids as $id) {
 | |
| 1170 | + $count = 0; | |
| 1171 | + if (!empty($field_ids)): | |
| 1172 | + $post_meta_info = false; | |
| 1173 | +		foreach ($field_ids as $id) {
 | |
| 1174 | 1174 | |
| 1175 | - $cf = trim($id, '_'); | |
| 1175 | + $cf = trim($id, '_'); | |
| 1176 | 1176 | |
| 1177 | - $post_meta_info = $wpdb->query( | |
| 1178 | - $wpdb->prepare( | |
| 1179 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set | |
| 1177 | + $post_meta_info = $wpdb->query( | |
| 1178 | + $wpdb->prepare( | |
| 1179 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set | |
| 1180 | 1180 | sort_order=%d | 
| 1181 | 1181 | where id= %d", | 
| 1182 | - array($count, $cf) | |
| 1183 | - ) | |
| 1184 | - ); | |
| 1185 | - $count++; | |
| 1186 | - } | |
| 1187 | - | |
| 1188 | - return $post_meta_info; | |
| 1189 | - else: | |
| 1190 | - return false; | |
| 1191 | - endif; | |
| 1182 | + array($count, $cf) | |
| 1183 | + ) | |
| 1184 | + ); | |
| 1185 | + $count++; | |
| 1186 | + } | |
| 1187 | + | |
| 1188 | + return $post_meta_info; | |
| 1189 | + else: | |
| 1190 | + return false; | |
| 1191 | + endif; | |
| 1192 | 1192 | } | 
| 1193 | 1193 | |
| 1194 | 1194 | |
| @@ -1208,140 +1208,140 @@ discard block | ||
| 1208 | 1208 | * @param string $post_type Optional. The wordpress post type. | 
| 1209 | 1209 | */ | 
| 1210 | 1210 |  function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') {
 | 
| 1211 | - global $is_default, $mapzoom, $gd_session; | |
| 1212 | - | |
| 1213 | - $show_editors = array(); | |
| 1214 | - $listing_type = $post_type; | |
| 1215 | - | |
| 1216 | - $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); | |
| 1217 | - | |
| 1218 | - $fieldset_id = ''; | |
| 1219 | - $fieldset_field_class = 'gd-fieldset-details'; | |
| 1220 | -    foreach ($custom_fields as $key => $val) {
 | |
| 1221 | - $val = stripslashes_deep($val); // strip slashes from labels | |
| 1222 | - $name = $val['name']; | |
| 1223 | - $site_title = $val['site_title']; | |
| 1224 | - $type = $val['type']; | |
| 1225 | - $admin_desc = $val['desc']; | |
| 1226 | - $option_values = $val['option_values']; | |
| 1227 | - $is_required = $val['is_required']; | |
| 1228 | - $is_default = $val['is_default']; | |
| 1229 | - $is_admin = $val['is_admin']; | |
| 1230 | - $required_msg = $val['required_msg']; | |
| 1231 | - $extra_fields = unserialize($val['extra_fields']); | |
| 1232 | - $value = ''; | |
| 1233 | - | |
| 1234 | - /* field available to site admin only for edit */ | |
| 1235 | - $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; | |
| 1236 | -        if ($for_admin_use && !is_super_admin()) {
 | |
| 1237 | - continue; | |
| 1238 | - } | |
| 1239 | - | |
| 1240 | -        if (is_admin()) {
 | |
| 1241 | - global $post; | |
| 1242 | - | |
| 1243 | - if (isset($_REQUEST['post'])) | |
| 1244 | - $_REQUEST['pid'] = $_REQUEST['post']; | |
| 1245 | - } | |
| 1246 | - | |
| 1247 | -        if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
 | |
| 1248 | - $post = $gd_ses_listing; | |
| 1249 | - $value = isset($post[$name]) ? $post[$name] : ''; | |
| 1250 | -        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | |
| 1251 | - $value = geodir_get_post_meta($_REQUEST['pid'], $name, true); | |
| 1252 | -        } else {
 | |
| 1253 | -            if ($value == '') {
 | |
| 1254 | - $value = $val['default']; | |
| 1255 | - } | |
| 1256 | - } | |
| 1257 | - | |
| 1258 | - /** | |
| 1259 | - * Called before the custom fields info is output for submitting a post. | |
| 1260 | - * | |
| 1261 | - * Used dynamic hook type geodir_before_custom_form_field_$name. | |
| 1262 | - * | |
| 1263 | - * @since 1.0.0 | |
| 1264 | - * @param string $listing_type The post post type. | |
| 1265 | - * @param int $package_id The price package ID for the post. | |
| 1266 | -         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
 | |
| 1267 | - * @see 'geodir_after_custom_form_field_$name' | |
| 1268 | - */ | |
| 1269 | -        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
 | |
| 1270 | - | |
| 1271 | -        if ($type == 'fieldset') {
 | |
| 1272 | - $fieldset_id = (int)$val['id']; | |
| 1273 | - $fieldset_field_class = 'gd-fieldset-' . $fieldset_id; | |
| 1274 | - ?> | |
| 1211 | + global $is_default, $mapzoom, $gd_session; | |
| 1212 | + | |
| 1213 | + $show_editors = array(); | |
| 1214 | + $listing_type = $post_type; | |
| 1215 | + | |
| 1216 | + $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); | |
| 1217 | + | |
| 1218 | + $fieldset_id = ''; | |
| 1219 | + $fieldset_field_class = 'gd-fieldset-details'; | |
| 1220 | +	foreach ($custom_fields as $key => $val) {
 | |
| 1221 | + $val = stripslashes_deep($val); // strip slashes from labels | |
| 1222 | + $name = $val['name']; | |
| 1223 | + $site_title = $val['site_title']; | |
| 1224 | + $type = $val['type']; | |
| 1225 | + $admin_desc = $val['desc']; | |
| 1226 | + $option_values = $val['option_values']; | |
| 1227 | + $is_required = $val['is_required']; | |
| 1228 | + $is_default = $val['is_default']; | |
| 1229 | + $is_admin = $val['is_admin']; | |
| 1230 | + $required_msg = $val['required_msg']; | |
| 1231 | + $extra_fields = unserialize($val['extra_fields']); | |
| 1232 | + $value = ''; | |
| 1233 | + | |
| 1234 | + /* field available to site admin only for edit */ | |
| 1235 | + $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; | |
| 1236 | +		if ($for_admin_use && !is_super_admin()) {
 | |
| 1237 | + continue; | |
| 1238 | + } | |
| 1239 | + | |
| 1240 | +		if (is_admin()) {
 | |
| 1241 | + global $post; | |
| 1242 | + | |
| 1243 | + if (isset($_REQUEST['post'])) | |
| 1244 | + $_REQUEST['pid'] = $_REQUEST['post']; | |
| 1245 | + } | |
| 1246 | + | |
| 1247 | +		if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
 | |
| 1248 | + $post = $gd_ses_listing; | |
| 1249 | + $value = isset($post[$name]) ? $post[$name] : ''; | |
| 1250 | +		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | |
| 1251 | + $value = geodir_get_post_meta($_REQUEST['pid'], $name, true); | |
| 1252 | +		} else {
 | |
| 1253 | +			if ($value == '') {
 | |
| 1254 | + $value = $val['default']; | |
| 1255 | + } | |
| 1256 | + } | |
| 1257 | + | |
| 1258 | + /** | |
| 1259 | + * Called before the custom fields info is output for submitting a post. | |
| 1260 | + * | |
| 1261 | + * Used dynamic hook type geodir_before_custom_form_field_$name. | |
| 1262 | + * | |
| 1263 | + * @since 1.0.0 | |
| 1264 | + * @param string $listing_type The post post type. | |
| 1265 | + * @param int $package_id The price package ID for the post. | |
| 1266 | +		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
 | |
| 1267 | + * @see 'geodir_after_custom_form_field_$name' | |
| 1268 | + */ | |
| 1269 | +		do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
 | |
| 1270 | + | |
| 1271 | +		if ($type == 'fieldset') {
 | |
| 1272 | + $fieldset_id = (int)$val['id']; | |
| 1273 | + $fieldset_field_class = 'gd-fieldset-' . $fieldset_id; | |
| 1274 | + ?> | |
| 1275 | 1275 | <h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?> | 
| 1276 | 1276 | <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?></h5> | 
| 1277 | 1277 | <?php | 
| 1278 | -        } else if ($type == 'address') {
 | |
| 1279 | - $prefix = $name . '_'; | |
| 1280 | - | |
| 1281 | - ($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address'); | |
| 1282 | - ($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code '); | |
| 1283 | -            ($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map');
 | |
| 1284 | - ($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview'); | |
| 1285 | - | |
| 1286 | - $address = ''; | |
| 1287 | - $zip = ''; | |
| 1288 | - $mapview = ''; | |
| 1289 | - $mapzoom = ''; | |
| 1290 | - $lat = ''; | |
| 1291 | - $lng = ''; | |
| 1292 | - | |
| 1293 | -            if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
 | |
| 1294 | - $post = $gd_ses_listing; | |
| 1295 | - $address = $post[$prefix . 'address']; | |
| 1296 | - $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : ''; | |
| 1297 | - $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : ''; | |
| 1298 | - $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : ''; | |
| 1299 | - $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : ''; | |
| 1300 | - $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : ''; | |
| 1301 | -            } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
 | |
| 1302 | - $post_info = (array)$post_info; | |
| 1303 | - | |
| 1304 | - $address = $post_info[$prefix . 'address']; | |
| 1305 | - $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : ''; | |
| 1306 | - $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : ''; | |
| 1307 | - $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : ''; | |
| 1308 | - $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : ''; | |
| 1309 | - $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : ''; | |
| 1310 | - } | |
| 1311 | - | |
| 1312 | - $location = geodir_get_default_location(); | |
| 1313 | - if (empty($city)) $city = isset($location->city) ? $location->city : ''; | |
| 1314 | - if (empty($region)) $region = isset($location->region) ? $location->region : ''; | |
| 1315 | - if (empty($country)) $country = isset($location->country) ? $location->country : ''; | |
| 1316 | - | |
| 1317 | - $lat_lng_blank = false; | |
| 1318 | -            if (empty($lat) && empty($lng)) {
 | |
| 1319 | - $lat_lng_blank = true; | |
| 1320 | - } | |
| 1321 | - | |
| 1322 | - if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : ''; | |
| 1323 | - if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : ''; | |
| 1324 | - | |
| 1325 | - /** | |
| 1326 | - * Filter the default latitude. | |
| 1327 | - * | |
| 1328 | - * @since 1.0.0 | |
| 1329 | - * | |
| 1330 | - * @param float $lat Default latitude. | |
| 1331 | - * @param bool $is_admin For admin use only?. | |
| 1332 | - */ | |
| 1333 | -            $lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
 | |
| 1334 | - /** | |
| 1335 | - * Filter the default longitude. | |
| 1336 | - * | |
| 1337 | - * @since 1.0.0 | |
| 1338 | - * | |
| 1339 | - * @param float $lat Default longitude. | |
| 1340 | - * @param bool $is_admin For admin use only?. | |
| 1341 | - */ | |
| 1342 | -            $lng = apply_filters('geodir_default_longitude', $lng, $is_admin);
 | |
| 1343 | - | |
| 1344 | - ?> | |
| 1278 | +		} else if ($type == 'address') {
 | |
| 1279 | + $prefix = $name . '_'; | |
| 1280 | + | |
| 1281 | + ($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address'); | |
| 1282 | + ($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code '); | |
| 1283 | +			($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map');
 | |
| 1284 | + ($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview'); | |
| 1285 | + | |
| 1286 | + $address = ''; | |
| 1287 | + $zip = ''; | |
| 1288 | + $mapview = ''; | |
| 1289 | + $mapzoom = ''; | |
| 1290 | + $lat = ''; | |
| 1291 | + $lng = ''; | |
| 1292 | + | |
| 1293 | +			if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
 | |
| 1294 | + $post = $gd_ses_listing; | |
| 1295 | + $address = $post[$prefix . 'address']; | |
| 1296 | + $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : ''; | |
| 1297 | + $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : ''; | |
| 1298 | + $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : ''; | |
| 1299 | + $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : ''; | |
| 1300 | + $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : ''; | |
| 1301 | +			} else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
 | |
| 1302 | + $post_info = (array)$post_info; | |
| 1303 | + | |
| 1304 | + $address = $post_info[$prefix . 'address']; | |
| 1305 | + $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : ''; | |
| 1306 | + $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : ''; | |
| 1307 | + $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : ''; | |
| 1308 | + $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : ''; | |
| 1309 | + $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : ''; | |
| 1310 | + } | |
| 1311 | + | |
| 1312 | + $location = geodir_get_default_location(); | |
| 1313 | + if (empty($city)) $city = isset($location->city) ? $location->city : ''; | |
| 1314 | + if (empty($region)) $region = isset($location->region) ? $location->region : ''; | |
| 1315 | + if (empty($country)) $country = isset($location->country) ? $location->country : ''; | |
| 1316 | + | |
| 1317 | + $lat_lng_blank = false; | |
| 1318 | +			if (empty($lat) && empty($lng)) {
 | |
| 1319 | + $lat_lng_blank = true; | |
| 1320 | + } | |
| 1321 | + | |
| 1322 | + if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : ''; | |
| 1323 | + if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : ''; | |
| 1324 | + | |
| 1325 | + /** | |
| 1326 | + * Filter the default latitude. | |
| 1327 | + * | |
| 1328 | + * @since 1.0.0 | |
| 1329 | + * | |
| 1330 | + * @param float $lat Default latitude. | |
| 1331 | + * @param bool $is_admin For admin use only?. | |
| 1332 | + */ | |
| 1333 | +			$lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
 | |
| 1334 | + /** | |
| 1335 | + * Filter the default longitude. | |
| 1336 | + * | |
| 1337 | + * @since 1.0.0 | |
| 1338 | + * | |
| 1339 | + * @param float $lat Default longitude. | |
| 1340 | + * @param bool $is_admin For admin use only?. | |
| 1341 | + */ | |
| 1342 | +			$lng = apply_filters('geodir_default_longitude', $lng, $is_admin);
 | |
| 1343 | + | |
| 1344 | + ?> | |
| 1345 | 1345 | |
| 1346 | 1346 | <div id="geodir_<?php echo $prefix . 'address';?>_row" | 
| 1347 | 1347 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| @@ -1360,17 +1360,17 @@ discard block | ||
| 1360 | 1360 | |
| 1361 | 1361 | |
| 1362 | 1362 | <?php | 
| 1363 | - /** | |
| 1364 | - * Called after the address input on the add listings. | |
| 1365 | - * | |
| 1366 | - * This is used by the location manage to add further locations info etc. | |
| 1367 | - * | |
| 1368 | - * @since 1.0.0 | |
| 1369 | -             * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}.
 | |
| 1370 | - */ | |
| 1371 | -            do_action('geodir_address_extra_listing_fields', $val);
 | |
| 1372 | - | |
| 1373 | -            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?>
 | |
| 1363 | + /** | |
| 1364 | + * Called after the address input on the add listings. | |
| 1365 | + * | |
| 1366 | + * This is used by the location manage to add further locations info etc. | |
| 1367 | + * | |
| 1368 | + * @since 1.0.0 | |
| 1369 | +			 * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}.
 | |
| 1370 | + */ | |
| 1371 | +			do_action('geodir_address_extra_listing_fields', $val);
 | |
| 1372 | + | |
| 1373 | +			if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?>
 | |
| 1374 | 1374 | |
| 1375 | 1375 | <div id="geodir_<?php echo $prefix . 'zip'; ?>_row" | 
| 1376 | 1376 | class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| @@ -1391,22 +1391,22 @@ discard block | ||
| 1391 | 1391 | |
| 1392 | 1392 | <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1393 | 1393 | <?php | 
| 1394 | - /** | |
| 1395 | - * Contains add listing page map functions. | |
| 1396 | - * | |
| 1397 | - * @since 1.0.0 | |
| 1398 | - */ | |
| 1399 | - include(geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php"); | |
| 1400 | -                    if ($lat_lng_blank) {
 | |
| 1401 | - $lat = ''; | |
| 1402 | - $lng = ''; | |
| 1403 | - } | |
| 1404 | - ?> | |
| 1394 | + /** | |
| 1395 | + * Contains add listing page map functions. | |
| 1396 | + * | |
| 1397 | + * @since 1.0.0 | |
| 1398 | + */ | |
| 1399 | + include(geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php"); | |
| 1400 | +					if ($lat_lng_blank) {
 | |
| 1401 | + $lat = ''; | |
| 1402 | + $lng = ''; | |
| 1403 | + } | |
| 1404 | + ?> | |
| 1405 | 1405 | <span class="geodir_message_note"><?php echo GET_MAP_MSG; ?></span> | 
| 1406 | 1406 | </div> | 
| 1407 | 1407 | <?php | 
| 1408 | - /* show lat lng */ | |
| 1409 | - $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?> | |
| 1408 | + /* show lat lng */ | |
| 1409 | + $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?> | |
| 1410 | 1410 | <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row" | 
| 1411 | 1411 | class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> | 
| 1412 | 1412 | <label> | 
| @@ -1447,27 +1447,27 @@ discard block | ||
| 1447 | 1447 | class="gd-checkbox" | 
| 1448 | 1448 | name="<?php echo $prefix . 'mapview'; ?>" | 
| 1449 | 1449 |                                                              id="<?php echo $prefix . 'mapview'; ?>" <?php if ($mapview == 'ROADMAP' || $mapview == '') {
 | 
| 1450 | - echo 'checked="checked"'; | |
| 1451 | -                        } ?>  value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?></span>
 | |
| 1450 | + echo 'checked="checked"'; | |
| 1451 | +						} ?>  value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?></span>
 | |
| 1452 | 1452 | <span class="geodir_user_define"> <input field_type="<?php echo $type; ?>" type="radio" | 
| 1453 | 1453 | class="gd-checkbox" | 
| 1454 | 1454 | name="<?php echo $prefix . 'mapview'; ?>" | 
| 1455 | 1455 |                                                               id="map_view1" <?php if ($mapview == 'SATELLITE') {
 | 
| 1456 | - echo 'checked="checked"'; | |
| 1457 | -                        } ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?></span>
 | |
| 1456 | + echo 'checked="checked"'; | |
| 1457 | +						} ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?></span>
 | |
| 1458 | 1458 | |
| 1459 | 1459 | <span class="geodir_user_define"><input field_type="<?php echo $type; ?>" type="radio" | 
| 1460 | 1460 | class="gd-checkbox" | 
| 1461 | 1461 | name="<?php echo $prefix . 'mapview'; ?>" | 
| 1462 | 1462 |                                                              id="map_view2" <?php if ($mapview == 'HYBRID') {
 | 
| 1463 | - echo 'checked="checked"'; | |
| 1464 | -                        } ?>  value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?></span>
 | |
| 1463 | + echo 'checked="checked"'; | |
| 1464 | +						} ?>  value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?></span>
 | |
| 1465 | 1465 | <span class="geodir_user_define"><input field_type="<?php echo $type; ?>" type="radio" | 
| 1466 | 1466 | class="gd-checkbox" | 
| 1467 | 1467 | name="<?php echo $prefix . 'mapview'; ?>" | 
| 1468 | 1468 |                                                              id="map_view3" <?php if ($mapview == 'TERRAIN') {
 | 
| 1469 | - echo 'checked="checked"'; | |
| 1470 | -                        } ?>  value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?></span>
 | |
| 1469 | + echo 'checked="checked"'; | |
| 1470 | +						} ?>  value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?></span>
 | |
| 1471 | 1471 | |
| 1472 | 1472 | |
| 1473 | 1473 | </div> | 
| @@ -1475,31 +1475,31 @@ discard block | ||
| 1475 | 1475 | |
| 1476 | 1476 |              <?php if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { ?>
 | 
| 1477 | 1477 |                  <input type="hidden" value="<?php if (isset($mapzoom)) {
 | 
| 1478 | - echo esc_attr($mapzoom); | |
| 1479 | - } ?>" name="<?php echo $prefix . 'mapzoom'; ?>" id="<?php echo $prefix . 'mapzoom'; ?>"/> | |
| 1478 | + echo esc_attr($mapzoom); | |
| 1479 | + } ?>" name="<?php echo $prefix . 'mapzoom'; ?>" id="<?php echo $prefix . 'mapzoom'; ?>"/> | |
| 1480 | 1480 | <?php }?> | 
| 1481 | 1481 |          <?php } elseif ($type == 'text') {
 | 
| 1482 | 1482 | |
| 1483 | - //number and float validation $validation_pattern | |
| 1484 | -            if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
 | |
| 1485 | -            elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
 | |
| 1486 | - //print_r($val); | |
| 1487 | - //validation | |
| 1488 | -            if(isset($val['validation_pattern']) && $val['validation_pattern']){
 | |
| 1489 | - $validation = 'pattern="'.$val['validation_pattern'].'"'; | |
| 1490 | -            }else{$validation='';}
 | |
| 1491 | - | |
| 1492 | - // validation message | |
| 1493 | -            if(isset($val['validation_msg']) && $val['validation_msg']){
 | |
| 1494 | - $validation_msg = 'title="'.$val['validation_msg'].'"'; | |
| 1495 | -            }else{$validation_msg='';}
 | |
| 1496 | - ?> | |
| 1483 | + //number and float validation $validation_pattern | |
| 1484 | +			if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
 | |
| 1485 | +			elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
 | |
| 1486 | + //print_r($val); | |
| 1487 | + //validation | |
| 1488 | +			if(isset($val['validation_pattern']) && $val['validation_pattern']){
 | |
| 1489 | + $validation = 'pattern="'.$val['validation_pattern'].'"'; | |
| 1490 | +			}else{$validation='';}
 | |
| 1491 | + | |
| 1492 | + // validation message | |
| 1493 | +			if(isset($val['validation_msg']) && $val['validation_msg']){
 | |
| 1494 | + $validation_msg = 'title="'.$val['validation_msg'].'"'; | |
| 1495 | +			}else{$validation_msg='';}
 | |
| 1496 | + ?> | |
| 1497 | 1497 | |
| 1498 | 1498 | <div id="<?php echo $name;?>_row" | 
| 1499 | 1499 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1500 | 1500 | <label> | 
| 1501 | 1501 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1502 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1502 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1503 | 1503 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1504 | 1504 | </label> | 
| 1505 | 1505 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" | 
| @@ -1511,15 +1511,15 @@ discard block | ||
| 1511 | 1511 | </div> | 
| 1512 | 1512 | |
| 1513 | 1513 |          <?php } elseif ($type == 'email') {
 | 
| 1514 | -            if ($value == $val['default']) {
 | |
| 1515 | - $value = ''; | |
| 1516 | - }?> | |
| 1514 | +			if ($value == $val['default']) {
 | |
| 1515 | + $value = ''; | |
| 1516 | + }?> | |
| 1517 | 1517 | |
| 1518 | 1518 | <div id="<?php echo $name;?>_row" | 
| 1519 | 1519 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1520 | 1520 | <label> | 
| 1521 | 1521 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1522 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1522 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1523 | 1523 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1524 | 1524 | </label> | 
| 1525 | 1525 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" | 
| @@ -1531,15 +1531,15 @@ discard block | ||
| 1531 | 1531 | </div> | 
| 1532 | 1532 | |
| 1533 | 1533 |          <?php } elseif ($type == 'phone') {
 | 
| 1534 | -            if ($value == $val['default']) {
 | |
| 1535 | - $value = ''; | |
| 1536 | - } ?> | |
| 1534 | +			if ($value == $val['default']) {
 | |
| 1535 | + $value = ''; | |
| 1536 | + } ?> | |
| 1537 | 1537 | |
| 1538 | 1538 | <div id="<?php echo $name;?>_row" | 
| 1539 | 1539 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1540 | 1540 | <label> | 
| 1541 | 1541 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1542 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1542 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1543 | 1543 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1544 | 1544 | </label> | 
| 1545 | 1545 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" | 
| @@ -1551,15 +1551,15 @@ discard block | ||
| 1551 | 1551 | </div> | 
| 1552 | 1552 | |
| 1553 | 1553 |          <?php } elseif ($type == 'url') {
 | 
| 1554 | -            if ($value == $val['default']) {
 | |
| 1555 | - $value = ''; | |
| 1556 | - }?> | |
| 1554 | +			if ($value == $val['default']) {
 | |
| 1555 | + $value = ''; | |
| 1556 | + }?> | |
| 1557 | 1557 | |
| 1558 | 1558 | <div id="<?php echo $name;?>_row" | 
| 1559 | 1559 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1560 | 1560 | <label> | 
| 1561 | 1561 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1562 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1562 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1563 | 1563 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1564 | 1564 | </label> | 
| 1565 | 1565 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" | 
| @@ -1578,23 +1578,23 @@ discard block | ||
| 1578 | 1578 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1579 | 1579 | <label> | 
| 1580 | 1580 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1581 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1581 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1582 | 1582 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1583 | 1583 | </label> | 
| 1584 | 1584 |                  <?php if ($option_values) {
 | 
| 1585 | - $option_values = geodir_string_values_to_options($option_values, true); | |
| 1585 | + $option_values = geodir_string_values_to_options($option_values, true); | |
| 1586 | 1586 | |
| 1587 | -                    if (!empty($option_values)) {
 | |
| 1588 | -                        foreach ($option_values as $option_value) {
 | |
| 1589 | -                            if (empty($option_value['optgroup'])) {
 | |
| 1590 | - ?> | |
| 1587 | +					if (!empty($option_values)) {
 | |
| 1588 | +						foreach ($option_values as $option_value) {
 | |
| 1589 | +							if (empty($option_value['optgroup'])) {
 | |
| 1590 | + ?> | |
| 1591 | 1591 | <span class="gd-radios"><input name="<?php echo $name;?>" id="<?php echo $name;?>" <?php checked($value, $option_value['value']);?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $type;?>" type="radio" /><?php echo $option_value['label']; ?></span> | 
| 1592 | 1592 | <?php | 
| 1593 | - } | |
| 1594 | - } | |
| 1595 | - } | |
| 1596 | - } | |
| 1597 | - ?> | |
| 1593 | + } | |
| 1594 | + } | |
| 1595 | + } | |
| 1596 | + } | |
| 1597 | + ?> | |
| 1598 | 1598 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> | 
| 1599 | 1599 |                  <?php if ($is_required) { ?>
 | 
| 1600 | 1600 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> | 
| @@ -1607,16 +1607,16 @@ discard block | ||
| 1607 | 1607 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1608 | 1608 | <label> | 
| 1609 | 1609 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1610 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1610 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1611 | 1611 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1612 | 1612 | </label> | 
| 1613 | 1613 |                  <?php if ($value != '1') {
 | 
| 1614 | - $value = '0'; | |
| 1615 | - }?> | |
| 1614 | + $value = '0'; | |
| 1615 | + }?> | |
| 1616 | 1616 | <input type="hidden" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>"/> | 
| 1617 | 1617 |                  <input  <?php if ($value == '1') {
 | 
| 1618 | - echo 'checked="checked"'; | |
| 1619 | - }?> value="1" class="gd-checkbox" field_type="<?php echo $type;?>" type="checkbox" | |
| 1618 | + echo 'checked="checked"'; | |
| 1619 | + }?> value="1" class="gd-checkbox" field_type="<?php echo $type;?>" type="checkbox" | |
| 1620 | 1620 |                       onchange="if(this.checked){jQuery('#<?php echo $name;?>').val('1');} else{ jQuery('#<?php echo $name;?>').val('0');}"/>
 | 
| 1621 | 1621 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> | 
| 1622 | 1622 |                  <?php if ($is_required) { ?>
 | 
| @@ -1625,31 +1625,31 @@ discard block | ||
| 1625 | 1625 | </div> | 
| 1626 | 1626 | |
| 1627 | 1627 |          <?php } elseif ($type == 'textarea') {
 | 
| 1628 | - ?> | |
| 1628 | + ?> | |
| 1629 | 1629 | |
| 1630 | 1630 | <div id="<?php echo $name;?>_row" | 
| 1631 | 1631 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1632 | 1632 | <label> | 
| 1633 | 1633 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1634 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1634 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1635 | 1635 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1636 | 1636 | </label><?php | 
| 1637 | 1637 | |
| 1638 | 1638 | |
| 1639 | -                if (is_array($extra_fields) && in_array('1', $extra_fields)) {
 | |
| 1639 | +				if (is_array($extra_fields) && in_array('1', $extra_fields)) {
 | |
| 1640 | 1640 | |
| 1641 | -                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?>
 | |
| 1641 | +					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?>
 | |
| 1642 | 1642 | |
| 1643 | 1643 | <div class="editor" field_id="<?php echo $name;?>" field_type="editor"> | 
| 1644 | 1644 | <?php wp_editor(stripslashes($value), $name, $editor_settings); ?> | 
| 1645 | 1645 | </div><?php | 
| 1646 | 1646 | |
| 1647 | -                } else {
 | |
| 1647 | +				} else {
 | |
| 1648 | 1648 | |
| 1649 | - ?><textarea field_type="<?php echo $type;?>" class="geodir_textarea" name="<?php echo $name;?>" | |
| 1649 | + ?><textarea field_type="<?php echo $type;?>" class="geodir_textarea" name="<?php echo $name;?>" | |
| 1650 | 1650 | id="<?php echo $name;?>"><?php echo stripslashes($value);?></textarea><?php | 
| 1651 | 1651 | |
| 1652 | - }?> | |
| 1652 | + }?> | |
| 1653 | 1653 | |
| 1654 | 1654 | |
| 1655 | 1655 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> | 
| @@ -1663,28 +1663,28 @@ discard block | ||
| 1663 | 1663 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>"> | 
| 1664 | 1664 | <label> | 
| 1665 | 1665 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1666 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1666 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1667 | 1667 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1668 | 1668 | </label> | 
| 1669 | 1669 | <?php | 
| 1670 | - $option_values_arr = geodir_string_values_to_options($option_values, true); | |
| 1671 | - $select_options = ''; | |
| 1672 | -                if (!empty($option_values_arr)) {
 | |
| 1673 | -                    foreach ($option_values_arr as $option_row) {
 | |
| 1674 | -                        if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
 | |
| 1675 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1676 | - | |
| 1677 | - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; | |
| 1678 | -                        } else {
 | |
| 1679 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1680 | - $option_value = isset($option_row['value']) ? $option_row['value'] : ''; | |
| 1681 | - $selected = $option_value == $value ? 'selected="selected"' : ''; | |
| 1682 | - | |
| 1683 | - $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; | |
| 1684 | - } | |
| 1685 | - } | |
| 1686 | - } | |
| 1687 | - ?> | |
| 1670 | + $option_values_arr = geodir_string_values_to_options($option_values, true); | |
| 1671 | + $select_options = ''; | |
| 1672 | +				if (!empty($option_values_arr)) {
 | |
| 1673 | +					foreach ($option_values_arr as $option_row) {
 | |
| 1674 | +						if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
 | |
| 1675 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1676 | + | |
| 1677 | + $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; | |
| 1678 | +						} else {
 | |
| 1679 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1680 | + $option_value = isset($option_row['value']) ? $option_row['value'] : ''; | |
| 1681 | + $selected = $option_value == $value ? 'selected="selected"' : ''; | |
| 1682 | + | |
| 1683 | + $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; | |
| 1684 | + } | |
| 1685 | + } | |
| 1686 | + } | |
| 1687 | + ?> | |
| 1688 | 1688 | <select field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" | 
| 1689 | 1689 | class="geodir_textfield textfield_x chosen_select" | 
| 1690 | 1690 |                          data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '…';?>"
 | 
| @@ -1696,17 +1696,17 @@ discard block | ||
| 1696 | 1696 | </div> | 
| 1697 | 1697 | |
| 1698 | 1698 | <?php | 
| 1699 | -        } else if ($type == 'multiselect') {
 | |
| 1700 | - $multi_display = 'select'; | |
| 1701 | -            if (!empty($val['extra_fields'])) {
 | |
| 1702 | - $multi_display = unserialize($val['extra_fields']); | |
| 1703 | - } | |
| 1704 | - ?> | |
| 1699 | +		} else if ($type == 'multiselect') {
 | |
| 1700 | + $multi_display = 'select'; | |
| 1701 | +			if (!empty($val['extra_fields'])) {
 | |
| 1702 | + $multi_display = unserialize($val['extra_fields']); | |
| 1703 | + } | |
| 1704 | + ?> | |
| 1705 | 1705 | <div id="<?php echo $name; ?>_row" | 
| 1706 | 1706 | class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1707 | 1707 | <label> | 
| 1708 | 1708 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1709 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1709 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1710 | 1710 | <?php if ($is_required) echo '<span>*</span>'; ?> | 
| 1711 | 1711 | </label> | 
| 1712 | 1712 | <input type="hidden" name="gd_field_<?php echo $name; ?>" value="1"/> | 
| @@ -1717,55 +1717,55 @@ discard block | ||
| 1717 | 1717 |                              data-placeholder="<?php _e('Select', 'geodirectory'); ?>"
 | 
| 1718 | 1718 | option-ajaxchosen="false"> | 
| 1719 | 1719 | <?php | 
| 1720 | -                        } else {
 | |
| 1721 | - echo '<ul class="gd_multi_choice">'; | |
| 1722 | - } | |
| 1723 | - | |
| 1724 | - $option_values_arr = geodir_string_values_to_options($option_values, true); | |
| 1725 | - $select_options = ''; | |
| 1726 | -                        if (!empty($option_values_arr)) {
 | |
| 1727 | -                            foreach ($option_values_arr as $option_row) {
 | |
| 1728 | -                                if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
 | |
| 1729 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1730 | - | |
| 1731 | -                                    if ($multi_display == 'select') {
 | |
| 1732 | - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; | |
| 1733 | -                                    } else {
 | |
| 1734 | - $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : ''; | |
| 1735 | - } | |
| 1736 | -                                } else {
 | |
| 1737 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1738 | - $option_value = isset($option_row['value']) ? $option_row['value'] : ''; | |
| 1739 | - $selected = $option_value == $value ? 'selected="selected"' : ''; | |
| 1740 | - $selected = ''; | |
| 1741 | - $checked = ''; | |
| 1742 | - | |
| 1743 | -                                    if ((!is_array($value) && trim($value) != '') || (is_array($value) && !empty($value))) {
 | |
| 1744 | -                                        if (!is_array($value)) {
 | |
| 1745 | -                                            $value_array = explode(',', $value);
 | |
| 1746 | -                                        } else {
 | |
| 1747 | - $value_array = $value; | |
| 1748 | - } | |
| 1749 | - | |
| 1750 | -                                        if (is_array($value_array)) {
 | |
| 1751 | -                                            if (in_array($option_value, $value_array)) {
 | |
| 1752 | - $selected = 'selected="selected"'; | |
| 1753 | - $checked = 'checked="checked"'; | |
| 1754 | - } | |
| 1755 | - } | |
| 1756 | - } | |
| 1757 | - | |
| 1758 | -                                    if ($multi_display == 'select') {
 | |
| 1759 | - $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; | |
| 1760 | -                                    } else {
 | |
| 1761 | - $select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" /> ' . $option_label . ' </li>'; | |
| 1762 | - } | |
| 1763 | - } | |
| 1764 | - } | |
| 1765 | - } | |
| 1766 | - echo $select_options; | |
| 1767 | - | |
| 1768 | -                        if ($multi_display == 'select') { ?></select></div>
 | |
| 1720 | +						} else {
 | |
| 1721 | + echo '<ul class="gd_multi_choice">'; | |
| 1722 | + } | |
| 1723 | + | |
| 1724 | + $option_values_arr = geodir_string_values_to_options($option_values, true); | |
| 1725 | + $select_options = ''; | |
| 1726 | +						if (!empty($option_values_arr)) {
 | |
| 1727 | +							foreach ($option_values_arr as $option_row) {
 | |
| 1728 | +								if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
 | |
| 1729 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1730 | + | |
| 1731 | +									if ($multi_display == 'select') {
 | |
| 1732 | + $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; | |
| 1733 | +									} else {
 | |
| 1734 | + $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : ''; | |
| 1735 | + } | |
| 1736 | +								} else {
 | |
| 1737 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; | |
| 1738 | + $option_value = isset($option_row['value']) ? $option_row['value'] : ''; | |
| 1739 | + $selected = $option_value == $value ? 'selected="selected"' : ''; | |
| 1740 | + $selected = ''; | |
| 1741 | + $checked = ''; | |
| 1742 | + | |
| 1743 | +									if ((!is_array($value) && trim($value) != '') || (is_array($value) && !empty($value))) {
 | |
| 1744 | +										if (!is_array($value)) {
 | |
| 1745 | +											$value_array = explode(',', $value);
 | |
| 1746 | +										} else {
 | |
| 1747 | + $value_array = $value; | |
| 1748 | + } | |
| 1749 | + | |
| 1750 | +										if (is_array($value_array)) {
 | |
| 1751 | +											if (in_array($option_value, $value_array)) {
 | |
| 1752 | + $selected = 'selected="selected"'; | |
| 1753 | + $checked = 'checked="checked"'; | |
| 1754 | + } | |
| 1755 | + } | |
| 1756 | + } | |
| 1757 | + | |
| 1758 | +									if ($multi_display == 'select') {
 | |
| 1759 | + $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; | |
| 1760 | +									} else {
 | |
| 1761 | + $select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" /> ' . $option_label . ' </li>'; | |
| 1762 | + } | |
| 1763 | + } | |
| 1764 | + } | |
| 1765 | + } | |
| 1766 | + echo $select_options; | |
| 1767 | + | |
| 1768 | +						if ($multi_display == 'select') { ?></select></div>
 | |
| 1769 | 1769 |              <?php } else { ?></ul><?php } ?>
 | 
| 1770 | 1770 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> | 
| 1771 | 1771 |                  <?php if ($is_required) { ?>
 | 
| @@ -1773,14 +1773,14 @@ discard block | ||
| 1773 | 1773 | <?php } ?> | 
| 1774 | 1774 | </div> | 
| 1775 | 1775 | <?php | 
| 1776 | -        } else if ($type == 'html') {
 | |
| 1777 | - ?> | |
| 1776 | +		} else if ($type == 'html') {
 | |
| 1777 | + ?> | |
| 1778 | 1778 | |
| 1779 | 1779 | <div id="<?php echo $name; ?>_row" | 
| 1780 | 1780 | class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1781 | 1781 | <label> | 
| 1782 | 1782 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1783 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1783 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1784 | 1784 | <?php if ($is_required) echo '<span>*</span>'; ?> | 
| 1785 | 1785 | </label> | 
| 1786 | 1786 | |
| @@ -1798,44 +1798,44 @@ discard block | ||
| 1798 | 1798 | </div> | 
| 1799 | 1799 |          <?php } elseif ($type == 'datepicker') {
 | 
| 1800 | 1800 | |
| 1801 | - if ($extra_fields['date_format'] == '') | |
| 1802 | - $extra_fields['date_format'] = 'yy-mm-dd'; | |
| 1801 | + if ($extra_fields['date_format'] == '') | |
| 1802 | + $extra_fields['date_format'] = 'yy-mm-dd'; | |
| 1803 | 1803 | |
| 1804 | - $date_format = $extra_fields['date_format']; | |
| 1805 | - $jquery_date_format = $date_format; | |
| 1804 | + $date_format = $extra_fields['date_format']; | |
| 1805 | + $jquery_date_format = $date_format; | |
| 1806 | 1806 | |
| 1807 | 1807 | |
| 1808 | - // check if we need to change the format or not | |
| 1809 | -            $date_format_len = strlen(str_replace(' ', '', $date_format));
 | |
| 1810 | -            if($date_format_len>5){// if greater then 5 then it's the old style format.
 | |
| 1808 | + // check if we need to change the format or not | |
| 1809 | +			$date_format_len = strlen(str_replace(' ', '', $date_format));
 | |
| 1810 | +			if($date_format_len>5){// if greater then 5 then it's the old style format.
 | |
| 1811 | 1811 | |
| 1812 | -                $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
 | |
| 1813 | -                $replace = array('d','j','l','m','n','F','Y');//PHP date format
 | |
| 1812 | +				$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
 | |
| 1813 | +				$replace = array('d','j','l','m','n','F','Y');//PHP date format
 | |
| 1814 | 1814 | |
| 1815 | - $date_format = str_replace($search, $replace, $date_format); | |
| 1816 | -            }else{
 | |
| 1817 | - $jquery_date_format = geodir_date_format_php_to_jqueryui( $jquery_date_format ); | |
| 1818 | - } | |
| 1815 | + $date_format = str_replace($search, $replace, $date_format); | |
| 1816 | +			}else{
 | |
| 1817 | + $jquery_date_format = geodir_date_format_php_to_jqueryui( $jquery_date_format ); | |
| 1818 | + } | |
| 1819 | 1819 | |
| 1820 | -            if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty
 | |
| 1821 | -            if($value && !isset($_REQUEST['backandedit'])) {
 | |
| 1822 | - $time = strtotime($value); | |
| 1823 | - $value = date_i18n($date_format, $time); | |
| 1824 | - } | |
| 1820 | +			if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty
 | |
| 1821 | +			if($value && !isset($_REQUEST['backandedit'])) {
 | |
| 1822 | + $time = strtotime($value); | |
| 1823 | + $value = date_i18n($date_format, $time); | |
| 1824 | + } | |
| 1825 | 1825 | |
| 1826 | - ?> | |
| 1826 | + ?> | |
| 1827 | 1827 | <script type="text/javascript"> | 
| 1828 | 1828 | |
| 1829 | 1829 |                  jQuery(function () {
 | 
| 1830 | 1830 | |
| 1831 | 1831 |                      jQuery("#<?php echo $name;?>").datepicker({changeMonth: true, changeYear: true <?php
 | 
| 1832 | - /** | |
| 1833 | - * Used to add extra option to datepicker per custom field. | |
| 1834 | - * | |
| 1835 | - * @since 1.5.7 | |
| 1836 | - * @param string $name The custom field name. | |
| 1837 | - */ | |
| 1838 | -                        echo apply_filters("gd_datepicker_extra_{$name}",'');?>});
 | |
| 1832 | + /** | |
| 1833 | + * Used to add extra option to datepicker per custom field. | |
| 1834 | + * | |
| 1835 | + * @since 1.5.7 | |
| 1836 | + * @param string $name The custom field name. | |
| 1837 | + */ | |
| 1838 | +						echo apply_filters("gd_datepicker_extra_{$name}",'');?>});
 | |
| 1839 | 1839 | |
| 1840 | 1840 |                      jQuery("#<?php echo $name;?>").datepicker("option", "dateFormat", '<?php echo $jquery_date_format;?>');
 | 
| 1841 | 1841 | |
| @@ -1851,7 +1851,7 @@ discard block | ||
| 1851 | 1851 | <label> | 
| 1852 | 1852 | |
| 1853 | 1853 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1854 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1854 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1855 | 1855 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1856 | 1856 | </label> | 
| 1857 | 1857 | |
| @@ -1866,9 +1866,9 @@ discard block | ||
| 1866 | 1866 | |
| 1867 | 1867 |          <?php } elseif ($type == 'time') {
 | 
| 1868 | 1868 | |
| 1869 | - if ($value != '') | |
| 1870 | -                $value = date('H:i', strtotime($value));
 | |
| 1871 | - ?> | |
| 1869 | + if ($value != '') | |
| 1870 | +				$value = date('H:i', strtotime($value));
 | |
| 1871 | + ?> | |
| 1872 | 1872 | <script type="text/javascript"> | 
| 1873 | 1873 |                  jQuery(document).ready(function () {
 | 
| 1874 | 1874 | |
| @@ -1884,7 +1884,7 @@ discard block | ||
| 1884 | 1884 | <label> | 
| 1885 | 1885 | |
| 1886 | 1886 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1887 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1887 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1888 | 1888 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1889 | 1889 | </label> | 
| 1890 | 1890 | <input readonly="readonly" field_type="<?php echo $type;?>" name="<?php echo $name;?>" | 
| @@ -1897,110 +1897,110 @@ discard block | ||
| 1897 | 1897 | </div> | 
| 1898 | 1898 | |
| 1899 | 1899 |          <?php } elseif ($type == 'taxonomy') {
 | 
| 1900 | -            if ($value == $val['default']) {
 | |
| 1901 | - $value = ''; | |
| 1902 | - } ?> | |
| 1900 | +			if ($value == $val['default']) {
 | |
| 1901 | + $value = ''; | |
| 1902 | + } ?> | |
| 1903 | 1903 | <div id="<?php echo $name;?>_row" | 
| 1904 | 1904 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| 1905 | 1905 | <label> | 
| 1906 | 1906 | <?php $site_title = __($site_title, 'geodirectory'); | 
| 1907 | - echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1907 | + echo (trim($site_title)) ? $site_title : ' '; ?> | |
| 1908 | 1908 | <?php if ($is_required) echo '<span>*</span>';?> | 
| 1909 | 1909 | </label> | 
| 1910 | 1910 | |
| 1911 | 1911 | <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;"> | 
| 1912 | 1912 | <?php | 
| 1913 | - global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats; | |
| 1913 | + global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats; | |
| 1914 | 1914 | |
| 1915 | - $exclude_cats = array(); | |
| 1915 | + $exclude_cats = array(); | |
| 1916 | 1916 | |
| 1917 | -                    if ($is_admin == '1') {
 | |
| 1917 | +					if ($is_admin == '1') {
 | |
| 1918 | 1918 | |
| 1919 | - $post_type = get_post_type(); | |
| 1919 | + $post_type = get_post_type(); | |
| 1920 | 1920 | |
| 1921 | - $package_info = array(); | |
| 1921 | + $package_info = array(); | |
| 1922 | 1922 | |
| 1923 | - $package_info = (array)geodir_post_package_info($package_info, $post, $post_type); | |
| 1923 | + $package_info = (array)geodir_post_package_info($package_info, $post, $post_type); | |
| 1924 | 1924 | |
| 1925 | -                        if (!empty($package_info)) {
 | |
| 1925 | +						if (!empty($package_info)) {
 | |
| 1926 | 1926 | |
| 1927 | -                            if (isset($package_info['cat']) && $package_info['cat'] != '') {
 | |
| 1927 | +							if (isset($package_info['cat']) && $package_info['cat'] != '') {
 | |
| 1928 | 1928 | |
| 1929 | -                                $exclude_cats = explode(',', $package_info['cat']);
 | |
| 1929 | +								$exclude_cats = explode(',', $package_info['cat']);
 | |
| 1930 | 1930 | |
| 1931 | - } | |
| 1932 | - } | |
| 1933 | - } | |
| 1931 | + } | |
| 1932 | + } | |
| 1933 | + } | |
| 1934 | 1934 | |
| 1935 | - $cat_display = unserialize($val['extra_fields']); | |
| 1935 | + $cat_display = unserialize($val['extra_fields']); | |
| 1936 | 1936 | |
| 1937 | -                    if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) {
 | |
| 1937 | +					if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) {
 | |
| 1938 | 1938 | |
| 1939 | -                        $post_cat = implode(",", $post_cat[$name]);
 | |
| 1939 | +						$post_cat = implode(",", $post_cat[$name]);
 | |
| 1940 | 1940 | |
| 1941 | -                    } else {
 | |
| 1942 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') | |
| 1943 | - $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); | |
| 1944 | - } | |
| 1941 | +					} else {
 | |
| 1942 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') | |
| 1943 | + $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); | |
| 1944 | + } | |
| 1945 | 1945 | |
| 1946 | 1946 | |
| 1947 | - global $geodir_addon_list; | |
| 1948 | -                    if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
 | |
| 1947 | + global $geodir_addon_list; | |
| 1948 | +					if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
 | |
| 1949 | 1949 | |
| 1950 | - $catadd_limit = $wpdb->get_var( | |
| 1951 | - $wpdb->prepare( | |
| 1952 | - "SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", | |
| 1953 | - array($package_id) | |
| 1954 | - ) | |
| 1955 | - ); | |
| 1950 | + $catadd_limit = $wpdb->get_var( | |
| 1951 | + $wpdb->prepare( | |
| 1952 | + "SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", | |
| 1953 | + array($package_id) | |
| 1954 | + ) | |
| 1955 | + ); | |
| 1956 | 1956 | |
| 1957 | 1957 | |
| 1958 | -                    } else {
 | |
| 1959 | - $catadd_limit = 0; | |
| 1960 | - } | |
| 1958 | +					} else {
 | |
| 1959 | + $catadd_limit = 0; | |
| 1960 | + } | |
| 1961 | 1961 | |
| 1962 | 1962 | |
| 1963 | -                    if ($cat_display != '' && $cat_display != 'ajax_chained') {
 | |
| 1963 | +					if ($cat_display != '' && $cat_display != 'ajax_chained') {
 | |
| 1964 | 1964 | |
| 1965 | - $required_limit_msg = ''; | |
| 1966 | -                        if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') {
 | |
| 1965 | + $required_limit_msg = ''; | |
| 1966 | +						if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') {
 | |
| 1967 | 1967 | |
| 1968 | -                            $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory');
 | |
| 1968 | +							$required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory');
 | |
| 1969 | 1969 | |
| 1970 | -                        } else {
 | |
| 1971 | - $required_limit_msg = $required_msg; | |
| 1972 | - } | |
| 1970 | +						} else {
 | |
| 1971 | + $required_limit_msg = $required_msg; | |
| 1972 | + } | |
| 1973 | 1973 | |
| 1974 | - echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']" />'; | |
| 1974 | + echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']" />'; | |
| 1975 | 1975 | |
| 1976 | 1976 | |
| 1977 | -                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
 | |
| 1977 | +						if ($cat_display == 'select' || $cat_display == 'multiselect') {
 | |
| 1978 | 1978 | |
| 1979 | - $cat_display == ''; | |
| 1980 | - $multiple = ''; | |
| 1981 | - if ($cat_display == 'multiselect') | |
| 1982 | - $multiple = 'multiple="multiple"'; | |
| 1979 | + $cat_display == ''; | |
| 1980 | + $multiple = ''; | |
| 1981 | + if ($cat_display == 'multiselect') | |
| 1982 | + $multiple = 'multiple="multiple"'; | |
| 1983 | 1983 | |
| 1984 | -                            echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
 | |
| 1984 | +							echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
 | |
| 1985 | 1985 | |
| 1986 | 1986 | |
| 1987 | - if ($cat_display == 'select') | |
| 1988 | -                                echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
 | |
| 1987 | + if ($cat_display == 'select') | |
| 1988 | +								echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
 | |
| 1989 | 1989 | |
| 1990 | - } | |
| 1990 | + } | |
| 1991 | 1991 | |
| 1992 | - echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0); | |
| 1992 | + echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0); | |
| 1993 | 1993 | |
| 1994 | - if ($cat_display == 'select' || $cat_display == 'multiselect') | |
| 1995 | - echo '</select>'; | |
| 1994 | + if ($cat_display == 'select' || $cat_display == 'multiselect') | |
| 1995 | + echo '</select>'; | |
| 1996 | 1996 | |
| 1997 | -                    } else {
 | |
| 1997 | +					} else {
 | |
| 1998 | 1998 | |
| 1999 | - echo geodir_custom_taxonomy_walker2($name, $catadd_limit); | |
| 1999 | + echo geodir_custom_taxonomy_walker2($name, $catadd_limit); | |
| 2000 | 2000 | |
| 2001 | - } | |
| 2001 | + } | |
| 2002 | 2002 | |
| 2003 | - ?> | |
| 2003 | + ?> | |
| 2004 | 2004 | </div> | 
| 2005 | 2005 | |
| 2006 | 2006 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> | 
| @@ -2015,46 +2015,46 @@ discard block | ||
| 2015 | 2015 | |
| 2016 | 2016 | |
| 2017 | 2017 | |
| 2018 | - // adjust values here | |
| 2019 | - $file_id = $name; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls | |
| 2018 | + // adjust values here | |
| 2019 | + $file_id = $name; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls | |
| 2020 | 2020 | |
| 2021 | -            if ($value != '') {
 | |
| 2021 | +			if ($value != '') {
 | |
| 2022 | 2022 | |
| 2023 | - $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls. | |
| 2023 | + $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls. | |
| 2024 | 2024 | |
| 2025 | - } else | |
| 2026 | - $file_value = ''; | |
| 2025 | + } else | |
| 2026 | + $file_value = ''; | |
| 2027 | 2027 | |
| 2028 | - if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) | |
| 2029 | - $file_multiple = true; // allow multiple files upload | |
| 2030 | - else | |
| 2031 | - $file_multiple = false; | |
| 2028 | + if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) | |
| 2029 | + $file_multiple = true; // allow multiple files upload | |
| 2030 | + else | |
| 2031 | + $file_multiple = false; | |
| 2032 | 2032 | |
| 2033 | - if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) | |
| 2034 | - $file_image_limit = $extra_fields['image_limit']; | |
| 2035 | - else | |
| 2036 | - $file_image_limit = 1; | |
| 2033 | + if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) | |
| 2034 | + $file_image_limit = $extra_fields['image_limit']; | |
| 2035 | + else | |
| 2036 | + $file_image_limit = 1; | |
| 2037 | 2037 | |
| 2038 | - $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) | |
| 2038 | + $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) | |
| 2039 | 2039 | |
| 2040 | - $file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) | |
| 2040 | + $file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) | |
| 2041 | 2041 | |
| 2042 | -            if (!empty($file_value)) {
 | |
| 2043 | -                $curImages = explode(',', $file_value);
 | |
| 2044 | - if (!empty($curImages)) | |
| 2045 | - $file_totImg = count($curImages); | |
| 2046 | - } | |
| 2042 | +			if (!empty($file_value)) {
 | |
| 2043 | +				$curImages = explode(',', $file_value);
 | |
| 2044 | + if (!empty($curImages)) | |
| 2045 | + $file_totImg = count($curImages); | |
| 2046 | + } | |
| 2047 | 2047 | |
| 2048 | -            $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
 | |
| 2049 | -            $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
 | |
| 2048 | +			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
 | |
| 2049 | +			$display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
 | |
| 2050 | 2050 | |
| 2051 | - ?> | |
| 2051 | + ?> | |
| 2052 | 2052 | <?php /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?> | 
| 2053 | 2053 |  				 <?php if($file_image_limit!=0 && $file_image_limit==1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('image with this package').')</small>';} ?>
 | 
| 2054 | 2054 |  				 <?php if($file_image_limit!=0 && $file_image_limit>1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('images with this package').')</small>';} ?>
 | 
| 2055 | 2055 |  				 <?php if($file_image_limit==0){echo '<br /><small>('.__('You can upload unlimited images with this package').')</small>';} ?>
 | 
| 2056 | 2056 | </h5> <?php */ | 
| 2057 | - ?> | |
| 2057 | + ?> | |
| 2058 | 2058 | |
| 2059 | 2059 | <div id="<?php echo $name;?>_row" | 
| 2060 | 2060 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> | 
| @@ -2062,7 +2062,7 @@ discard block | ||
| 2062 | 2062 | <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;"> | 
| 2063 | 2063 | <label | 
| 2064 | 2064 | style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory'); | 
| 2065 | - echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label> | |
| 2065 | + echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label> | |
| 2066 | 2066 | <input class="geodir-custom-file-upload" field_type="file" type="hidden" | 
| 2067 | 2067 | name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>" | 
| 2068 | 2068 | value="<?php echo esc_attr($file_value); ?>"/> | 
| @@ -2074,17 +2074,17 @@ discard block | ||
| 2074 | 2074 | <?php } ?> | 
| 2075 | 2075 | <input type="hidden" name="<?php echo $file_id; ?>totImg" id="<?php echo $file_id; ?>totImg" | 
| 2076 | 2076 |                             value="<?php if (isset($file_totImg)) {
 | 
| 2077 | - echo esc_attr($file_totImg); | |
| 2078 | -                           } else {
 | |
| 2079 | - echo '0'; | |
| 2080 | - } ?>"/> | |
| 2077 | + echo esc_attr($file_totImg); | |
| 2078 | +						   } else {
 | |
| 2079 | + echo '0'; | |
| 2080 | + } ?>"/> | |
| 2081 | 2081 | |
| 2082 | 2082 | <div style="float:left; width:55%;"> | 
| 2083 | 2083 | <div | 
| 2084 | 2084 | class="plupload-upload-uic hide-if-no-js <?php if ($file_multiple): ?>plupload-upload-uic-multiple<?php endif; ?>" | 
| 2085 | 2085 | id="<?php echo $file_id; ?>plupload-upload-ui" style="float:left; width:30%;"> | 
| 2086 | 2086 |                              <?php /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */
 | 
| 2087 | - ?> | |
| 2087 | + ?> | |
| 2088 | 2088 | <input id="<?php echo $file_id; ?>plupload-browse-button" type="button" | 
| 2089 | 2089 |                                     value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory') ); ?>"
 | 
| 2090 | 2090 | class="geodir_button" style="margin-top:10px;"/> | 
| @@ -2103,7 +2103,7 @@ discard block | ||
| 2103 | 2103 | style=" clear:inherit; margin-top:0; margin-left:15px; padding-top:10px; float:left; width:50%;"> | 
| 2104 | 2104 | </div> | 
| 2105 | 2105 |                          <?php /*?><span id="upload-msg" ><?php _e('Please drag & drop the images to rearrange the order');?></span><?php */
 | 
| 2106 | - ?> | |
| 2106 | + ?> | |
| 2107 | 2107 | |
| 2108 | 2108 | <span id="<?php echo $file_id; ?>upload-error" style="display:none"></span> | 
| 2109 | 2109 | |
| @@ -2117,178 +2117,178 @@ discard block | ||
| 2117 | 2117 | |
| 2118 | 2118 | |
| 2119 | 2119 | <?php } | 
| 2120 | - /** | |
| 2121 | - * Called after the custom fields info is output for submitting a post. | |
| 2122 | - * | |
| 2123 | - * Used dynamic hook type geodir_after_custom_form_field_$name. | |
| 2124 | - * | |
| 2125 | - * @since 1.0.0 | |
| 2126 | - * @param string $listing_type The post post type. | |
| 2127 | - * @param int $package_id The price package ID for the post. | |
| 2128 | -         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
 | |
| 2129 | - * @see 'geodir_before_custom_form_field_$name' | |
| 2130 | - */ | |
| 2131 | -        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
 | |
| 2132 | - | |
| 2133 | - } | |
| 2120 | + /** | |
| 2121 | + * Called after the custom fields info is output for submitting a post. | |
| 2122 | + * | |
| 2123 | + * Used dynamic hook type geodir_after_custom_form_field_$name. | |
| 2124 | + * | |
| 2125 | + * @since 1.0.0 | |
| 2126 | + * @param string $listing_type The post post type. | |
| 2127 | + * @param int $package_id The price package ID for the post. | |
| 2128 | +		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
 | |
| 2129 | + * @see 'geodir_before_custom_form_field_$name' | |
| 2130 | + */ | |
| 2131 | +		do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
 | |
| 2132 | + | |
| 2133 | + } | |
| 2134 | 2134 | |
| 2135 | 2135 | } | 
| 2136 | 2136 | |
| 2137 | 2137 | |
| 2138 | 2138 |  if (!function_exists('geodir_get_field_infoby')) {
 | 
| 2139 | - /** | |
| 2140 | - * Get custom field using key and value. | |
| 2141 | - * | |
| 2142 | - * @since 1.0.0 | |
| 2143 | - * @package GeoDirectory | |
| 2144 | - * @global object $wpdb WordPress Database object. | |
| 2145 | - * @param string $key The key you want to look for. | |
| 2146 | - * @param string $value The value of the key you want to look for. | |
| 2147 | - * @param string $geodir_post_type The post type. | |
| 2148 | - * @return bool|mixed Returns field info when available. otherwise returns false. | |
| 2149 | - */ | |
| 2150 | - function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') | |
| 2151 | -    {
 | |
| 2152 | - | |
| 2153 | - global $wpdb; | |
| 2154 | - | |
| 2155 | - $filter = $wpdb->get_row( | |
| 2156 | - $wpdb->prepare( | |
| 2157 | - "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", | |
| 2158 | - array($geodir_post_type) | |
| 2159 | - ) | |
| 2160 | - ); | |
| 2161 | - | |
| 2162 | -        if ($filter) {
 | |
| 2163 | - return $filter; | |
| 2164 | -        } else {
 | |
| 2165 | - return false; | |
| 2166 | - } | |
| 2167 | - | |
| 2168 | - } | |
| 2139 | + /** | |
| 2140 | + * Get custom field using key and value. | |
| 2141 | + * | |
| 2142 | + * @since 1.0.0 | |
| 2143 | + * @package GeoDirectory | |
| 2144 | + * @global object $wpdb WordPress Database object. | |
| 2145 | + * @param string $key The key you want to look for. | |
| 2146 | + * @param string $value The value of the key you want to look for. | |
| 2147 | + * @param string $geodir_post_type The post type. | |
| 2148 | + * @return bool|mixed Returns field info when available. otherwise returns false. | |
| 2149 | + */ | |
| 2150 | + function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') | |
| 2151 | +	{
 | |
| 2152 | + | |
| 2153 | + global $wpdb; | |
| 2154 | + | |
| 2155 | + $filter = $wpdb->get_row( | |
| 2156 | + $wpdb->prepare( | |
| 2157 | + "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", | |
| 2158 | + array($geodir_post_type) | |
| 2159 | + ) | |
| 2160 | + ); | |
| 2161 | + | |
| 2162 | +		if ($filter) {
 | |
| 2163 | + return $filter; | |
| 2164 | +		} else {
 | |
| 2165 | + return false; | |
| 2166 | + } | |
| 2167 | + | |
| 2168 | + } | |
| 2169 | 2169 | } | 
| 2170 | 2170 | |
| 2171 | 2171 | |
| 2172 | 2172 |  if (!function_exists('geodir_show_listing_info')) {
 | 
| 2173 | - /** | |
| 2174 | - * Show listing info depending on field location. | |
| 2175 | - * | |
| 2176 | - * @since 1.0.0 | |
| 2177 | - * @since 1.5.7 Custom fields option values added to db translation. | |
| 2178 | - * Changes to display url fields title. | |
| 2179 | - * @package GeoDirectory | |
| 2180 | - * @global object $wpdb WordPress Database object. | |
| 2181 | - * @global object $post The current post object. | |
| 2182 | - * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. | |
| 2183 | - * | |
| 2184 | - * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. | |
| 2185 | - * @return string Returns listing info html. | |
| 2186 | - */ | |
| 2187 | -    function geodir_show_listing_info($fields_location = '') {
 | |
| 2188 | - global $post, $preview, $wpdb, $send_to_friend; | |
| 2189 | - | |
| 2190 | - $payment_info = array(); | |
| 2191 | - $package_info = array(); | |
| 2192 | - | |
| 2193 | - $package_info = geodir_post_package_info($package_info, $post); | |
| 2194 | - $post_package_id = $package_info->pid; | |
| 2195 | - $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); | |
| 2196 | - $send_to_friend = false; | |
| 2197 | - | |
| 2198 | - ob_start(); | |
| 2199 | - $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location); | |
| 2200 | - | |
| 2201 | -        if (!empty($fields_info)) {
 | |
| 2202 | - $post = stripslashes_deep($post); // strip slashes | |
| 2173 | + /** | |
| 2174 | + * Show listing info depending on field location. | |
| 2175 | + * | |
| 2176 | + * @since 1.0.0 | |
| 2177 | + * @since 1.5.7 Custom fields option values added to db translation. | |
| 2178 | + * Changes to display url fields title. | |
| 2179 | + * @package GeoDirectory | |
| 2180 | + * @global object $wpdb WordPress Database object. | |
| 2181 | + * @global object $post The current post object. | |
| 2182 | + * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. | |
| 2183 | + * | |
| 2184 | + * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. | |
| 2185 | + * @return string Returns listing info html. | |
| 2186 | + */ | |
| 2187 | +	function geodir_show_listing_info($fields_location = '') {
 | |
| 2188 | + global $post, $preview, $wpdb, $send_to_friend; | |
| 2189 | + | |
| 2190 | + $payment_info = array(); | |
| 2191 | + $package_info = array(); | |
| 2192 | + | |
| 2193 | + $package_info = geodir_post_package_info($package_info, $post); | |
| 2194 | + $post_package_id = $package_info->pid; | |
| 2195 | + $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); | |
| 2196 | + $send_to_friend = false; | |
| 2197 | + | |
| 2198 | + ob_start(); | |
| 2199 | + $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location); | |
| 2200 | + | |
| 2201 | +		if (!empty($fields_info)) {
 | |
| 2202 | + $post = stripslashes_deep($post); // strip slashes | |
| 2203 | 2203 | |
| 2204 | - //echo '<div class="geodir-company_info field-group">'; | |
| 2205 | - $field_set_start = 0; | |
| 2204 | + //echo '<div class="geodir-company_info field-group">'; | |
| 2205 | + $field_set_start = 0; | |
| 2206 | 2206 | |
| 2207 | 2207 | |
| 2208 | - if ($fields_location == 'detail') | |
| 2208 | + if ($fields_location == 'detail') | |
| 2209 | 2209 | |
| 2210 | - $i = 1; | |
| 2211 | -            foreach ($fields_info as $type) {
 | |
| 2212 | - $type = stripslashes_deep($type); // strip slashes | |
| 2213 | - $html = ''; | |
| 2214 | - $html_var = ''; | |
| 2215 | - $field_icon = ''; | |
| 2210 | + $i = 1; | |
| 2211 | +			foreach ($fields_info as $type) {
 | |
| 2212 | + $type = stripslashes_deep($type); // strip slashes | |
| 2213 | + $html = ''; | |
| 2214 | + $html_var = ''; | |
| 2215 | + $field_icon = ''; | |
| 2216 | 2216 | |
| 2217 | - $variables_array = array(); | |
| 2217 | + $variables_array = array(); | |
| 2218 | 2218 | |
| 2219 | -                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'))) {
 | |
| 2220 | - continue; | |
| 2221 | - } | |
| 2219 | +				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'))) {
 | |
| 2220 | + continue; | |
| 2221 | + } | |
| 2222 | 2222 | |
| 2223 | - if ($type['type'] != 'fieldset'): | |
| 2224 | - $variables_array['post_id'] = $post->ID; | |
| 2225 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); | |
| 2226 | - $variables_array['value'] = ''; | |
| 2227 | -                    if (isset($post->{$type['htmlvar_name']}))
 | |
| 2228 | -                        $variables_array['value'] = $post->{$type['htmlvar_name']};
 | |
| 2229 | - endif; | |
| 2223 | + if ($type['type'] != 'fieldset'): | |
| 2224 | + $variables_array['post_id'] = $post->ID; | |
| 2225 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); | |
| 2226 | + $variables_array['value'] = ''; | |
| 2227 | +					if (isset($post->{$type['htmlvar_name']}))
 | |
| 2228 | +						$variables_array['value'] = $post->{$type['htmlvar_name']};
 | |
| 2229 | + endif; | |
| 2230 | 2230 | |
| 2231 | - //if($type['field_icon']) | |
| 2231 | + //if($type['field_icon']) | |
| 2232 | 2232 | |
| 2233 | -                if (strpos($type['field_icon'], 'http') !== false) {
 | |
| 2234 | -                    $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
 | |
| 2235 | -                } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
 | |
| 2236 | - $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; | |
| 2237 | - } | |
| 2238 | -                //else{$field_icon = $type['field_icon'];}
 | |
| 2233 | +				if (strpos($type['field_icon'], 'http') !== false) {
 | |
| 2234 | +					$field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
 | |
| 2235 | +				} elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
 | |
| 2236 | + $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; | |
| 2237 | + } | |
| 2238 | +				//else{$field_icon = $type['field_icon'];}
 | |
| 2239 | 2239 | |
| 2240 | 2240 | |
| 2241 | -                switch ($type['type']) {
 | |
| 2241 | +				switch ($type['type']) {
 | |
| 2242 | 2242 | |
| 2243 | - case 'fieldset': | |
| 2243 | + case 'fieldset': | |
| 2244 | 2244 | |
| 2245 | - $fieldset_class = 'fieldset-'.sanitize_title_with_dashes($type['site_title']); | |
| 2245 | + $fieldset_class = 'fieldset-'.sanitize_title_with_dashes($type['site_title']); | |
| 2246 | 2246 | |
| 2247 | -                        if ($field_set_start == 1) {
 | |
| 2248 | - echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>'; | |
| 2249 | -                        } else {
 | |
| 2250 | - echo '<h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>'; | |
| 2251 | - $field_set_start = 1; | |
| 2252 | - } | |
| 2247 | +						if ($field_set_start == 1) {
 | |
| 2248 | + echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>'; | |
| 2249 | +						} else {
 | |
| 2250 | + echo '<h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>'; | |
| 2251 | + $field_set_start = 1; | |
| 2252 | + } | |
| 2253 | 2253 | |
| 2254 | - break; | |
| 2254 | + break; | |
| 2255 | 2255 | |
| 2256 | - case 'address': | |
| 2256 | + case 'address': | |
| 2257 | 2257 | |
| 2258 | - $html_var = $type['htmlvar_name'] . '_address'; | |
| 2258 | + $html_var = $type['htmlvar_name'] . '_address'; | |
| 2259 | 2259 | |
| 2260 | -                        if ($type['extra_fields']) {
 | |
| 2260 | +						if ($type['extra_fields']) {
 | |
| 2261 | 2261 | |
| 2262 | - $extra_fields = unserialize($type['extra_fields']); | |
| 2262 | + $extra_fields = unserialize($type['extra_fields']); | |
| 2263 | 2263 | |
| 2264 | - $addition_fields = ''; | |
| 2264 | + $addition_fields = ''; | |
| 2265 | 2265 | |
| 2266 | -                            if (!empty($extra_fields)) {
 | |
| 2267 | - /** | |
| 2268 | - * Filter "show city in address" value. | |
| 2269 | - * | |
| 2270 | - * @since 1.0.0 | |
| 2271 | - */ | |
| 2272 | -                                $show_city_in_address = apply_filters('geodir_show_city_in_address', false);
 | |
| 2273 | -                                if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) {
 | |
| 2274 | - $field = $type['htmlvar_name'] . '_city'; | |
| 2275 | -                                    if ($post->{$field}) {
 | |
| 2276 | -                                        $addition_fields .= ', ' . $post->{$field};
 | |
| 2277 | - } | |
| 2278 | - } | |
| 2266 | +							if (!empty($extra_fields)) {
 | |
| 2267 | + /** | |
| 2268 | + * Filter "show city in address" value. | |
| 2269 | + * | |
| 2270 | + * @since 1.0.0 | |
| 2271 | + */ | |
| 2272 | +								$show_city_in_address = apply_filters('geodir_show_city_in_address', false);
 | |
| 2273 | +								if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) {
 | |
| 2274 | + $field = $type['htmlvar_name'] . '_city'; | |
| 2275 | +									if ($post->{$field}) {
 | |
| 2276 | +										$addition_fields .= ', ' . $post->{$field};
 | |
| 2277 | + } | |
| 2278 | + } | |
| 2279 | 2279 | |
| 2280 | 2280 | |
| 2281 | -                                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
 | |
| 2282 | - $field = $type['htmlvar_name'] . '_zip'; | |
| 2283 | -                                    if ($post->{$field}) {
 | |
| 2284 | -                                        $addition_fields .= ', ' . $post->{$field};
 | |
| 2285 | - } | |
| 2286 | - } | |
| 2281 | +								if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
 | |
| 2282 | + $field = $type['htmlvar_name'] . '_zip'; | |
| 2283 | +									if ($post->{$field}) {
 | |
| 2284 | +										$addition_fields .= ', ' . $post->{$field};
 | |
| 2285 | + } | |
| 2286 | + } | |
| 2287 | 2287 | |
| 2288 | - } | |
| 2288 | + } | |
| 2289 | 2289 | |
| 2290 | - } | |
| 2291 | - /*if($type['extra_fields']) | |
| 2290 | + } | |
| 2291 | + /*if($type['extra_fields']) | |
| 2292 | 2292 |  						{
 | 
| 2293 | 2293 | |
| 2294 | 2294 | $extra_fields = unserialize($type['extra_fields']); | 
| @@ -2337,1034 +2337,1034 @@ discard block | ||
| 2337 | 2337 | |
| 2338 | 2338 | }*/ | 
| 2339 | 2339 | |
| 2340 | -                        if ($post->{$html_var}):
 | |
| 2340 | +						if ($post->{$html_var}):
 | |
| 2341 | + | |
| 2342 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2343 | + $field_icon_af = ''; | |
| 2344 | +							} elseif ($field_icon == '') {
 | |
| 2345 | + $field_icon_af = '<i class="fa fa-home"></i>'; | |
| 2346 | +							} else {
 | |
| 2347 | + $field_icon_af = $field_icon; | |
| 2348 | + $field_icon = ''; | |
| 2349 | + } | |
| 2350 | + | |
| 2351 | + $geodir_odd_even = ''; | |
| 2352 | +							if ($fields_location == 'detail') {
 | |
| 2353 | + | |
| 2354 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2355 | + if ($i % 2 == 0) | |
| 2356 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2357 | + | |
| 2358 | + $i++; | |
| 2359 | + } | |
| 2360 | + | |
| 2361 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;" itemscope itemtype="http://schema.org/PostalAddress">'; | |
| 2362 | + $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af; | |
| 2363 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2364 | + $html .= '</span>'; | |
| 2365 | + | |
| 2366 | +							if ($preview) {
 | |
| 2367 | +								$html .= $post->{$html_var} . $addition_fields . '</p></div>';
 | |
| 2368 | +							} else {
 | |
| 2369 | +								if ($post->post_address) {
 | |
| 2370 | + $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>'; | |
| 2371 | + } | |
| 2372 | +								if ($post->post_city) {
 | |
| 2373 | + $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>'; | |
| 2374 | + } | |
| 2375 | +								if ($post->post_region) {
 | |
| 2376 | + $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>'; | |
| 2377 | + } | |
| 2378 | +								if ($post->post_zip) {
 | |
| 2379 | + $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>'; | |
| 2380 | + } | |
| 2381 | +								if ($post->post_country) {
 | |
| 2382 | + $html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>'; | |
| 2383 | + } | |
| 2384 | + $html .= '</div>'; | |
| 2385 | + } | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + endif; | |
| 2389 | + | |
| 2390 | +						$variables_array['value'] = $post->{$html_var};
 | |
| 2391 | + | |
| 2392 | + break; | |
| 2393 | + | |
| 2394 | + case 'url': | |
| 2395 | + | |
| 2396 | + $html_var = $type['htmlvar_name']; | |
| 2397 | + | |
| 2398 | +						if ($post->{$type['htmlvar_name']}):
 | |
| 2399 | + | |
| 2400 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2401 | + $field_icon_af = ''; | |
| 2402 | +							} elseif ($field_icon == '') {
 | |
| 2403 | + | |
| 2404 | +								if ($type['name'] == 'geodir_facebook') {
 | |
| 2405 | + $field_icon_af = '<i class="fa fa-facebook-square"></i>'; | |
| 2406 | +								} elseif ($type['name'] == 'geodir_twitter') {
 | |
| 2407 | + $field_icon_af = '<i class="fa fa-twitter-square"></i>'; | |
| 2408 | +								} else {
 | |
| 2409 | + $field_icon_af = '<i class="fa fa-link"></i>'; | |
| 2410 | + } | |
| 2411 | + | |
| 2412 | +							} else {
 | |
| 2413 | + $field_icon_af = $field_icon; | |
| 2414 | + $field_icon = ''; | |
| 2415 | + } | |
| 2416 | + | |
| 2417 | +							$a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
 | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + $website = !empty($a_url['url']) ? $a_url['url'] : ''; | |
| 2421 | + $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; | |
| 2422 | +							if(!empty($type['default_value'])){$title = $type['default_value'];}
 | |
| 2423 | + $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; | |
| 2341 | 2424 | |
| 2342 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2343 | - $field_icon_af = ''; | |
| 2344 | -                            } elseif ($field_icon == '') {
 | |
| 2345 | - $field_icon_af = '<i class="fa fa-home"></i>'; | |
| 2346 | -                            } else {
 | |
| 2347 | - $field_icon_af = $field_icon; | |
| 2348 | - $field_icon = ''; | |
| 2349 | - } | |
| 2350 | - | |
| 2351 | - $geodir_odd_even = ''; | |
| 2352 | -                            if ($fields_location == 'detail') {
 | |
| 2353 | 2425 | |
| 2354 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2355 | - if ($i % 2 == 0) | |
| 2356 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2426 | + $geodir_odd_even = ''; | |
| 2427 | +							if ($fields_location == 'detail') {
 | |
| 2357 | 2428 | |
| 2358 | - $i++; | |
| 2359 | - } | |
| 2429 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2430 | + if ($i % 2 == 0) | |
| 2431 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2360 | 2432 | |
| 2361 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;" itemscope itemtype="http://schema.org/PostalAddress">'; | |
| 2362 | - $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af; | |
| 2363 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2364 | - $html .= '</span>'; | |
| 2433 | + $i++; | |
| 2434 | + } | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + // all search engines that use the nofollow value exclude links that use it from their ranking calculation | |
| 2438 | + $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; | |
| 2439 | + /** | |
| 2440 | + * Filter custom field website name. | |
| 2441 | + * | |
| 2442 | + * @since 1.0.0 | |
| 2443 | + * | |
| 2444 | + * @param string $title Website Title. | |
| 2445 | + * @param string $website Website URL. | |
| 2446 | + * @param int $post->ID Post ID. | |
| 2447 | + */ | |
| 2448 | +							$html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
 | |
| 2449 | + | |
| 2450 | + endif; | |
| 2451 | + | |
| 2452 | + break; | |
| 2453 | + | |
| 2454 | + case 'phone': | |
| 2455 | + | |
| 2456 | + $html_var = $type['htmlvar_name']; | |
| 2457 | + | |
| 2458 | +						if ($post->{$type['htmlvar_name']}):
 | |
| 2459 | + | |
| 2460 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2461 | + $field_icon_af = ''; | |
| 2462 | +							} elseif ($field_icon == '') {
 | |
| 2463 | + $field_icon_af = '<i class="fa fa-phone"></i>'; | |
| 2464 | +							} else {
 | |
| 2465 | + $field_icon_af = $field_icon; | |
| 2466 | + $field_icon = ''; | |
| 2467 | + } | |
| 2468 | + | |
| 2469 | + $geodir_odd_even = ''; | |
| 2470 | +							if ($fields_location == 'detail') {
 | |
| 2471 | + | |
| 2472 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2473 | + if ($i % 2 == 0) | |
| 2474 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2475 | + | |
| 2476 | + $i++; | |
| 2477 | + } | |
| 2478 | + | |
| 2479 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . | |
| 2480 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2481 | +							$html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$type['htmlvar_name']}) . '">' . $post->{$type['htmlvar_name']} . '</a></div>';
 | |
| 2482 | + | |
| 2483 | + endif; | |
| 2484 | + | |
| 2485 | + break; | |
| 2486 | + | |
| 2487 | + case 'time': | |
| 2488 | + | |
| 2489 | + $html_var = $type['htmlvar_name']; | |
| 2490 | + | |
| 2491 | +						if ($post->{$type['htmlvar_name']}):
 | |
| 2492 | + | |
| 2493 | + $value = ''; | |
| 2494 | +							if ($post->{$type['htmlvar_name']} != '')
 | |
| 2495 | +								//$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
 | |
| 2496 | +								$value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
 | |
| 2497 | + | |
| 2498 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2499 | + $field_icon_af = ''; | |
| 2500 | +							} elseif ($field_icon == '') {
 | |
| 2501 | + $field_icon_af = '<i class="fa fa-clock-o"></i>'; | |
| 2502 | +							} else {
 | |
| 2503 | + $field_icon_af = $field_icon; | |
| 2504 | + $field_icon = ''; | |
| 2505 | + } | |
| 2506 | + | |
| 2507 | + $geodir_odd_even = ''; | |
| 2508 | +							if ($fields_location == 'detail') {
 | |
| 2509 | + | |
| 2510 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2511 | + if ($i % 2 == 0) | |
| 2512 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2513 | + | |
| 2514 | + $i++; | |
| 2515 | + } | |
| 2516 | + | |
| 2517 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; | |
| 2518 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2519 | + $html .= '</span>' . $value . '</div>'; | |
| 2520 | + | |
| 2521 | + endif; | |
| 2522 | + | |
| 2523 | + break; | |
| 2524 | + | |
| 2525 | + case 'datepicker': | |
| 2526 | + | |
| 2527 | +						if ($post->{$type['htmlvar_name']}):
 | |
| 2528 | + | |
| 2529 | + $date_format = geodir_default_date_format(); | |
| 2530 | +							if ($type['extra_fields'] != '') {
 | |
| 2531 | + $date_format = unserialize($type['extra_fields']); | |
| 2532 | + $date_format = $date_format['date_format']; | |
| 2533 | + } | |
| 2534 | + // check if we need to change the format or not | |
| 2535 | +							$date_format_len = strlen(str_replace(' ', '', $date_format));
 | |
| 2536 | +							if($date_format_len>5){// if greater then 4 then it's the old style format.
 | |
| 2537 | + | |
| 2538 | +								$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
 | |
| 2539 | +								$replace = array('d','j','l','m','n','F','Y');//PHP date format
 | |
| 2540 | + | |
| 2541 | + $date_format = str_replace($search, $replace, $date_format); | |
| 2542 | + | |
| 2543 | +								$post_htmlvar_value = ($date_format == 'd/m/Y' || $date_format == 'j/n/Y' ) ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
 | |
| 2544 | +							}else{
 | |
| 2545 | +								$post_htmlvar_value = $post->{$type['htmlvar_name']};
 | |
| 2546 | + } | |
| 2547 | + | |
| 2548 | +							if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
 | |
| 2549 | + $value = date_i18n($date_format, strtotime($post_htmlvar_value)); | |
| 2550 | +							}else{
 | |
| 2551 | + continue; | |
| 2552 | + } | |
| 2553 | + | |
| 2554 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2555 | + $field_icon_af = ''; | |
| 2556 | +							} elseif ($field_icon == '') {
 | |
| 2557 | + $field_icon_af = '<i class="fa fa-calendar"></i>'; | |
| 2558 | +							} else {
 | |
| 2559 | + $field_icon_af = $field_icon; | |
| 2560 | + $field_icon = ''; | |
| 2561 | + } | |
| 2562 | + | |
| 2563 | + $geodir_odd_even = ''; | |
| 2564 | +							if ($fields_location == 'detail') {
 | |
| 2565 | + | |
| 2566 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2567 | + if ($i % 2 == 0) | |
| 2568 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2569 | + | |
| 2570 | + $i++; | |
| 2571 | + } | |
| 2572 | + | |
| 2573 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; | |
| 2574 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2575 | + $html .= '</span>' . $value . '</div>'; | |
| 2576 | + | |
| 2577 | + endif; | |
| 2578 | + | |
| 2579 | + break; | |
| 2580 | + | |
| 2581 | + case 'text': | |
| 2582 | + | |
| 2583 | + $html_var = $type['htmlvar_name']; | |
| 2584 | + | |
| 2585 | +						if (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']} != '' && $type['htmlvar_name'] == 'geodir_timing'):
 | |
| 2586 | + | |
| 2587 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2588 | + $field_icon_af = ''; | |
| 2589 | +							} elseif ($field_icon == '') {
 | |
| 2590 | + $field_icon_af = '<i class="fa fa-clock-o"></i>'; | |
| 2591 | +							} else {
 | |
| 2592 | + $field_icon_af = $field_icon; | |
| 2593 | + $field_icon = ''; | |
| 2594 | + } | |
| 2595 | + | |
| 2596 | + $geodir_odd_even = ''; | |
| 2597 | +							if ($fields_location == 'detail') {
 | |
| 2598 | + | |
| 2599 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2600 | + if ($i % 2 == 0) | |
| 2601 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2602 | + | |
| 2603 | + $i++; | |
| 2604 | + } | |
| 2605 | + | |
| 2606 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; | |
| 2607 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2608 | +							$html .= '</span>' . $post->{$type['htmlvar_name']} . '</div>';
 | |
| 2609 | + | |
| 2610 | +						elseif (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']}):
 | |
| 2611 | + | |
| 2612 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2613 | + $field_icon_af = ''; | |
| 2614 | +							} elseif ($field_icon == '') {
 | |
| 2615 | + $field_icon_af = ''; | |
| 2616 | +							} else {
 | |
| 2617 | + $field_icon_af = $field_icon; | |
| 2618 | + $field_icon = ''; | |
| 2619 | + } | |
| 2620 | + | |
| 2621 | + $geodir_odd_even = ''; | |
| 2622 | +							if ($fields_location == 'detail') {
 | |
| 2623 | + | |
| 2624 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2625 | + if ($i % 2 == 0) | |
| 2626 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2627 | + | |
| 2628 | + $i++; | |
| 2629 | + } | |
| 2630 | + | |
| 2631 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; | |
| 2632 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2633 | +							$html .= '</span>' . $post->{$type['htmlvar_name']} . '</div>';
 | |
| 2634 | + | |
| 2635 | + endif; | |
| 2636 | + | |
| 2637 | + break; | |
| 2638 | + | |
| 2639 | + case 'radio': | |
| 2640 | + | |
| 2641 | + $html_var = $type['htmlvar_name']; | |
| 2642 | +						if(!isset($post->{$type['htmlvar_name']})){continue;}
 | |
| 2643 | +						$html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
 | |
| 2644 | +						if ($post->{$type['htmlvar_name']} != ''):
 | |
| 2645 | + | |
| 2646 | +							if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
 | |
| 2647 | +								$html_val = __('No', 'geodirectory');
 | |
| 2648 | +							} else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
 | |
| 2649 | +								$html_val = __('Yes', 'geodirectory');
 | |
| 2650 | +							} else {
 | |
| 2651 | +								if (!empty($type['option_values'])) {
 | |
| 2652 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); | |
| 2653 | + | |
| 2654 | +									if (!empty($cf_option_values)) {
 | |
| 2655 | +										foreach ($cf_option_values as $cf_option_value) {
 | |
| 2656 | +											if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
 | |
| 2657 | + $html_val = $cf_option_value['label']; | |
| 2658 | + } | |
| 2659 | + } | |
| 2660 | + } | |
| 2661 | + } | |
| 2662 | + } | |
| 2663 | + | |
| 2664 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2665 | + $field_icon_af = ''; | |
| 2666 | +							} elseif ($field_icon == '') {
 | |
| 2667 | + $field_icon_af = ''; | |
| 2668 | +							} else {
 | |
| 2669 | + $field_icon_af = $field_icon; | |
| 2670 | + $field_icon = ''; | |
| 2671 | + } | |
| 2365 | 2672 | |
| 2366 | -                            if ($preview) {
 | |
| 2367 | -                                $html .= $post->{$html_var} . $addition_fields . '</p></div>';
 | |
| 2368 | -                            } else {
 | |
| 2369 | -                                if ($post->post_address) {
 | |
| 2370 | - $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>'; | |
| 2371 | - } | |
| 2372 | -                                if ($post->post_city) {
 | |
| 2373 | - $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>'; | |
| 2374 | - } | |
| 2375 | -                                if ($post->post_region) {
 | |
| 2376 | - $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>'; | |
| 2377 | - } | |
| 2378 | -                                if ($post->post_zip) {
 | |
| 2379 | - $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>'; | |
| 2380 | - } | |
| 2381 | -                                if ($post->post_country) {
 | |
| 2382 | - $html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>'; | |
| 2383 | - } | |
| 2384 | - $html .= '</div>'; | |
| 2385 | - } | |
| 2673 | + $geodir_odd_even = ''; | |
| 2674 | +							if ($fields_location == 'detail') {
 | |
| 2386 | 2675 | |
| 2676 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2677 | + if ($i % 2 == 0) | |
| 2678 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2387 | 2679 | |
| 2388 | - endif; | |
| 2680 | + $i++; | |
| 2681 | + } | |
| 2682 | + | |
| 2683 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; | |
| 2684 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2685 | + $html .= '</span>' . $html_val . '</div>'; | |
| 2686 | + endif; | |
| 2687 | + | |
| 2688 | + break; | |
| 2689 | + | |
| 2690 | + case 'checkbox': | |
| 2691 | + | |
| 2692 | + $html_var = $type['htmlvar_name']; | |
| 2693 | + | |
| 2694 | +						if ((int)$post->{$html_var} == 1):
 | |
| 2695 | + | |
| 2696 | +							if ($post->{$type['htmlvar_name']} == '1'):
 | |
| 2697 | +								$html_val = __('Yes', 'geodirectory');
 | |
| 2698 | + else: | |
| 2699 | +								$html_val = __('No', 'geodirectory');
 | |
| 2700 | + endif; | |
| 2701 | + | |
| 2702 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2703 | + $field_icon_af = ''; | |
| 2704 | +							} elseif ($field_icon == '') {
 | |
| 2705 | + $field_icon_af = ''; | |
| 2706 | +							} else {
 | |
| 2707 | + $field_icon_af = $field_icon; | |
| 2708 | + $field_icon = ''; | |
| 2709 | + } | |
| 2710 | + | |
| 2711 | + $geodir_odd_even = ''; | |
| 2712 | +							if ($fields_location == 'detail') {
 | |
| 2713 | + | |
| 2714 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2715 | + if ($i % 2 == 0) | |
| 2716 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2717 | + | |
| 2718 | + $i++; | |
| 2719 | + } | |
| 2720 | + | |
| 2721 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; | |
| 2722 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2723 | + $html .= '</span>' . $html_val . '</div>'; | |
| 2724 | + endif; | |
| 2725 | + | |
| 2726 | + break; | |
| 2727 | + | |
| 2728 | + case 'select': | |
| 2729 | + | |
| 2730 | + $html_var = $type['htmlvar_name']; | |
| 2731 | +						if(!isset($post->{$type['htmlvar_name']})){continue;}
 | |
| 2732 | +						if ($post->{$type['htmlvar_name']}):
 | |
| 2733 | +							$field_value = __($post->{$type['htmlvar_name']}, 'geodirectory');
 | |
| 2734 | + | |
| 2735 | +							if (!empty($type['option_values'])) {
 | |
| 2736 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); | |
| 2737 | + | |
| 2738 | +								if (!empty($cf_option_values)) {
 | |
| 2739 | +									foreach ($cf_option_values as $cf_option_value) {
 | |
| 2740 | +										if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
 | |
| 2741 | + //$field_value = $cf_option_value['label']; // no longer needed here. | |
| 2742 | + } | |
| 2743 | + } | |
| 2744 | + } | |
| 2745 | + } | |
| 2746 | + | |
| 2747 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2748 | + $field_icon_af = ''; | |
| 2749 | +							} elseif ($field_icon == '') {
 | |
| 2750 | + $field_icon_af = ''; | |
| 2751 | +							} else {
 | |
| 2752 | + $field_icon_af = $field_icon; | |
| 2753 | + $field_icon = ''; | |
| 2754 | + } | |
| 2755 | + | |
| 2756 | + $geodir_odd_even = ''; | |
| 2757 | +							if ($fields_location == 'detail') {
 | |
| 2758 | + | |
| 2759 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2760 | + if ($i % 2 == 0) | |
| 2761 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2762 | + | |
| 2763 | + $i++; | |
| 2764 | + } | |
| 2765 | + | |
| 2766 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; | |
| 2767 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2768 | + $html .= '</span>' . $field_value . '</div>'; | |
| 2769 | + endif; | |
| 2770 | + | |
| 2771 | + break; | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + case 'multiselect': | |
| 2775 | + | |
| 2776 | + $html_var = $type['htmlvar_name']; | |
| 2777 | + | |
| 2778 | +						if (!empty($post->{$type['htmlvar_name']})):
 | |
| 2779 | + | |
| 2780 | +							if (is_array($post->{$type['htmlvar_name']})) {
 | |
| 2781 | +								$post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
 | |
| 2782 | + } | |
| 2783 | + | |
| 2784 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2785 | + $field_icon_af = ''; | |
| 2786 | +							} elseif ($field_icon == '') {
 | |
| 2787 | + $field_icon_af = ''; | |
| 2788 | +							} else {
 | |
| 2789 | + $field_icon_af = $field_icon; | |
| 2790 | + $field_icon = ''; | |
| 2791 | + } | |
| 2792 | + | |
| 2793 | +							$field_values = explode(',', trim($post->{$type['htmlvar_name']}, ","));
 | |
| 2389 | 2794 | |
| 2390 | -                        $variables_array['value'] = $post->{$html_var};
 | |
| 2795 | + $option_values = array(); | |
| 2796 | +							if (!empty($type['option_values'])) {
 | |
| 2797 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); | |
| 2391 | 2798 | |
| 2392 | - break; | |
| 2799 | +								if (!empty($cf_option_values)) {
 | |
| 2800 | +									foreach ($cf_option_values as $cf_option_value) {
 | |
| 2801 | +										if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
 | |
| 2802 | + $option_values[] = $cf_option_value['label']; | |
| 2803 | + } | |
| 2804 | + } | |
| 2805 | + } | |
| 2806 | + } | |
| 2393 | 2807 | |
| 2394 | - case 'url': | |
| 2808 | + $geodir_odd_even = ''; | |
| 2809 | +							if ($fields_location == 'detail') {
 | |
| 2395 | 2810 | |
| 2396 | - $html_var = $type['htmlvar_name']; | |
| 2811 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2812 | + if ($i % 2 == 0) | |
| 2813 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2397 | 2814 | |
| 2398 | -                        if ($post->{$type['htmlvar_name']}):
 | |
| 2815 | + $i++; | |
| 2816 | + } | |
| 2399 | 2817 | |
| 2400 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2401 | - $field_icon_af = ''; | |
| 2402 | -                            } elseif ($field_icon == '') {
 | |
| 2818 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; | |
| 2819 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2820 | + $html .= '</span>'; | |
| 2403 | 2821 | |
| 2404 | -                                if ($type['name'] == 'geodir_facebook') {
 | |
| 2405 | - $field_icon_af = '<i class="fa fa-facebook-square"></i>'; | |
| 2406 | -                                } elseif ($type['name'] == 'geodir_twitter') {
 | |
| 2407 | - $field_icon_af = '<i class="fa fa-twitter-square"></i>'; | |
| 2408 | -                                } else {
 | |
| 2409 | - $field_icon_af = '<i class="fa fa-link"></i>'; | |
| 2410 | - } | |
| 2822 | +							if (count($option_values) > 1) {
 | |
| 2823 | + $html .= '<ul>'; | |
| 2411 | 2824 | |
| 2412 | -                            } else {
 | |
| 2413 | - $field_icon_af = $field_icon; | |
| 2414 | - $field_icon = ''; | |
| 2415 | - } | |
| 2825 | +								foreach ($option_values as $val) {
 | |
| 2826 | + $html .= '<li>' . $val . '</li>'; | |
| 2827 | + } | |
| 2416 | 2828 | |
| 2417 | -                            $a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
 | |
| 2829 | + $html .= '</ul>'; | |
| 2830 | +							} else {
 | |
| 2831 | +								$html .= $post->{$type['htmlvar_name']};
 | |
| 2832 | + } | |
| 2418 | 2833 | |
| 2834 | + $html .= '</div>'; | |
| 2835 | + endif; | |
| 2836 | + break; | |
| 2837 | + case 'email': | |
| 2838 | + $html_var = $type['htmlvar_name']; | |
| 2839 | +						if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
 | |
| 2840 | + continue; // Remove Send Enquiry | Send To Friend from listings page | |
| 2841 | + } | |
| 2842 | + | |
| 2843 | +						if ($type['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$type['htmlvar_name']})) {
 | |
| 2844 | + $send_to_friend = true; | |
| 2845 | + $b_send_inquiry = ''; | |
| 2846 | + $b_sendtofriend = ''; | |
| 2847 | + | |
| 2848 | + $html = ''; | |
| 2849 | +							if (!$preview) {
 | |
| 2850 | + $b_send_inquiry = 'b_send_inquiry'; | |
| 2851 | + $b_sendtofriend = 'b_sendtofriend'; | |
| 2852 | + $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>'; | |
| 2853 | + } | |
| 2419 | 2854 | |
| 2420 | - $website = !empty($a_url['url']) ? $a_url['url'] : ''; | |
| 2421 | - $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; | |
| 2422 | -                            if(!empty($type['default_value'])){$title = $type['default_value'];}
 | |
| 2423 | - $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; | |
| 2855 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 2856 | + $field_icon_af = ''; | |
| 2857 | +							} elseif ($field_icon == '') {
 | |
| 2858 | + $field_icon_af = '<i class="fa fa-envelope"></i>'; | |
| 2859 | +							} else {
 | |
| 2860 | + $field_icon_af = $field_icon; | |
| 2861 | + $field_icon = ''; | |
| 2862 | + } | |
| 2424 | 2863 | |
| 2864 | + $geodir_odd_even = ''; | |
| 2865 | +							if ($fields_location == 'detail') {
 | |
| 2425 | 2866 | |
| 2426 | - $geodir_odd_even = ''; | |
| 2427 | -                            if ($fields_location == 'detail') {
 | |
| 2867 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2868 | + if ($i % 2 == 0) | |
| 2869 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2428 | 2870 | |
| 2429 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2430 | - if ($i % 2 == 0) | |
| 2431 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2871 | + $i++; | |
| 2872 | + } | |
| 2432 | 2873 | |
| 2433 | - $i++; | |
| 2434 | - } | |
| 2874 | + $html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; | |
| 2875 | + $seperator = ''; | |
| 2876 | +							if ($post->{$type['htmlvar_name']}) {
 | |
| 2877 | + $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>'; | |
| 2878 | + $seperator = ' | '; | |
| 2879 | + } | |
| 2435 | 2880 | |
| 2881 | +							if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
 | |
| 2882 | + $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>'; | |
| 2883 | + } | |
| 2436 | 2884 | |
| 2437 | - // all search engines that use the nofollow value exclude links that use it from their ranking calculation | |
| 2438 | - $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; | |
| 2439 | - /** | |
| 2440 | - * Filter custom field website name. | |
| 2441 | - * | |
| 2442 | - * @since 1.0.0 | |
| 2443 | - * | |
| 2444 | - * @param string $title Website Title. | |
| 2445 | - * @param string $website Website URL. | |
| 2446 | - * @param int $post->ID Post ID. | |
| 2447 | - */ | |
| 2448 | -                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
 | |
| 2885 | + $html .= '</span></div>'; | |
| 2449 | 2886 | |
| 2450 | - endif; | |
| 2451 | 2887 | |
| 2452 | - break; | |
| 2888 | +							if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
 | |
| 2889 | + $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>'; | |
| 2890 | +							} elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
 | |
| 2891 | + $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>'; | |
| 2892 | +							} elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
 | |
| 2893 | + $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>'; | |
| 2894 | + } | |
| 2453 | 2895 | |
| 2454 | - case 'phone': | |
| 2896 | +							/*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
 | |
| 2455 | 2897 | |
| 2456 | - $html_var = $type['htmlvar_name']; | |
| 2898 | +						} else {
 | |
| 2457 | 2899 | |
| 2458 | -                        if ($post->{$type['htmlvar_name']}):
 | |
| 2900 | +							if ($post->{$type['htmlvar_name']}) {
 | |
| 2901 | +								if (strpos($field_icon, 'http') !== false) {
 | |
| 2902 | + $field_icon_af = ''; | |
| 2903 | +								} elseif ($field_icon == '') {
 | |
| 2904 | + $field_icon_af = '<i class="fa fa-envelope"></i>'; | |
| 2905 | +								} else {
 | |
| 2906 | + $field_icon_af = $field_icon; | |
| 2907 | + $field_icon = ''; | |
| 2908 | + } | |
| 2459 | 2909 | |
| 2460 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2461 | - $field_icon_af = ''; | |
| 2462 | -                            } elseif ($field_icon == '') {
 | |
| 2463 | - $field_icon_af = '<i class="fa fa-phone"></i>'; | |
| 2464 | -                            } else {
 | |
| 2465 | - $field_icon_af = $field_icon; | |
| 2466 | - $field_icon = ''; | |
| 2467 | - } | |
| 2910 | + $geodir_odd_even = ''; | |
| 2911 | +								if ($fields_location == 'detail') {
 | |
| 2468 | 2912 | |
| 2469 | - $geodir_odd_even = ''; | |
| 2470 | -                            if ($fields_location == 'detail') {
 | |
| 2913 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2914 | + if ($i % 2 == 0) | |
| 2915 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2471 | 2916 | |
| 2472 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2473 | - if ($i % 2 == 0) | |
| 2474 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2917 | + $i++; | |
| 2918 | + } | |
| 2475 | 2919 | |
| 2476 | - $i++; | |
| 2477 | - } | |
| 2920 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; | |
| 2921 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2922 | + $html .= '</span><span class="geodir-email-address-output">'; | |
| 2923 | +								$email = $post->{$type['htmlvar_name']} ;
 | |
| 2924 | +								if($e_split = explode('@',$email)){
 | |
| 2925 | + /** | |
| 2926 | + * Filter email custom field name output. | |
| 2927 | + * | |
| 2928 | + * @since 1.5.3 | |
| 2929 | + * | |
| 2930 | + * @param string $email The email string being output. | |
| 2931 | + * @param array $type Custom field variables array. | |
| 2932 | + */ | |
| 2933 | +									$email_name = apply_filters('geodir_email_field_name_output',$email,$type);
 | |
| 2934 | +									$html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
 | |
| 2935 | +								}else{
 | |
| 2936 | + $html .= $email; | |
| 2937 | + } | |
| 2938 | + $html .= '</span></div>'; | |
| 2939 | + } | |
| 2478 | 2940 | |
| 2479 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . | |
| 2480 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2481 | -                            $html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$type['htmlvar_name']}) . '">' . $post->{$type['htmlvar_name']} . '</a></div>';
 | |
| 2941 | + } | |
| 2482 | 2942 | |
| 2483 | - endif; | |
| 2943 | + break; | |
| 2484 | 2944 | |
| 2485 | - break; | |
| 2486 | 2945 | |
| 2487 | - case 'time': | |
| 2946 | + case 'file': | |
| 2488 | 2947 | |
| 2489 | - $html_var = $type['htmlvar_name']; | |
| 2948 | + $html_var = $type['htmlvar_name']; | |
| 2490 | 2949 | |
| 2491 | -                        if ($post->{$type['htmlvar_name']}):
 | |
| 2950 | +						if (!empty($post->{$type['htmlvar_name']})):
 | |
| 2492 | 2951 | |
| 2493 | - $value = ''; | |
| 2494 | -                            if ($post->{$type['htmlvar_name']} != '')
 | |
| 2495 | -                                //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
 | |
| 2496 | -                                $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
 | |
| 2952 | +							$files = explode(",", $post->{$type['htmlvar_name']});
 | |
| 2953 | + if (!empty($files)): | |
| 2497 | 2954 | |
| 2498 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2499 | - $field_icon_af = ''; | |
| 2500 | -                            } elseif ($field_icon == '') {
 | |
| 2501 | - $field_icon_af = '<i class="fa fa-clock-o"></i>'; | |
| 2502 | -                            } else {
 | |
| 2503 | - $field_icon_af = $field_icon; | |
| 2504 | - $field_icon = ''; | |
| 2505 | - } | |
| 2955 | + $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; | |
| 2956 | +								$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'] : '';
 | |
| 2506 | 2957 | |
| 2507 | - $geodir_odd_even = ''; | |
| 2508 | -                            if ($fields_location == 'detail') {
 | |
| 2958 | + $file_paths = ''; | |
| 2959 | +								foreach ($files as $file) {
 | |
| 2960 | +									if (!empty($file)) {
 | |
| 2509 | 2961 | |
| 2510 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2511 | - if ($i % 2 == 0) | |
| 2512 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2962 | + // $filetype = wp_check_filetype($file); | |
| 2513 | 2963 | |
| 2514 | - $i++; | |
| 2515 | - } | |
| 2964 | +										$image_name_arr = explode('/', $file);
 | |
| 2965 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; | |
| 2966 | + $filename = end($image_name_arr); | |
| 2967 | +										$img_name_arr = explode('.', $filename);
 | |
| 2516 | 2968 | |
| 2517 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; | |
| 2518 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2519 | - $html .= '</span>' . $value . '</div>'; | |
| 2969 | + $arr_file_type = wp_check_filetype($filename); | |
| 2970 | +										if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
 | |
| 2971 | + continue; | |
| 2972 | + } | |
| 2520 | 2973 | |
| 2521 | - endif; | |
| 2974 | + $uploaded_file_type = $arr_file_type['type']; | |
| 2975 | + $uploaded_file_ext = $arr_file_type['ext']; | |
| 2522 | 2976 | |
| 2523 | - break; | |
| 2977 | +										if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
 | |
| 2978 | + continue; // Invalid file type. | |
| 2979 | + } | |
| 2524 | 2980 | |
| 2525 | - case 'datepicker': | |
| 2981 | +										//$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
 | |
| 2982 | +										$image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
 | |
| 2526 | 2983 | |
| 2527 | -                        if ($post->{$type['htmlvar_name']}):
 | |
| 2984 | + // If the uploaded file is image | |
| 2985 | +										if (in_array($uploaded_file_type, $image_file_types)) {
 | |
| 2986 | + $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; | |
| 2987 | + $file_paths .= '<a href="'.$file.'">'; | |
| 2988 | +											$file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
 | |
| 2989 | + $file_paths .= '</a>'; | |
| 2990 | + //$file_paths .= '<img src="'.$file.'" />'; | |
| 2991 | + $file_paths .= '</div>'; | |
| 2992 | +										} else {
 | |
| 2993 | + $ext_path = '_' . $html_var . '_'; | |
| 2994 | + $filename = explode($ext_path, $filename); | |
| 2995 | + $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; | |
| 2996 | + } | |
| 2997 | + } | |
| 2998 | + } | |
| 2528 | 2999 | |
| 2529 | - $date_format = geodir_default_date_format(); | |
| 2530 | -                            if ($type['extra_fields'] != '') {
 | |
| 2531 | - $date_format = unserialize($type['extra_fields']); | |
| 2532 | - $date_format = $date_format['date_format']; | |
| 2533 | - } | |
| 2534 | - // check if we need to change the format or not | |
| 2535 | -                            $date_format_len = strlen(str_replace(' ', '', $date_format));
 | |
| 2536 | -                            if($date_format_len>5){// if greater then 4 then it's the old style format.
 | |
| 3000 | +								if (strpos($field_icon, 'http') !== false) {
 | |
| 3001 | + $field_icon_af = ''; | |
| 3002 | +								} elseif ($field_icon == '') {
 | |
| 3003 | + $field_icon_af = ''; | |
| 3004 | +								} else {
 | |
| 3005 | + $field_icon_af = $field_icon; | |
| 3006 | + $field_icon = ''; | |
| 3007 | + } | |
| 2537 | 3008 | |
| 2538 | -                                $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
 | |
| 2539 | -                                $replace = array('d','j','l','m','n','F','Y');//PHP date format
 | |
| 3009 | + $geodir_odd_even = ''; | |
| 3010 | +								if ($fields_location == 'detail') {
 | |
| 2540 | 3011 | |
| 2541 | - $date_format = str_replace($search, $replace, $date_format); | |
| 3012 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3013 | + if ($i % 2 == 0) | |
| 3014 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2542 | 3015 | |
| 2543 | -                                $post_htmlvar_value = ($date_format == 'd/m/Y' || $date_format == 'j/n/Y' ) ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
 | |
| 2544 | -                            }else{
 | |
| 2545 | -                                $post_htmlvar_value = $post->{$type['htmlvar_name']};
 | |
| 2546 | - } | |
| 3016 | + $i++; | |
| 3017 | + } | |
| 2547 | 3018 | |
| 2548 | -                            if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
 | |
| 2549 | - $value = date_i18n($date_format, strtotime($post_htmlvar_value)); | |
| 2550 | -                            }else{
 | |
| 2551 | - continue; | |
| 2552 | - } | |
| 3019 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; | |
| 3020 | + $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">'; | |
| 3021 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3022 | + $html .= '</span>'; | |
| 3023 | + $html .= $file_paths . '</div></div>'; | |
| 2553 | 3024 | |
| 2554 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2555 | - $field_icon_af = ''; | |
| 2556 | -                            } elseif ($field_icon == '') {
 | |
| 2557 | - $field_icon_af = '<i class="fa fa-calendar"></i>'; | |
| 2558 | -                            } else {
 | |
| 2559 | - $field_icon_af = $field_icon; | |
| 2560 | - $field_icon = ''; | |
| 2561 | - } | |
| 3025 | + endif; | |
| 3026 | + endif; | |
| 2562 | 3027 | |
| 2563 | - $geodir_odd_even = ''; | |
| 2564 | -                            if ($fields_location == 'detail') {
 | |
| 3028 | + break; | |
| 2565 | 3029 | |
| 2566 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2567 | - if ($i % 2 == 0) | |
| 2568 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3030 | + case 'textarea': | |
| 3031 | + $html_var = $type['htmlvar_name']; | |
| 2569 | 3032 | |
| 2570 | - $i++; | |
| 2571 | - } | |
| 3033 | +						if (!empty($post->{$type['htmlvar_name']})) {
 | |
| 2572 | 3034 | |
| 2573 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; | |
| 2574 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2575 | - $html .= '</span>' . $value . '</div>'; | |
| 3035 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 3036 | + $field_icon_af = ''; | |
| 3037 | +							} elseif ($field_icon == '') {
 | |
| 3038 | + $field_icon_af = ''; | |
| 3039 | +							} else {
 | |
| 3040 | + $field_icon_af = $field_icon; | |
| 3041 | + $field_icon = ''; | |
| 3042 | + } | |
| 3043 | + | |
| 3044 | + $geodir_odd_even = ''; | |
| 3045 | +							if ($fields_location == 'detail') {
 | |
| 3046 | + | |
| 3047 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3048 | + if ($i % 2 == 0) | |
| 3049 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 3050 | + | |
| 3051 | + $i++; | |
| 3052 | + } | |
| 2576 | 3053 | |
| 2577 | - endif; | |
| 3054 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; | |
| 3055 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3056 | +							$html .= '</span>' . wpautop($post->{$type['htmlvar_name']}) . '</div>';
 | |
| 2578 | 3057 | |
| 2579 | - break; | |
| 3058 | + } | |
| 3059 | + break; | |
| 2580 | 3060 | |
| 2581 | - case 'text': | |
| 3061 | + case 'html': | |
| 3062 | +						if (!empty($post->{$type['htmlvar_name']})) {
 | |
| 2582 | 3063 | |
| 2583 | - $html_var = $type['htmlvar_name']; | |
| 3064 | +							if (strpos($field_icon, 'http') !== false) {
 | |
| 3065 | + $field_icon_af = ''; | |
| 3066 | +							} elseif ($field_icon == '') {
 | |
| 3067 | + $field_icon_af = ''; | |
| 3068 | +							} else {
 | |
| 3069 | + $field_icon_af = $field_icon; | |
| 3070 | + $field_icon = ''; | |
| 3071 | + } | |
| 2584 | 3072 | |
| 2585 | -                        if (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']} != '' && $type['htmlvar_name'] == 'geodir_timing'):
 | |
| 3073 | + $geodir_odd_even = ''; | |
| 3074 | +							if ($fields_location == 'detail') {
 | |
| 2586 | 3075 | |
| 2587 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2588 | - $field_icon_af = ''; | |
| 2589 | -                            } elseif ($field_icon == '') {
 | |
| 2590 | - $field_icon_af = '<i class="fa fa-clock-o"></i>'; | |
| 2591 | -                            } else {
 | |
| 2592 | - $field_icon_af = $field_icon; | |
| 2593 | - $field_icon = ''; | |
| 2594 | - } | |
| 3076 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3077 | + if ($i % 2 == 0) | |
| 3078 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 2595 | 3079 | |
| 2596 | - $geodir_odd_even = ''; | |
| 2597 | -                            if ($fields_location == 'detail') {
 | |
| 3080 | + $i++; | |
| 3081 | + } | |
| 2598 | 3082 | |
| 2599 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2600 | - if ($i % 2 == 0) | |
| 2601 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3083 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; | |
| 3084 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3085 | +							$html .= '</span>' . wpautop($post->{$type['htmlvar_name']}) . '</div>';
 | |
| 3086 | + | |
| 3087 | + } | |
| 3088 | + break; | |
| 3089 | +					case 'taxonomy': {
 | |
| 3090 | + $html_var = $type['htmlvar_name']; | |
| 3091 | +						if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) {
 | |
| 3092 | + $post_taxonomy = $post->post_type . 'category'; | |
| 3093 | +							$field_value = $post->{$html_var};
 | |
| 3094 | + $links = array(); | |
| 3095 | + $terms = array(); | |
| 3096 | + $termsOrdered = array(); | |
| 3097 | +							if (!is_array($field_value)) {
 | |
| 3098 | +								$field_value = explode(",", trim($field_value, ","));
 | |
| 3099 | + } | |
| 2602 | 3100 | |
| 2603 | - $i++; | |
| 2604 | - } | |
| 3101 | + $field_value = array_unique($field_value); | |
| 2605 | 3102 | |
| 2606 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; | |
| 2607 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; | |
| 2608 | -                            $html .= '</span>' . $post->{$type['htmlvar_name']} . '</div>';
 | |
| 3103 | +							if (!empty($field_value)) {
 | |
| 3104 | +								foreach ($field_value as $term) {
 | |
| 3105 | + $term = trim($term); | |
| 2609 | 3106 | |
| 2610 | -                        elseif (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']}):
 | |
| 3107 | +									if ($term != '') {
 | |
| 3108 | +										$term = get_term_by('id', $term, $html_var);
 | |
| 3109 | +										if (is_object($term)) {
 | |
| 3110 | + $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; | |
| 3111 | + $terms[] = $term; | |
| 3112 | + } | |
| 3113 | + } | |
| 3114 | + } | |
| 3115 | +								if (!empty($links)) {
 | |
| 3116 | + // order alphabetically | |
| 3117 | + asort($links); | |
| 3118 | +									foreach (array_keys($links) as $key) {
 | |
| 3119 | + $termsOrdered[$key] = $terms[$key]; | |
| 3120 | + } | |
| 3121 | + $terms = $termsOrdered; | |
| 3122 | + } | |
| 3123 | + } | |
| 3124 | +							$html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
 | |
| 3125 | + | |
| 3126 | +							if ($html_value != '') {
 | |
| 3127 | +								if (strpos($field_icon, 'http') !== false) {
 | |
| 3128 | + $field_icon_af = ''; | |
| 3129 | +								} else if ($field_icon == '') {
 | |
| 3130 | + $field_icon_af = ''; | |
| 3131 | +								} else {
 | |
| 3132 | + $field_icon_af = $field_icon; | |
| 3133 | + $field_icon = ''; | |
| 3134 | + } | |
| 3135 | + | |
| 3136 | + $geodir_odd_even = ''; | |
| 3137 | +								if ($fields_location == 'detail') {
 | |
| 3138 | + $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3139 | +									if ($i % 2 == 0) {
 | |
| 3140 | + $geodir_odd_even = 'geodir_more_info_even'; | |
| 3141 | + } | |
| 3142 | + $i++; | |
| 3143 | + } | |
| 3144 | + | |
| 3145 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; | |
| 3146 | + $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3147 | + $html .= '</span> ' . $html_value . '</div>'; | |
| 3148 | + } | |
| 3149 | + } | |
| 3150 | + } | |
| 3151 | + break; | |
| 2611 | 3152 | |
| 2612 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2613 | - $field_icon_af = ''; | |
| 2614 | -                            } elseif ($field_icon == '') {
 | |
| 2615 | - $field_icon_af = ''; | |
| 2616 | -                            } else {
 | |
| 2617 | - $field_icon_af = $field_icon; | |
| 2618 | - $field_icon = ''; | |
| 2619 | - } | |
| 3153 | + } | |
| 2620 | 3154 | |
| 2621 | - $geodir_odd_even = ''; | |
| 2622 | -                            if ($fields_location == 'detail') {
 | |
| 2623 | - | |
| 2624 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2625 | - if ($i % 2 == 0) | |
| 2626 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2627 | - | |
| 2628 | - $i++; | |
| 2629 | - } | |
| 2630 | - | |
| 2631 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; | |
| 2632 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2633 | -                            $html .= '</span>' . $post->{$type['htmlvar_name']} . '</div>';
 | |
| 3155 | + if ($html): | |
| 2634 | 3156 | |
| 2635 | - endif; | |
| 3157 | + /** | |
| 3158 | + * Called before a custom fields is output on the frontend. | |
| 3159 | + * | |
| 3160 | + * @since 1.0.0 | |
| 3161 | + * @param string $html_var The HTML variable name for the field. | |
| 3162 | + */ | |
| 3163 | +					do_action("geodir_before_show_{$html_var}");
 | |
| 3164 | + /** | |
| 3165 | + * Filter custom field output. | |
| 3166 | + * | |
| 3167 | + * @since 1.0.0 | |
| 3168 | + * | |
| 3169 | + * @param string $html_var The HTML variable name for the field. | |
| 3170 | + * @param string $html Custom field unfiltered HTML. | |
| 3171 | + * @param array $variables_array Custom field variables array. | |
| 3172 | + */ | |
| 3173 | +					if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
 | |
| 2636 | 3174 | |
| 2637 | - break; | |
| 3175 | + /** | |
| 3176 | + * Called after a custom fields is output on the frontend. | |
| 3177 | + * | |
| 3178 | + * @since 1.0.0 | |
| 3179 | + * @param string $html_var The HTML variable name for the field. | |
| 3180 | + */ | |
| 3181 | +					do_action("geodir_after_show_{$html_var}");
 | |
| 2638 | 3182 | |
| 2639 | - case 'radio': | |
| 3183 | + endif; | |
| 2640 | 3184 | |
| 2641 | - $html_var = $type['htmlvar_name']; | |
| 2642 | -                        if(!isset($post->{$type['htmlvar_name']})){continue;}
 | |
| 2643 | -                        $html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
 | |
| 2644 | -                        if ($post->{$type['htmlvar_name']} != ''):
 | |
| 2645 | - | |
| 2646 | -                            if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
 | |
| 2647 | -                                $html_val = __('No', 'geodirectory');
 | |
| 2648 | -                            } else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
 | |
| 2649 | -                                $html_val = __('Yes', 'geodirectory');
 | |
| 2650 | -                            } else {
 | |
| 2651 | -                                if (!empty($type['option_values'])) {
 | |
| 2652 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); | |
| 2653 | - | |
| 2654 | -                                    if (!empty($cf_option_values)) {
 | |
| 2655 | -                                        foreach ($cf_option_values as $cf_option_value) {
 | |
| 2656 | -                                            if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
 | |
| 2657 | - $html_val = $cf_option_value['label']; | |
| 2658 | - } | |
| 2659 | - } | |
| 2660 | - } | |
| 2661 | - } | |
| 2662 | - } | |
| 2663 | - | |
| 2664 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2665 | - $field_icon_af = ''; | |
| 2666 | -                            } elseif ($field_icon == '') {
 | |
| 2667 | - $field_icon_af = ''; | |
| 2668 | -                            } else {
 | |
| 2669 | - $field_icon_af = $field_icon; | |
| 2670 | - $field_icon = ''; | |
| 2671 | - } | |
| 3185 | + } | |
| 2672 | 3186 | |
| 2673 | - $geodir_odd_even = ''; | |
| 2674 | -                            if ($fields_location == 'detail') {
 | |
| 3187 | + //echo '</div>'; | |
| 2675 | 3188 | |
| 2676 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2677 | - if ($i % 2 == 0) | |
| 2678 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3189 | + } | |
| 2679 | 3190 | |
| 2680 | - $i++; | |
| 2681 | - } | |
| 2682 | 3191 | |
| 2683 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; | |
| 2684 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2685 | - $html .= '</span>' . $html_val . '</div>'; | |
| 2686 | - endif; | |
| 2687 | - | |
| 2688 | - break; | |
| 2689 | - | |
| 2690 | - case 'checkbox': | |
| 2691 | - | |
| 2692 | - $html_var = $type['htmlvar_name']; | |
| 2693 | - | |
| 2694 | -                        if ((int)$post->{$html_var} == 1):
 | |
| 3192 | + return $html = ob_get_clean(); | |
| 2695 | 3193 | |
| 2696 | -                            if ($post->{$type['htmlvar_name']} == '1'):
 | |
| 2697 | -                                $html_val = __('Yes', 'geodirectory');
 | |
| 2698 | - else: | |
| 2699 | -                                $html_val = __('No', 'geodirectory');
 | |
| 2700 | - endif; | |
| 2701 | - | |
| 2702 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2703 | - $field_icon_af = ''; | |
| 2704 | -                            } elseif ($field_icon == '') {
 | |
| 2705 | - $field_icon_af = ''; | |
| 2706 | -                            } else {
 | |
| 2707 | - $field_icon_af = $field_icon; | |
| 2708 | - $field_icon = ''; | |
| 2709 | - } | |
| 2710 | - | |
| 2711 | - $geodir_odd_even = ''; | |
| 2712 | -                            if ($fields_location == 'detail') {
 | |
| 2713 | - | |
| 2714 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2715 | - if ($i % 2 == 0) | |
| 2716 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2717 | - | |
| 2718 | - $i++; | |
| 2719 | - } | |
| 2720 | - | |
| 2721 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; | |
| 2722 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2723 | - $html .= '</span>' . $html_val . '</div>'; | |
| 2724 | - endif; | |
| 2725 | - | |
| 2726 | - break; | |
| 2727 | - | |
| 2728 | - case 'select': | |
| 2729 | - | |
| 2730 | - $html_var = $type['htmlvar_name']; | |
| 2731 | -                        if(!isset($post->{$type['htmlvar_name']})){continue;}
 | |
| 2732 | -                        if ($post->{$type['htmlvar_name']}):
 | |
| 2733 | -                            $field_value = __($post->{$type['htmlvar_name']}, 'geodirectory');
 | |
| 2734 | - | |
| 2735 | -                            if (!empty($type['option_values'])) {
 | |
| 2736 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); | |
| 2737 | - | |
| 2738 | -                                if (!empty($cf_option_values)) {
 | |
| 2739 | -                                    foreach ($cf_option_values as $cf_option_value) {
 | |
| 2740 | -                                        if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
 | |
| 2741 | - //$field_value = $cf_option_value['label']; // no longer needed here. | |
| 2742 | - } | |
| 2743 | - } | |
| 2744 | - } | |
| 2745 | - } | |
| 2746 | - | |
| 2747 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2748 | - $field_icon_af = ''; | |
| 2749 | -                            } elseif ($field_icon == '') {
 | |
| 2750 | - $field_icon_af = ''; | |
| 2751 | -                            } else {
 | |
| 2752 | - $field_icon_af = $field_icon; | |
| 2753 | - $field_icon = ''; | |
| 2754 | - } | |
| 2755 | - | |
| 2756 | - $geodir_odd_even = ''; | |
| 2757 | -                            if ($fields_location == 'detail') {
 | |
| 2758 | - | |
| 2759 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2760 | - if ($i % 2 == 0) | |
| 2761 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2762 | - | |
| 2763 | - $i++; | |
| 2764 | - } | |
| 2765 | - | |
| 2766 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; | |
| 2767 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2768 | - $html .= '</span>' . $field_value . '</div>'; | |
| 2769 | - endif; | |
| 2770 | - | |
| 2771 | - break; | |
| 2772 | - | |
| 2773 | - | |
| 2774 | - case 'multiselect': | |
| 2775 | - | |
| 2776 | - $html_var = $type['htmlvar_name']; | |
| 2777 | - | |
| 2778 | -                        if (!empty($post->{$type['htmlvar_name']})):
 | |
| 2779 | - | |
| 2780 | -                            if (is_array($post->{$type['htmlvar_name']})) {
 | |
| 2781 | -                                $post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
 | |
| 2782 | - } | |
| 2783 | - | |
| 2784 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2785 | - $field_icon_af = ''; | |
| 2786 | -                            } elseif ($field_icon == '') {
 | |
| 2787 | - $field_icon_af = ''; | |
| 2788 | -                            } else {
 | |
| 2789 | - $field_icon_af = $field_icon; | |
| 2790 | - $field_icon = ''; | |
| 2791 | - } | |
| 2792 | - | |
| 2793 | -                            $field_values = explode(',', trim($post->{$type['htmlvar_name']}, ","));
 | |
| 2794 | - | |
| 2795 | - $option_values = array(); | |
| 2796 | -                            if (!empty($type['option_values'])) {
 | |
| 2797 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); | |
| 2798 | - | |
| 2799 | -                                if (!empty($cf_option_values)) {
 | |
| 2800 | -                                    foreach ($cf_option_values as $cf_option_value) {
 | |
| 2801 | -                                        if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
 | |
| 2802 | - $option_values[] = $cf_option_value['label']; | |
| 2803 | - } | |
| 2804 | - } | |
| 2805 | - } | |
| 2806 | - } | |
| 2807 | - | |
| 2808 | - $geodir_odd_even = ''; | |
| 2809 | -                            if ($fields_location == 'detail') {
 | |
| 2810 | - | |
| 2811 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2812 | - if ($i % 2 == 0) | |
| 2813 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2814 | - | |
| 2815 | - $i++; | |
| 2816 | - } | |
| 2817 | - | |
| 2818 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; | |
| 2819 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2820 | - $html .= '</span>'; | |
| 2821 | - | |
| 2822 | -                            if (count($option_values) > 1) {
 | |
| 2823 | - $html .= '<ul>'; | |
| 2824 | - | |
| 2825 | -                                foreach ($option_values as $val) {
 | |
| 2826 | - $html .= '<li>' . $val . '</li>'; | |
| 2827 | - } | |
| 2828 | - | |
| 2829 | - $html .= '</ul>'; | |
| 2830 | -                            } else {
 | |
| 2831 | -                                $html .= $post->{$type['htmlvar_name']};
 | |
| 2832 | - } | |
| 2833 | - | |
| 2834 | - $html .= '</div>'; | |
| 2835 | - endif; | |
| 2836 | - break; | |
| 2837 | - case 'email': | |
| 2838 | - $html_var = $type['htmlvar_name']; | |
| 2839 | -                        if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
 | |
| 2840 | - continue; // Remove Send Enquiry | Send To Friend from listings page | |
| 2841 | - } | |
| 2842 | - | |
| 2843 | -                        if ($type['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$type['htmlvar_name']})) {
 | |
| 2844 | - $send_to_friend = true; | |
| 2845 | - $b_send_inquiry = ''; | |
| 2846 | - $b_sendtofriend = ''; | |
| 2847 | - | |
| 2848 | - $html = ''; | |
| 2849 | -                            if (!$preview) {
 | |
| 2850 | - $b_send_inquiry = 'b_send_inquiry'; | |
| 2851 | - $b_sendtofriend = 'b_sendtofriend'; | |
| 2852 | - $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>'; | |
| 2853 | - } | |
| 2854 | - | |
| 2855 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 2856 | - $field_icon_af = ''; | |
| 2857 | -                            } elseif ($field_icon == '') {
 | |
| 2858 | - $field_icon_af = '<i class="fa fa-envelope"></i>'; | |
| 2859 | -                            } else {
 | |
| 2860 | - $field_icon_af = $field_icon; | |
| 2861 | - $field_icon = ''; | |
| 2862 | - } | |
| 2863 | - | |
| 2864 | - $geodir_odd_even = ''; | |
| 2865 | -                            if ($fields_location == 'detail') {
 | |
| 2866 | - | |
| 2867 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2868 | - if ($i % 2 == 0) | |
| 2869 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2870 | - | |
| 2871 | - $i++; | |
| 2872 | - } | |
| 2873 | - | |
| 2874 | - $html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; | |
| 2875 | - $seperator = ''; | |
| 2876 | -                            if ($post->{$type['htmlvar_name']}) {
 | |
| 2877 | - $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>'; | |
| 2878 | - $seperator = ' | '; | |
| 2879 | - } | |
| 2880 | - | |
| 2881 | -                            if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
 | |
| 2882 | - $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>'; | |
| 2883 | - } | |
| 2884 | - | |
| 2885 | - $html .= '</span></div>'; | |
| 2886 | - | |
| 2887 | - | |
| 2888 | -                            if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
 | |
| 2889 | - $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>'; | |
| 2890 | -                            } elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
 | |
| 2891 | - $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>'; | |
| 2892 | -                            } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
 | |
| 2893 | - $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>'; | |
| 2894 | - } | |
| 2895 | - | |
| 2896 | -                            /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
 | |
| 2897 | - | |
| 2898 | -                        } else {
 | |
| 2899 | - | |
| 2900 | -                            if ($post->{$type['htmlvar_name']}) {
 | |
| 2901 | -                                if (strpos($field_icon, 'http') !== false) {
 | |
| 2902 | - $field_icon_af = ''; | |
| 2903 | -                                } elseif ($field_icon == '') {
 | |
| 2904 | - $field_icon_af = '<i class="fa fa-envelope"></i>'; | |
| 2905 | -                                } else {
 | |
| 2906 | - $field_icon_af = $field_icon; | |
| 2907 | - $field_icon = ''; | |
| 2908 | - } | |
| 2909 | - | |
| 2910 | - $geodir_odd_even = ''; | |
| 2911 | -                                if ($fields_location == 'detail') {
 | |
| 2912 | - | |
| 2913 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 2914 | - if ($i % 2 == 0) | |
| 2915 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 2916 | - | |
| 2917 | - $i++; | |
| 2918 | - } | |
| 2919 | - | |
| 2920 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; | |
| 2921 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 2922 | - $html .= '</span><span class="geodir-email-address-output">'; | |
| 2923 | -                                $email = $post->{$type['htmlvar_name']} ;
 | |
| 2924 | -                                if($e_split = explode('@',$email)){
 | |
| 2925 | - /** | |
| 2926 | - * Filter email custom field name output. | |
| 2927 | - * | |
| 2928 | - * @since 1.5.3 | |
| 2929 | - * | |
| 2930 | - * @param string $email The email string being output. | |
| 2931 | - * @param array $type Custom field variables array. | |
| 2932 | - */ | |
| 2933 | -                                    $email_name = apply_filters('geodir_email_field_name_output',$email,$type);
 | |
| 2934 | -                                    $html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
 | |
| 2935 | -                                }else{
 | |
| 2936 | - $html .= $email; | |
| 2937 | - } | |
| 2938 | - $html .= '</span></div>'; | |
| 2939 | - } | |
| 2940 | - | |
| 2941 | - } | |
| 2942 | - | |
| 2943 | - break; | |
| 2944 | - | |
| 2945 | - | |
| 2946 | - case 'file': | |
| 2947 | - | |
| 2948 | - $html_var = $type['htmlvar_name']; | |
| 2949 | - | |
| 2950 | -                        if (!empty($post->{$type['htmlvar_name']})):
 | |
| 2951 | - | |
| 2952 | -                            $files = explode(",", $post->{$type['htmlvar_name']});
 | |
| 2953 | - if (!empty($files)): | |
| 2954 | - | |
| 2955 | - $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; | |
| 2956 | -                                $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'] : '';
 | |
| 2957 | - | |
| 2958 | - $file_paths = ''; | |
| 2959 | -                                foreach ($files as $file) {
 | |
| 2960 | -                                    if (!empty($file)) {
 | |
| 2961 | - | |
| 2962 | - // $filetype = wp_check_filetype($file); | |
| 2963 | - | |
| 2964 | -                                        $image_name_arr = explode('/', $file);
 | |
| 2965 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; | |
| 2966 | - $filename = end($image_name_arr); | |
| 2967 | -                                        $img_name_arr = explode('.', $filename);
 | |
| 2968 | - | |
| 2969 | - $arr_file_type = wp_check_filetype($filename); | |
| 2970 | -                                        if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
 | |
| 2971 | - continue; | |
| 2972 | - } | |
| 2973 | - | |
| 2974 | - $uploaded_file_type = $arr_file_type['type']; | |
| 2975 | - $uploaded_file_ext = $arr_file_type['ext']; | |
| 2976 | - | |
| 2977 | -                                        if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
 | |
| 2978 | - continue; // Invalid file type. | |
| 2979 | - } | |
| 2980 | - | |
| 2981 | -                                        //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
 | |
| 2982 | -                                        $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
 | |
| 2983 | - | |
| 2984 | - // If the uploaded file is image | |
| 2985 | -                                        if (in_array($uploaded_file_type, $image_file_types)) {
 | |
| 2986 | - $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; | |
| 2987 | - $file_paths .= '<a href="'.$file.'">'; | |
| 2988 | -                                            $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
 | |
| 2989 | - $file_paths .= '</a>'; | |
| 2990 | - //$file_paths .= '<img src="'.$file.'" />'; | |
| 2991 | - $file_paths .= '</div>'; | |
| 2992 | -                                        } else {
 | |
| 2993 | - $ext_path = '_' . $html_var . '_'; | |
| 2994 | - $filename = explode($ext_path, $filename); | |
| 2995 | - $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; | |
| 2996 | - } | |
| 2997 | - } | |
| 2998 | - } | |
| 2999 | - | |
| 3000 | -                                if (strpos($field_icon, 'http') !== false) {
 | |
| 3001 | - $field_icon_af = ''; | |
| 3002 | -                                } elseif ($field_icon == '') {
 | |
| 3003 | - $field_icon_af = ''; | |
| 3004 | -                                } else {
 | |
| 3005 | - $field_icon_af = $field_icon; | |
| 3006 | - $field_icon = ''; | |
| 3007 | - } | |
| 3008 | - | |
| 3009 | - $geodir_odd_even = ''; | |
| 3010 | -                                if ($fields_location == 'detail') {
 | |
| 3011 | - | |
| 3012 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3013 | - if ($i % 2 == 0) | |
| 3014 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3015 | - | |
| 3016 | - $i++; | |
| 3017 | - } | |
| 3018 | - | |
| 3019 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; | |
| 3020 | - $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">'; | |
| 3021 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3022 | - $html .= '</span>'; | |
| 3023 | - $html .= $file_paths . '</div></div>'; | |
| 3024 | - | |
| 3025 | - endif; | |
| 3026 | - endif; | |
| 3027 | - | |
| 3028 | - break; | |
| 3029 | - | |
| 3030 | - case 'textarea': | |
| 3031 | - $html_var = $type['htmlvar_name']; | |
| 3032 | - | |
| 3033 | -                        if (!empty($post->{$type['htmlvar_name']})) {
 | |
| 3034 | - | |
| 3035 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 3036 | - $field_icon_af = ''; | |
| 3037 | -                            } elseif ($field_icon == '') {
 | |
| 3038 | - $field_icon_af = ''; | |
| 3039 | -                            } else {
 | |
| 3040 | - $field_icon_af = $field_icon; | |
| 3041 | - $field_icon = ''; | |
| 3042 | - } | |
| 3043 | - | |
| 3044 | - $geodir_odd_even = ''; | |
| 3045 | -                            if ($fields_location == 'detail') {
 | |
| 3046 | - | |
| 3047 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3048 | - if ($i % 2 == 0) | |
| 3049 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3050 | - | |
| 3051 | - $i++; | |
| 3052 | - } | |
| 3053 | - | |
| 3054 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; | |
| 3055 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3056 | -                            $html .= '</span>' . wpautop($post->{$type['htmlvar_name']}) . '</div>';
 | |
| 3057 | - | |
| 3058 | - } | |
| 3059 | - break; | |
| 3060 | - | |
| 3061 | - case 'html': | |
| 3062 | -                        if (!empty($post->{$type['htmlvar_name']})) {
 | |
| 3063 | - | |
| 3064 | -                            if (strpos($field_icon, 'http') !== false) {
 | |
| 3065 | - $field_icon_af = ''; | |
| 3066 | -                            } elseif ($field_icon == '') {
 | |
| 3067 | - $field_icon_af = ''; | |
| 3068 | -                            } else {
 | |
| 3069 | - $field_icon_af = $field_icon; | |
| 3070 | - $field_icon = ''; | |
| 3071 | - } | |
| 3072 | - | |
| 3073 | - $geodir_odd_even = ''; | |
| 3074 | -                            if ($fields_location == 'detail') {
 | |
| 3075 | - | |
| 3076 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3077 | - if ($i % 2 == 0) | |
| 3078 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3079 | - | |
| 3080 | - $i++; | |
| 3081 | - } | |
| 3082 | - | |
| 3083 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; | |
| 3084 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3085 | -                            $html .= '</span>' . wpautop($post->{$type['htmlvar_name']}) . '</div>';
 | |
| 3086 | - | |
| 3087 | - } | |
| 3088 | - break; | |
| 3089 | -                    case 'taxonomy': {
 | |
| 3090 | - $html_var = $type['htmlvar_name']; | |
| 3091 | -                        if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) {
 | |
| 3092 | - $post_taxonomy = $post->post_type . 'category'; | |
| 3093 | -                            $field_value = $post->{$html_var};
 | |
| 3094 | - $links = array(); | |
| 3095 | - $terms = array(); | |
| 3096 | - $termsOrdered = array(); | |
| 3097 | -                            if (!is_array($field_value)) {
 | |
| 3098 | -                                $field_value = explode(",", trim($field_value, ","));
 | |
| 3099 | - } | |
| 3100 | - | |
| 3101 | - $field_value = array_unique($field_value); | |
| 3102 | - | |
| 3103 | -                            if (!empty($field_value)) {
 | |
| 3104 | -                                foreach ($field_value as $term) {
 | |
| 3105 | - $term = trim($term); | |
| 3106 | - | |
| 3107 | -                                    if ($term != '') {
 | |
| 3108 | -                                        $term = get_term_by('id', $term, $html_var);
 | |
| 3109 | -                                        if (is_object($term)) {
 | |
| 3110 | - $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; | |
| 3111 | - $terms[] = $term; | |
| 3112 | - } | |
| 3113 | - } | |
| 3114 | - } | |
| 3115 | -                                if (!empty($links)) {
 | |
| 3116 | - // order alphabetically | |
| 3117 | - asort($links); | |
| 3118 | -                                    foreach (array_keys($links) as $key) {
 | |
| 3119 | - $termsOrdered[$key] = $terms[$key]; | |
| 3120 | - } | |
| 3121 | - $terms = $termsOrdered; | |
| 3122 | - } | |
| 3123 | - } | |
| 3124 | -                            $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
 | |
| 3125 | - | |
| 3126 | -                            if ($html_value != '') {
 | |
| 3127 | -                                if (strpos($field_icon, 'http') !== false) {
 | |
| 3128 | - $field_icon_af = ''; | |
| 3129 | -                                } else if ($field_icon == '') {
 | |
| 3130 | - $field_icon_af = ''; | |
| 3131 | -                                } else {
 | |
| 3132 | - $field_icon_af = $field_icon; | |
| 3133 | - $field_icon = ''; | |
| 3134 | - } | |
| 3135 | - | |
| 3136 | - $geodir_odd_even = ''; | |
| 3137 | -                                if ($fields_location == 'detail') {
 | |
| 3138 | - $geodir_odd_even = 'geodir_more_info_odd'; | |
| 3139 | -                                    if ($i % 2 == 0) {
 | |
| 3140 | - $geodir_odd_even = 'geodir_more_info_even'; | |
| 3141 | - } | |
| 3142 | - $i++; | |
| 3143 | - } | |
| 3144 | - | |
| 3145 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; | |
| 3146 | - $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; | |
| 3147 | - $html .= '</span> ' . $html_value . '</div>'; | |
| 3148 | - } | |
| 3149 | - } | |
| 3150 | - } | |
| 3151 | - break; | |
| 3152 | - | |
| 3153 | - } | |
| 3154 | - | |
| 3155 | - if ($html): | |
| 3156 | - | |
| 3157 | - /** | |
| 3158 | - * Called before a custom fields is output on the frontend. | |
| 3159 | - * | |
| 3160 | - * @since 1.0.0 | |
| 3161 | - * @param string $html_var The HTML variable name for the field. | |
| 3162 | - */ | |
| 3163 | -                    do_action("geodir_before_show_{$html_var}");
 | |
| 3164 | - /** | |
| 3165 | - * Filter custom field output. | |
| 3166 | - * | |
| 3167 | - * @since 1.0.0 | |
| 3168 | - * | |
| 3169 | - * @param string $html_var The HTML variable name for the field. | |
| 3170 | - * @param string $html Custom field unfiltered HTML. | |
| 3171 | - * @param array $variables_array Custom field variables array. | |
| 3172 | - */ | |
| 3173 | -                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
 | |
| 3174 | - | |
| 3175 | - /** | |
| 3176 | - * Called after a custom fields is output on the frontend. | |
| 3177 | - * | |
| 3178 | - * @since 1.0.0 | |
| 3179 | - * @param string $html_var The HTML variable name for the field. | |
| 3180 | - */ | |
| 3181 | -                    do_action("geodir_after_show_{$html_var}");
 | |
| 3182 | - | |
| 3183 | - endif; | |
| 3184 | - | |
| 3185 | - } | |
| 3186 | - | |
| 3187 | - //echo '</div>'; | |
| 3188 | - | |
| 3189 | - } | |
| 3190 | - | |
| 3191 | - | |
| 3192 | - return $html = ob_get_clean(); | |
| 3193 | - | |
| 3194 | - } | |
| 3194 | + } | |
| 3195 | 3195 | } | 
| 3196 | 3196 | |
| 3197 | 3197 |  if (!function_exists('geodir_default_date_format')) {
 | 
| 3198 | - /** | |
| 3199 | - * Returns default date format. | |
| 3200 | - * | |
| 3201 | - * @since 1.0.0 | |
| 3202 | - * @package GeoDirectory | |
| 3203 | - * @return mixed|string|void Returns default date format. | |
| 3204 | - */ | |
| 3205 | - function geodir_default_date_format() | |
| 3206 | -    {
 | |
| 3207 | -        if ($format = get_option('date_format'))
 | |
| 3208 | - return $format; | |
| 3209 | - else | |
| 3210 | - return 'dd-mm-yy'; | |
| 3211 | - } | |
| 3198 | + /** | |
| 3199 | + * Returns default date format. | |
| 3200 | + * | |
| 3201 | + * @since 1.0.0 | |
| 3202 | + * @package GeoDirectory | |
| 3203 | + * @return mixed|string|void Returns default date format. | |
| 3204 | + */ | |
| 3205 | + function geodir_default_date_format() | |
| 3206 | +	{
 | |
| 3207 | +		if ($format = get_option('date_format'))
 | |
| 3208 | + return $format; | |
| 3209 | + else | |
| 3210 | + return 'dd-mm-yy'; | |
| 3211 | + } | |
| 3212 | 3212 | } | 
| 3213 | 3213 | |
| 3214 | 3214 |  if (!function_exists('geodir_get_formated_date')) {
 | 
| 3215 | - /** | |
| 3216 | - * Returns formatted date. | |
| 3217 | - * | |
| 3218 | - * @since 1.0.0 | |
| 3219 | - * @package GeoDirectory | |
| 3220 | - * @param string $date Date string to convert. | |
| 3221 | - * @return bool|int|string Returns formatted date. | |
| 3222 | - */ | |
| 3223 | - function geodir_get_formated_date($date) | |
| 3224 | -    {
 | |
| 3225 | -        return mysql2date(get_option('date_format'), $date);
 | |
| 3226 | - } | |
| 3215 | + /** | |
| 3216 | + * Returns formatted date. | |
| 3217 | + * | |
| 3218 | + * @since 1.0.0 | |
| 3219 | + * @package GeoDirectory | |
| 3220 | + * @param string $date Date string to convert. | |
| 3221 | + * @return bool|int|string Returns formatted date. | |
| 3222 | + */ | |
| 3223 | + function geodir_get_formated_date($date) | |
| 3224 | +	{
 | |
| 3225 | +		return mysql2date(get_option('date_format'), $date);
 | |
| 3226 | + } | |
| 3227 | 3227 | } | 
| 3228 | 3228 | |
| 3229 | 3229 |  if (!function_exists('geodir_get_formated_time')) {
 | 
| 3230 | - /** | |
| 3231 | - * Returns formatted time. | |
| 3232 | - * | |
| 3233 | - * @since 1.0.0 | |
| 3234 | - * @package GeoDirectory | |
| 3235 | - * @param string $time Time string to convert. | |
| 3236 | - * @return bool|int|string Returns formatted time. | |
| 3237 | - */ | |
| 3238 | - function geodir_get_formated_time($time) | |
| 3239 | -    {
 | |
| 3240 | -        return mysql2date(get_option('time_format'), $time, $translate = true);
 | |
| 3241 | - } | |
| 3230 | + /** | |
| 3231 | + * Returns formatted time. | |
| 3232 | + * | |
| 3233 | + * @since 1.0.0 | |
| 3234 | + * @package GeoDirectory | |
| 3235 | + * @param string $time Time string to convert. | |
| 3236 | + * @return bool|int|string Returns formatted time. | |
| 3237 | + */ | |
| 3238 | + function geodir_get_formated_time($time) | |
| 3239 | +	{
 | |
| 3240 | +		return mysql2date(get_option('time_format'), $time, $translate = true);
 | |
| 3241 | + } | |
| 3242 | 3242 | } | 
| 3243 | 3243 | |
| 3244 | 3244 | |
| 3245 | 3245 |  if (!function_exists('geodir_save_post_file_fields')) {
 | 
| 3246 | - /** | |
| 3247 | - * Save post file fields | |
| 3248 | - * | |
| 3249 | - * @since 1.0.0 | |
| 3250 | - * @since 1.4.7 Added `$extra_fields` parameter. | |
| 3251 | - * @package GeoDirectory | |
| 3252 | - * @global object $wpdb WordPress Database object. | |
| 3253 | - * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 3254 | - * @global object $current_user Current user object. | |
| 3255 | - * @param int $post_id | |
| 3256 | - * @param string $field_id | |
| 3257 | - * @param array $post_image | |
| 3258 | - * @param array $extra_fields Array of extra fields. | |
| 3259 | - */ | |
| 3260 | - function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) | |
| 3261 | -    {
 | |
| 3246 | + /** | |
| 3247 | + * Save post file fields | |
| 3248 | + * | |
| 3249 | + * @since 1.0.0 | |
| 3250 | + * @since 1.4.7 Added `$extra_fields` parameter. | |
| 3251 | + * @package GeoDirectory | |
| 3252 | + * @global object $wpdb WordPress Database object. | |
| 3253 | + * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 3254 | + * @global object $current_user Current user object. | |
| 3255 | + * @param int $post_id | |
| 3256 | + * @param string $field_id | |
| 3257 | + * @param array $post_image | |
| 3258 | + * @param array $extra_fields Array of extra fields. | |
| 3259 | + */ | |
| 3260 | + function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) | |
| 3261 | +	{
 | |
| 3262 | 3262 | |
| 3263 | - global $wpdb, $plugin_prefix, $current_user; | |
| 3263 | + global $wpdb, $plugin_prefix, $current_user; | |
| 3264 | 3264 | |
| 3265 | - $post_type = get_post_type($post_id); | |
| 3266 | - //echo $field_id; exit; | |
| 3267 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 3265 | + $post_type = get_post_type($post_id); | |
| 3266 | + //echo $field_id; exit; | |
| 3267 | + $table = $plugin_prefix . $post_type . '_detail'; | |
| 3268 | 3268 | |
| 3269 | - $postcurr_images = array(); | |
| 3270 | - $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); | |
| 3271 | - $file_urls = ''; | |
| 3269 | + $postcurr_images = array(); | |
| 3270 | + $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); | |
| 3271 | + $file_urls = ''; | |
| 3272 | 3272 | |
| 3273 | -        if (!empty($post_image)) {
 | |
| 3273 | +		if (!empty($post_image)) {
 | |
| 3274 | 3274 | |
| 3275 | - $invalid_files = array(); | |
| 3275 | + $invalid_files = array(); | |
| 3276 | 3276 | |
| 3277 | - //Get and remove all old images of post from database to set by new order | |
| 3278 | - $geodir_uploaddir = ''; | |
| 3279 | - $uploads = wp_upload_dir(); | |
| 3280 | - $uploads_dir = $uploads['path']; | |
| 3277 | + //Get and remove all old images of post from database to set by new order | |
| 3278 | + $geodir_uploaddir = ''; | |
| 3279 | + $uploads = wp_upload_dir(); | |
| 3280 | + $uploads_dir = $uploads['path']; | |
| 3281 | 3281 | |
| 3282 | - $geodir_uploadpath = $uploads['path']; | |
| 3283 | - $geodir_uploadurl = $uploads['url']; | |
| 3284 | - $sub_dir = $uploads['subdir']; | |
| 3282 | + $geodir_uploadpath = $uploads['path']; | |
| 3283 | + $geodir_uploadurl = $uploads['url']; | |
| 3284 | + $sub_dir = $uploads['subdir']; | |
| 3285 | 3285 | |
| 3286 | -            $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'] : '';
 | |
| 3286 | +			$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'] : '';
 | |
| 3287 | 3287 | |
| 3288 | -            for ($m = 0; $m < count($post_image); $m++) {
 | |
| 3288 | +			for ($m = 0; $m < count($post_image); $m++) {
 | |
| 3289 | 3289 | |
| 3290 | - /* --------- start ------- */ | |
| 3290 | + /* --------- start ------- */ | |
| 3291 | 3291 | |
| 3292 | -                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)))) {
 | |
| 3292 | +				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)))) {
 | |
| 3293 | 3293 | |
| 3294 | 3294 | |
| 3295 | - $curr_img_url = $post_image[$m]; | |
| 3296 | -                    $image_name_arr = explode('/', $curr_img_url);
 | |
| 3297 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; | |
| 3298 | - $filename = end($image_name_arr); | |
| 3299 | -                    $img_name_arr = explode('.', $filename);
 | |
| 3295 | + $curr_img_url = $post_image[$m]; | |
| 3296 | +					$image_name_arr = explode('/', $curr_img_url);
 | |
| 3297 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; | |
| 3298 | + $filename = end($image_name_arr); | |
| 3299 | +					$img_name_arr = explode('.', $filename);
 | |
| 3300 | 3300 | |
| 3301 | - $arr_file_type = wp_check_filetype($filename); | |
| 3301 | + $arr_file_type = wp_check_filetype($filename); | |
| 3302 | 3302 | |
| 3303 | -                    if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
 | |
| 3304 | - continue; | |
| 3305 | - } | |
| 3303 | +					if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
 | |
| 3304 | + continue; | |
| 3305 | + } | |
| 3306 | 3306 | |
| 3307 | - $uploaded_file_type = $arr_file_type['type']; | |
| 3308 | - $uploaded_file_ext = $arr_file_type['ext']; | |
| 3307 | + $uploaded_file_type = $arr_file_type['type']; | |
| 3308 | + $uploaded_file_ext = $arr_file_type['ext']; | |
| 3309 | 3309 | |
| 3310 | -                    if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
 | |
| 3311 | - continue; // Invalid file type. | |
| 3312 | - } | |
| 3310 | +					if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
 | |
| 3311 | + continue; // Invalid file type. | |
| 3312 | + } | |
| 3313 | 3313 | |
| 3314 | - // Set an array containing a list of acceptable formats | |
| 3315 | -                    //$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');
 | |
| 3314 | + // Set an array containing a list of acceptable formats | |
| 3315 | +					//$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');
 | |
| 3316 | 3316 | |
| 3317 | -                    if (!function_exists('wp_handle_upload'))
 | |
| 3318 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); | |
| 3317 | +					if (!function_exists('wp_handle_upload'))
 | |
| 3318 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); | |
| 3319 | 3319 | |
| 3320 | - if (!is_dir($geodir_uploadpath)) | |
| 3321 | - mkdir($geodir_uploadpath); | |
| 3320 | + if (!is_dir($geodir_uploadpath)) | |
| 3321 | + mkdir($geodir_uploadpath); | |
| 3322 | 3322 | |
| 3323 | - $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; | |
| 3324 | -                    $explode_sub_dir = explode("/", $sub_dir);
 | |
| 3325 | -                    if ($curr_img_dir == end($explode_sub_dir)) {
 | |
| 3326 | - $img_path = $geodir_uploadpath . '/' . $filename; | |
| 3327 | - $img_url = $geodir_uploadurl . '/' . $filename; | |
| 3328 | -                    } else {
 | |
| 3329 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 3330 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 3331 | - } | |
| 3323 | + $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; | |
| 3324 | +					$explode_sub_dir = explode("/", $sub_dir);
 | |
| 3325 | +					if ($curr_img_dir == end($explode_sub_dir)) {
 | |
| 3326 | + $img_path = $geodir_uploadpath . '/' . $filename; | |
| 3327 | + $img_url = $geodir_uploadurl . '/' . $filename; | |
| 3328 | +					} else {
 | |
| 3329 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 3330 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 3331 | + } | |
| 3332 | 3332 | |
| 3333 | - $uploaded_file = ''; | |
| 3334 | - if (file_exists($img_path)) | |
| 3335 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); | |
| 3333 | + $uploaded_file = ''; | |
| 3334 | + if (file_exists($img_path)) | |
| 3335 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); | |
| 3336 | 3336 | |
| 3337 | -                    if ($curr_img_dir != $geodir_uploaddir) {
 | |
| 3338 | - if (file_exists($img_path)) | |
| 3339 | - unlink($img_path); | |
| 3340 | - } | |
| 3337 | +					if ($curr_img_dir != $geodir_uploaddir) {
 | |
| 3338 | + if (file_exists($img_path)) | |
| 3339 | + unlink($img_path); | |
| 3340 | + } | |
| 3341 | 3341 | |
| 3342 | - if (!empty($uploaded_file)) | |
| 3343 | - $file_urls = $geodir_uploadurl . '/' . $new_name; | |
| 3342 | + if (!empty($uploaded_file)) | |
| 3343 | + $file_urls = $geodir_uploadurl . '/' . $new_name; | |
| 3344 | 3344 | |
| 3345 | -                } else {
 | |
| 3346 | - $file_urls = $post_image[$m]; | |
| 3347 | - } | |
| 3348 | - } | |
| 3345 | +				} else {
 | |
| 3346 | + $file_urls = $post_image[$m]; | |
| 3347 | + } | |
| 3348 | + } | |
| 3349 | 3349 | |
| 3350 | 3350 | |
| 3351 | - } | |
| 3351 | + } | |
| 3352 | 3352 | |
| 3353 | - //Remove all old attachments and temp images | |
| 3354 | -        if (!empty($postcurr_images)) {
 | |
| 3353 | + //Remove all old attachments and temp images | |
| 3354 | +		if (!empty($postcurr_images)) {
 | |
| 3355 | 3355 | |
| 3356 | -            if ($file_urls != $postcurr_images) {
 | |
| 3357 | -                $invalid_files[] = (object)array('src' => $postcurr_images);
 | |
| 3358 | - $invalid_files = (object)$invalid_files; | |
| 3359 | - } | |
| 3360 | - } | |
| 3356 | +			if ($file_urls != $postcurr_images) {
 | |
| 3357 | +				$invalid_files[] = (object)array('src' => $postcurr_images);
 | |
| 3358 | + $invalid_files = (object)$invalid_files; | |
| 3359 | + } | |
| 3360 | + } | |
| 3361 | 3361 | |
| 3362 | - geodir_save_post_meta($post_id, $field_id, $file_urls); | |
| 3362 | + geodir_save_post_meta($post_id, $field_id, $file_urls); | |
| 3363 | 3363 | |
| 3364 | - if (!empty($invalid_files)) | |
| 3365 | - geodir_remove_attachments($invalid_files); | |
| 3364 | + if (!empty($invalid_files)) | |
| 3365 | + geodir_remove_attachments($invalid_files); | |
| 3366 | 3366 | |
| 3367 | - } | |
| 3367 | + } | |
| 3368 | 3368 | } | 
| 3369 | 3369 | |
| 3370 | 3370 | |
| @@ -3379,76 +3379,76 @@ discard block | ||
| 3379 | 3379 | */ | 
| 3380 | 3380 | function geodir_custom_upload_mimes($existing_mimes = array()) | 
| 3381 | 3381 |  {
 | 
| 3382 | - $existing_mimes['wif'] = 'text/plain'; | |
| 3383 | - $existing_mimes['jpg|jpeg'] = 'image/jpeg'; | |
| 3384 | - $existing_mimes['gif'] = 'image/gif'; | |
| 3385 | - $existing_mimes['png'] = 'image/png'; | |
| 3386 | - $existing_mimes['pdf'] = 'application/pdf'; | |
| 3387 | - $existing_mimes['txt'] = 'text/text'; | |
| 3388 | - $existing_mimes['csv'] = 'application/octet-stream'; | |
| 3389 | - $existing_mimes['doc'] = 'application/msword'; | |
| 3390 | - $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; | |
| 3391 | - $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; | |
| 3392 | - $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; | |
| 3393 | - return $existing_mimes; | |
| 3382 | + $existing_mimes['wif'] = 'text/plain'; | |
| 3383 | + $existing_mimes['jpg|jpeg'] = 'image/jpeg'; | |
| 3384 | + $existing_mimes['gif'] = 'image/gif'; | |
| 3385 | + $existing_mimes['png'] = 'image/png'; | |
| 3386 | + $existing_mimes['pdf'] = 'application/pdf'; | |
| 3387 | + $existing_mimes['txt'] = 'text/text'; | |
| 3388 | + $existing_mimes['csv'] = 'application/octet-stream'; | |
| 3389 | + $existing_mimes['doc'] = 'application/msword'; | |
| 3390 | + $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; | |
| 3391 | + $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; | |
| 3392 | + $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; | |
| 3393 | + return $existing_mimes; | |
| 3394 | 3394 | } | 
| 3395 | 3395 | |
| 3396 | 3396 |  if (!function_exists('geodir_plupload_action')) {
 | 
| 3397 | 3397 | |
| 3398 | - /** | |
| 3399 | - * Get upload directory path details | |
| 3400 | - * | |
| 3401 | - * @since 1.0.0 | |
| 3402 | - * @package GeoDirectory | |
| 3403 | - * @global object $current_user Current user object. | |
| 3404 | - * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. | |
| 3405 | - * @return mixed Returns upload directory details as an array. | |
| 3406 | - */ | |
| 3407 | - function geodir_upload_dir($upload) | |
| 3408 | -    {
 | |
| 3409 | - global $current_user; | |
| 3410 | - $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; | |
| 3411 | - $upload['path'] = $upload['basedir'] . $upload['subdir']; | |
| 3412 | - $upload['url'] = $upload['baseurl'] . $upload['subdir']; | |
| 3413 | - return $upload; | |
| 3414 | - } | |
| 3415 | - | |
| 3416 | - /** | |
| 3417 | - * Handles place file and image upload. | |
| 3418 | - * | |
| 3419 | - * @since 1.0.0 | |
| 3420 | - * @package GeoDirectory | |
| 3421 | - */ | |
| 3422 | - function geodir_plupload_action() | |
| 3423 | -    {
 | |
| 3424 | - // check ajax noonce | |
| 3425 | - $imgid = $_POST["imgid"]; | |
| 3426 | - | |
| 3427 | - check_ajax_referer($imgid . 'pluploadan'); | |
| 3428 | - | |
| 3429 | - // handle custom file uploaddir | |
| 3430 | -        add_filter('upload_dir', 'geodir_upload_dir');
 | |
| 3431 | - | |
| 3432 | - // change file orinetation if needed | |
| 3433 | - $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); | |
| 3434 | - | |
| 3435 | - // handle file upload | |
| 3436 | -        $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
 | |
| 3437 | - // remove handle custom file uploaddir | |
| 3438 | -        remove_filter('upload_dir', 'geodir_upload_dir');
 | |
| 3439 | - | |
| 3440 | -        if(!isset($status['url']) && isset($status['error'])){
 | |
| 3441 | - print_r($status); | |
| 3442 | - } | |
| 3443 | - | |
| 3444 | - // send the uploaded file url in response | |
| 3445 | -        if (isset($status['url'])) {
 | |
| 3446 | - echo $status['url']; | |
| 3447 | -        } else {
 | |
| 3448 | - echo 'x'; | |
| 3449 | - } | |
| 3450 | - exit; | |
| 3451 | - } | |
| 3398 | + /** | |
| 3399 | + * Get upload directory path details | |
| 3400 | + * | |
| 3401 | + * @since 1.0.0 | |
| 3402 | + * @package GeoDirectory | |
| 3403 | + * @global object $current_user Current user object. | |
| 3404 | + * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. | |
| 3405 | + * @return mixed Returns upload directory details as an array. | |
| 3406 | + */ | |
| 3407 | + function geodir_upload_dir($upload) | |
| 3408 | +	{
 | |
| 3409 | + global $current_user; | |
| 3410 | + $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; | |
| 3411 | + $upload['path'] = $upload['basedir'] . $upload['subdir']; | |
| 3412 | + $upload['url'] = $upload['baseurl'] . $upload['subdir']; | |
| 3413 | + return $upload; | |
| 3414 | + } | |
| 3415 | + | |
| 3416 | + /** | |
| 3417 | + * Handles place file and image upload. | |
| 3418 | + * | |
| 3419 | + * @since 1.0.0 | |
| 3420 | + * @package GeoDirectory | |
| 3421 | + */ | |
| 3422 | + function geodir_plupload_action() | |
| 3423 | +	{
 | |
| 3424 | + // check ajax noonce | |
| 3425 | + $imgid = $_POST["imgid"]; | |
| 3426 | + | |
| 3427 | + check_ajax_referer($imgid . 'pluploadan'); | |
| 3428 | + | |
| 3429 | + // handle custom file uploaddir | |
| 3430 | +		add_filter('upload_dir', 'geodir_upload_dir');
 | |
| 3431 | + | |
| 3432 | + // change file orinetation if needed | |
| 3433 | + $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); | |
| 3434 | + | |
| 3435 | + // handle file upload | |
| 3436 | +		$status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
 | |
| 3437 | + // remove handle custom file uploaddir | |
| 3438 | +		remove_filter('upload_dir', 'geodir_upload_dir');
 | |
| 3439 | + | |
| 3440 | +		if(!isset($status['url']) && isset($status['error'])){
 | |
| 3441 | + print_r($status); | |
| 3442 | + } | |
| 3443 | + | |
| 3444 | + // send the uploaded file url in response | |
| 3445 | +		if (isset($status['url'])) {
 | |
| 3446 | + echo $status['url']; | |
| 3447 | +		} else {
 | |
| 3448 | + echo 'x'; | |
| 3449 | + } | |
| 3450 | + exit; | |
| 3451 | + } | |
| 3452 | 3452 | } | 
| 3453 | 3453 | |
| 3454 | 3454 | /** | 
| @@ -3463,17 +3463,17 @@ discard block | ||
| 3463 | 3463 | */ | 
| 3464 | 3464 | function geodir_get_video($post_id) | 
| 3465 | 3465 |  {
 | 
| 3466 | - global $wpdb, $plugin_prefix; | |
| 3466 | + global $wpdb, $plugin_prefix; | |
| 3467 | 3467 | |
| 3468 | - $post_type = get_post_type($post_id); | |
| 3468 | + $post_type = get_post_type($post_id); | |
| 3469 | 3469 | |
| 3470 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 3470 | + $table = $plugin_prefix . $post_type . '_detail'; | |
| 3471 | 3471 | |
| 3472 | -    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
 | |
| 3472 | +	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
 | |
| 3473 | 3473 | |
| 3474 | -    if ($results) {
 | |
| 3475 | - return $results[0]->geodir_video; | |
| 3476 | - } | |
| 3474 | +	if ($results) {
 | |
| 3475 | + return $results[0]->geodir_video; | |
| 3476 | + } | |
| 3477 | 3477 | |
| 3478 | 3478 | } | 
| 3479 | 3479 | |
| @@ -3489,40 +3489,40 @@ discard block | ||
| 3489 | 3489 | */ | 
| 3490 | 3490 | function geodir_get_special_offers($post_id) | 
| 3491 | 3491 |  {
 | 
| 3492 | - global $wpdb, $plugin_prefix; | |
| 3492 | + global $wpdb, $plugin_prefix; | |
| 3493 | 3493 | |
| 3494 | - $post_type = get_post_type($post_id); | |
| 3494 | + $post_type = get_post_type($post_id); | |
| 3495 | 3495 | |
| 3496 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 3496 | + $table = $plugin_prefix . $post_type . '_detail'; | |
| 3497 | 3497 | |
| 3498 | -    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
 | |
| 3498 | +	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
 | |
| 3499 | 3499 | |
| 3500 | -    if ($results) {
 | |
| 3501 | - return $results[0]->geodir_special_offers; | |
| 3502 | - } | |
| 3500 | +	if ($results) {
 | |
| 3501 | + return $results[0]->geodir_special_offers; | |
| 3502 | + } | |
| 3503 | 3503 | |
| 3504 | 3504 | } | 
| 3505 | 3505 | |
| 3506 | 3506 |  if (!function_exists('geodir_max_upload_size')) {
 | 
| 3507 | - /** | |
| 3508 | - * Get max upload file size | |
| 3509 | - * | |
| 3510 | - * @since 1.0.0 | |
| 3511 | - * @package GeoDirectory | |
| 3512 | - * @return mixed|void Returns max upload file size. | |
| 3513 | - */ | |
| 3514 | - function geodir_max_upload_size() | |
| 3515 | -    {
 | |
| 3516 | -        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
 | |
| 3517 | - | |
| 3518 | -        if ($max_filesize > 0 && $max_filesize < 1) {
 | |
| 3519 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; | |
| 3520 | -        } else {
 | |
| 3521 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; | |
| 3522 | - } | |
| 3523 | - /** Filter documented in geodirectory-functions/general_functions.php **/ | |
| 3524 | -        return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
 | |
| 3525 | - } | |
| 3507 | + /** | |
| 3508 | + * Get max upload file size | |
| 3509 | + * | |
| 3510 | + * @since 1.0.0 | |
| 3511 | + * @package GeoDirectory | |
| 3512 | + * @return mixed|void Returns max upload file size. | |
| 3513 | + */ | |
| 3514 | + function geodir_max_upload_size() | |
| 3515 | +	{
 | |
| 3516 | +		$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
 | |
| 3517 | + | |
| 3518 | +		if ($max_filesize > 0 && $max_filesize < 1) {
 | |
| 3519 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; | |
| 3520 | +		} else {
 | |
| 3521 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; | |
| 3522 | + } | |
| 3523 | + /** Filter documented in geodirectory-functions/general_functions.php **/ | |
| 3524 | +		return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
 | |
| 3525 | + } | |
| 3526 | 3526 | } | 
| 3527 | 3527 | |
| 3528 | 3528 | |
| @@ -3540,33 +3540,33 @@ discard block | ||
| 3540 | 3540 | */ | 
| 3541 | 3541 | function geodir_add_custom_sort_options($fields, $post_type) | 
| 3542 | 3542 |  {
 | 
| 3543 | - global $wpdb; | |
| 3543 | + global $wpdb; | |
| 3544 | 3544 | |
| 3545 | -    if ($post_type != '') {
 | |
| 3545 | +	if ($post_type != '') {
 | |
| 3546 | 3546 | |
| 3547 | - $all_postypes = geodir_get_posttypes(); | |
| 3547 | + $all_postypes = geodir_get_posttypes(); | |
| 3548 | 3548 | |
| 3549 | -        if (in_array($post_type, $all_postypes)) {
 | |
| 3549 | +		if (in_array($post_type, $all_postypes)) {
 | |
| 3550 | 3550 | |
| 3551 | - $custom_fields = $wpdb->get_results( | |
| 3552 | - $wpdb->prepare( | |
| 3553 | - "select post_type,data_type,field_type,site_title,htmlvar_name 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", | |
| 3554 | - array($post_type) | |
| 3555 | - ), 'ARRAY_A' | |
| 3556 | - ); | |
| 3551 | + $custom_fields = $wpdb->get_results( | |
| 3552 | + $wpdb->prepare( | |
| 3553 | + "select post_type,data_type,field_type,site_title,htmlvar_name 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", | |
| 3554 | + array($post_type) | |
| 3555 | + ), 'ARRAY_A' | |
| 3556 | + ); | |
| 3557 | 3557 | |
| 3558 | -            if (!empty($custom_fields)) {
 | |
| 3558 | +			if (!empty($custom_fields)) {
 | |
| 3559 | 3559 | |
| 3560 | -                foreach ($custom_fields as $val) {
 | |
| 3561 | - $fields[] = $val; | |
| 3562 | - } | |
| 3563 | - } | |
| 3560 | +				foreach ($custom_fields as $val) {
 | |
| 3561 | + $fields[] = $val; | |
| 3562 | + } | |
| 3563 | + } | |
| 3564 | 3564 | |
| 3565 | - } | |
| 3565 | + } | |
| 3566 | 3566 | |
| 3567 | - } | |
| 3567 | + } | |
| 3568 | 3568 | |
| 3569 | - return $fields; | |
| 3569 | + return $fields; | |
| 3570 | 3570 | } | 
| 3571 | 3571 | |
| 3572 | 3572 | |
| @@ -3582,66 +3582,66 @@ discard block | ||
| 3582 | 3582 | function geodir_get_custom_sort_options($post_type = '') | 
| 3583 | 3583 |  {
 | 
| 3584 | 3584 | |
| 3585 | - global $wpdb; | |
| 3586 | - | |
| 3587 | -    if ($post_type != '') {
 | |
| 3588 | - | |
| 3589 | - $all_postypes = geodir_get_posttypes(); | |
| 3590 | - | |
| 3591 | - if (!in_array($post_type, $all_postypes)) | |
| 3592 | - return false; | |
| 3593 | - | |
| 3594 | - $fields = array(); | |
| 3595 | - | |
| 3596 | - $fields[] = array( | |
| 3597 | - 'post_type' => $post_type, | |
| 3598 | - 'data_type' => '', | |
| 3599 | - 'field_type' => 'random', | |
| 3600 | - 'site_title' => 'Random', | |
| 3601 | - 'htmlvar_name' => 'post_title' | |
| 3602 | - ); | |
| 3603 | - | |
| 3604 | - $fields[] = array( | |
| 3605 | - 'post_type' => $post_type, | |
| 3606 | - 'data_type' => '', | |
| 3607 | - 'field_type' => 'datetime', | |
| 3608 | -            'site_title' => __('Add date', 'geodirectory'),
 | |
| 3609 | - 'htmlvar_name' => 'post_date' | |
| 3610 | - ); | |
| 3611 | - $fields[] = array( | |
| 3612 | - 'post_type' => $post_type, | |
| 3613 | - 'data_type' => '', | |
| 3614 | - 'field_type' => 'bigint', | |
| 3615 | -            'site_title' => __('Review', 'geodirectory'),
 | |
| 3616 | - 'htmlvar_name' => 'comment_count' | |
| 3617 | - ); | |
| 3618 | - $fields[] = array( | |
| 3619 | - 'post_type' => $post_type, | |
| 3620 | - 'data_type' => '', | |
| 3621 | - 'field_type' => 'float', | |
| 3622 | -            'site_title' => __('Rating', 'geodirectory'),
 | |
| 3623 | - 'htmlvar_name' => 'overall_rating' | |
| 3624 | - ); | |
| 3625 | - $fields[] = array( | |
| 3626 | - 'post_type' => $post_type, | |
| 3627 | - 'data_type' => '', | |
| 3628 | - 'field_type' => 'text', | |
| 3629 | -            'site_title' => __('Title', 'geodirectory'),
 | |
| 3630 | - 'htmlvar_name' => 'post_title' | |
| 3631 | - ); | |
| 3632 | - | |
| 3633 | - /** | |
| 3634 | - * Hook to add custom sort options. | |
| 3635 | - * | |
| 3636 | - * @since 1.0.0 | |
| 3637 | - * @param array $fields Unmodified sort options array. | |
| 3638 | - * @param string $post_type Post type. | |
| 3639 | - */ | |
| 3640 | -        return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
 | |
| 3641 | - | |
| 3642 | - } | |
| 3643 | - | |
| 3644 | - return false; | |
| 3585 | + global $wpdb; | |
| 3586 | + | |
| 3587 | +	if ($post_type != '') {
 | |
| 3588 | + | |
| 3589 | + $all_postypes = geodir_get_posttypes(); | |
| 3590 | + | |
| 3591 | + if (!in_array($post_type, $all_postypes)) | |
| 3592 | + return false; | |
| 3593 | + | |
| 3594 | + $fields = array(); | |
| 3595 | + | |
| 3596 | + $fields[] = array( | |
| 3597 | + 'post_type' => $post_type, | |
| 3598 | + 'data_type' => '', | |
| 3599 | + 'field_type' => 'random', | |
| 3600 | + 'site_title' => 'Random', | |
| 3601 | + 'htmlvar_name' => 'post_title' | |
| 3602 | + ); | |
| 3603 | + | |
| 3604 | + $fields[] = array( | |
| 3605 | + 'post_type' => $post_type, | |
| 3606 | + 'data_type' => '', | |
| 3607 | + 'field_type' => 'datetime', | |
| 3608 | +			'site_title' => __('Add date', 'geodirectory'),
 | |
| 3609 | + 'htmlvar_name' => 'post_date' | |
| 3610 | + ); | |
| 3611 | + $fields[] = array( | |
| 3612 | + 'post_type' => $post_type, | |
| 3613 | + 'data_type' => '', | |
| 3614 | + 'field_type' => 'bigint', | |
| 3615 | +			'site_title' => __('Review', 'geodirectory'),
 | |
| 3616 | + 'htmlvar_name' => 'comment_count' | |
| 3617 | + ); | |
| 3618 | + $fields[] = array( | |
| 3619 | + 'post_type' => $post_type, | |
| 3620 | + 'data_type' => '', | |
| 3621 | + 'field_type' => 'float', | |
| 3622 | +			'site_title' => __('Rating', 'geodirectory'),
 | |
| 3623 | + 'htmlvar_name' => 'overall_rating' | |
| 3624 | + ); | |
| 3625 | + $fields[] = array( | |
| 3626 | + 'post_type' => $post_type, | |
| 3627 | + 'data_type' => '', | |
| 3628 | + 'field_type' => 'text', | |
| 3629 | +			'site_title' => __('Title', 'geodirectory'),
 | |
| 3630 | + 'htmlvar_name' => 'post_title' | |
| 3631 | + ); | |
| 3632 | + | |
| 3633 | + /** | |
| 3634 | + * Hook to add custom sort options. | |
| 3635 | + * | |
| 3636 | + * @since 1.0.0 | |
| 3637 | + * @param array $fields Unmodified sort options array. | |
| 3638 | + * @param string $post_type Post type. | |
| 3639 | + */ | |
| 3640 | +		return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
 | |
| 3641 | + | |
| 3642 | + } | |
| 3643 | + | |
| 3644 | + return false; | |
| 3645 | 3645 | } | 
| 3646 | 3646 | |
| 3647 | 3647 | |
| @@ -3657,117 +3657,117 @@ discard block | ||
| 3657 | 3657 | function godir_set_sort_field_order($field_ids = array()) | 
| 3658 | 3658 |  {
 | 
| 3659 | 3659 | |
| 3660 | - global $wpdb; | |
| 3660 | + global $wpdb; | |
| 3661 | 3661 | |
| 3662 | - $count = 0; | |
| 3663 | - if (!empty($field_ids)): | |
| 3664 | -        foreach ($field_ids as $id) {
 | |
| 3662 | + $count = 0; | |
| 3663 | + if (!empty($field_ids)): | |
| 3664 | +		foreach ($field_ids as $id) {
 | |
| 3665 | 3665 | |
| 3666 | - $cf = trim($id, '_'); | |
| 3666 | + $cf = trim($id, '_'); | |
| 3667 | 3667 | |
| 3668 | - $post_meta_info = $wpdb->query( | |
| 3669 | - $wpdb->prepare( | |
| 3670 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 3668 | + $post_meta_info = $wpdb->query( | |
| 3669 | + $wpdb->prepare( | |
| 3670 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 3671 | 3671 | sort_order=%d | 
| 3672 | 3672 | where id= %d", | 
| 3673 | - array($count, $cf) | |
| 3674 | - ) | |
| 3675 | - ); | |
| 3676 | - $count++; | |
| 3677 | - } | |
| 3678 | - | |
| 3679 | - return $field_ids; | |
| 3680 | - else: | |
| 3681 | - return false; | |
| 3682 | - endif; | |
| 3673 | + array($count, $cf) | |
| 3674 | + ) | |
| 3675 | + ); | |
| 3676 | + $count++; | |
| 3677 | + } | |
| 3678 | + | |
| 3679 | + return $field_ids; | |
| 3680 | + else: | |
| 3681 | + return false; | |
| 3682 | + endif; | |
| 3683 | 3683 | } | 
| 3684 | 3684 | |
| 3685 | 3685 | |
| 3686 | 3686 |  if (!function_exists('geodir_custom_sort_field_save')) {
 | 
| 3687 | - /** | |
| 3688 | - * Save or Update custom sort fields into the database. | |
| 3689 | - * | |
| 3690 | - * @since 1.0.0 | |
| 3691 | - * @package GeoDirectory | |
| 3692 | - * @global object $wpdb WordPress Database object. | |
| 3693 | - * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 3694 | -     * @param array $request_field {
 | |
| 3695 | - * Attributes of the Request field. | |
| 3696 | - * | |
| 3697 | - * @type string $action Ajax action name. | |
| 3698 | - * @type string $manage_field_type Manage field type Default "sorting_options". | |
| 3699 | - * @type string $create_field Do you want to create this field?. | |
| 3700 | - * @type string $field_ins_upd Field created or updated?. | |
| 3701 | - * @type string $_wpnonce Nonce value. | |
| 3702 | - * @type string $listing_type The Post type. | |
| 3703 | - * @type string $field_type Field Type. | |
| 3704 | - * @type string $field_id Field ID. | |
| 3705 | - * @type string $data_type Data Type. | |
| 3706 | - * @type string $htmlvar_name HTML variable name. | |
| 3707 | - * @type string $site_title Section title which you wish to display in frontend. | |
| 3708 | - * @type string $is_default Is this default sorting?. | |
| 3709 | - * @type string $is_active If not active then the field will not be displayed anywhere. | |
| 3710 | - * @type string $sort_order Sort Order. | |
| 3711 | - * | |
| 3712 | - * } | |
| 3713 | - * @param bool $default Not yet implemented. | |
| 3714 | - * @return int Returns the last affected db table row id. | |
| 3715 | - */ | |
| 3716 | - function geodir_custom_sort_field_save($request_field = array(), $default = false) | |
| 3717 | -    {
 | |
| 3718 | - | |
| 3719 | - global $wpdb, $plugin_prefix; | |
| 3720 | - | |
| 3721 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; | |
| 3722 | - | |
| 3723 | - $cf = trim($result_str, '_'); | |
| 3724 | - | |
| 3725 | - /*-------- check dublicate validation --------*/ | |
| 3726 | - | |
| 3727 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; | |
| 3728 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; | |
| 3729 | - | |
| 3730 | - $post_type = $request_field['listing_type']; | |
| 3731 | - $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; | |
| 3732 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; | |
| 3733 | - $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; | |
| 3734 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; | |
| 3735 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; | |
| 3736 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; | |
| 3737 | - $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; | |
| 3738 | - $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; | |
| 3739 | - $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; | |
| 3740 | - $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; | |
| 3741 | - $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; | |
| 3742 | - | |
| 3743 | - $default_order = ''; | |
| 3744 | -        if ($is_default != '') {
 | |
| 3745 | - $default_order = $is_default; | |
| 3746 | - $is_default = '1'; | |
| 3747 | - } | |
| 3748 | - | |
| 3749 | - | |
| 3750 | - $check_html_variable = $wpdb->get_var( | |
| 3751 | - $wpdb->prepare( | |
| 3752 | - "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", | |
| 3753 | - array($cehhtmlvar_name, $post_type, $field_type) | |
| 3754 | - ) | |
| 3755 | - ); | |
| 3756 | - | |
| 3757 | -        if ($is_default == 1) {
 | |
| 3758 | - | |
| 3759 | -            $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
 | |
| 3760 | - | |
| 3761 | - } | |
| 3762 | - | |
| 3763 | - | |
| 3764 | -        if (!$check_html_variable) {
 | |
| 3765 | - | |
| 3766 | - $wpdb->query( | |
| 3767 | - | |
| 3768 | - $wpdb->prepare( | |
| 3769 | - | |
| 3770 | - "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 3687 | + /** | |
| 3688 | + * Save or Update custom sort fields into the database. | |
| 3689 | + * | |
| 3690 | + * @since 1.0.0 | |
| 3691 | + * @package GeoDirectory | |
| 3692 | + * @global object $wpdb WordPress Database object. | |
| 3693 | + * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 3694 | +	 * @param array $request_field {
 | |
| 3695 | + * Attributes of the Request field. | |
| 3696 | + * | |
| 3697 | + * @type string $action Ajax action name. | |
| 3698 | + * @type string $manage_field_type Manage field type Default "sorting_options". | |
| 3699 | + * @type string $create_field Do you want to create this field?. | |
| 3700 | + * @type string $field_ins_upd Field created or updated?. | |
| 3701 | + * @type string $_wpnonce Nonce value. | |
| 3702 | + * @type string $listing_type The Post type. | |
| 3703 | + * @type string $field_type Field Type. | |
| 3704 | + * @type string $field_id Field ID. | |
| 3705 | + * @type string $data_type Data Type. | |
| 3706 | + * @type string $htmlvar_name HTML variable name. | |
| 3707 | + * @type string $site_title Section title which you wish to display in frontend. | |
| 3708 | + * @type string $is_default Is this default sorting?. | |
| 3709 | + * @type string $is_active If not active then the field will not be displayed anywhere. | |
| 3710 | + * @type string $sort_order Sort Order. | |
| 3711 | + * | |
| 3712 | + * } | |
| 3713 | + * @param bool $default Not yet implemented. | |
| 3714 | + * @return int Returns the last affected db table row id. | |
| 3715 | + */ | |
| 3716 | + function geodir_custom_sort_field_save($request_field = array(), $default = false) | |
| 3717 | +	{
 | |
| 3718 | + | |
| 3719 | + global $wpdb, $plugin_prefix; | |
| 3720 | + | |
| 3721 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; | |
| 3722 | + | |
| 3723 | + $cf = trim($result_str, '_'); | |
| 3724 | + | |
| 3725 | + /*-------- check dublicate validation --------*/ | |
| 3726 | + | |
| 3727 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; | |
| 3728 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; | |
| 3729 | + | |
| 3730 | + $post_type = $request_field['listing_type']; | |
| 3731 | + $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; | |
| 3732 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; | |
| 3733 | + $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; | |
| 3734 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; | |
| 3735 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; | |
| 3736 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; | |
| 3737 | + $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; | |
| 3738 | + $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; | |
| 3739 | + $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; | |
| 3740 | + $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; | |
| 3741 | + $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; | |
| 3742 | + | |
| 3743 | + $default_order = ''; | |
| 3744 | +		if ($is_default != '') {
 | |
| 3745 | + $default_order = $is_default; | |
| 3746 | + $is_default = '1'; | |
| 3747 | + } | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + $check_html_variable = $wpdb->get_var( | |
| 3751 | + $wpdb->prepare( | |
| 3752 | + "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", | |
| 3753 | + array($cehhtmlvar_name, $post_type, $field_type) | |
| 3754 | + ) | |
| 3755 | + ); | |
| 3756 | + | |
| 3757 | +		if ($is_default == 1) {
 | |
| 3758 | + | |
| 3759 | +			$wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
 | |
| 3760 | + | |
| 3761 | + } | |
| 3762 | + | |
| 3763 | + | |
| 3764 | +		if (!$check_html_variable) {
 | |
| 3765 | + | |
| 3766 | + $wpdb->query( | |
| 3767 | + | |
| 3768 | + $wpdb->prepare( | |
| 3769 | + | |
| 3770 | + "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 3771 | 3771 | post_type = %s, | 
| 3772 | 3772 | data_type = %s, | 
| 3773 | 3773 | field_type = %s, | 
| @@ -3782,23 +3782,23 @@ discard block | ||
| 3782 | 3782 | asc_title = %s, | 
| 3783 | 3783 | desc_title = %s", | 
| 3784 | 3784 | |
| 3785 | - 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) | |
| 3786 | - ) | |
| 3785 | + 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) | |
| 3786 | + ) | |
| 3787 | 3787 | |
| 3788 | - ); | |
| 3788 | + ); | |
| 3789 | 3789 | |
| 3790 | 3790 | |
| 3791 | - $lastid = $wpdb->insert_id; | |
| 3791 | + $lastid = $wpdb->insert_id; | |
| 3792 | 3792 | |
| 3793 | - $lastid = trim($lastid); | |
| 3793 | + $lastid = trim($lastid); | |
| 3794 | 3794 | |
| 3795 | -        } else {
 | |
| 3795 | +		} else {
 | |
| 3796 | 3796 | |
| 3797 | - $wpdb->query( | |
| 3797 | + $wpdb->query( | |
| 3798 | 3798 | |
| 3799 | - $wpdb->prepare( | |
| 3799 | + $wpdb->prepare( | |
| 3800 | 3800 | |
| 3801 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 3801 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set | |
| 3802 | 3802 | post_type = %s, | 
| 3803 | 3803 | data_type = %s, | 
| 3804 | 3804 | field_type = %s, | 
| @@ -3814,115 +3814,115 @@ discard block | ||
| 3814 | 3814 | desc_title = %s | 
| 3815 | 3815 | where id = %d", | 
| 3816 | 3816 | |
| 3817 | - 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) | |
| 3818 | - ) | |
| 3817 | + 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) | |
| 3818 | + ) | |
| 3819 | 3819 | |
| 3820 | - ); | |
| 3820 | + ); | |
| 3821 | 3821 | |
| 3822 | - $lastid = trim($cf); | |
| 3822 | + $lastid = trim($cf); | |
| 3823 | 3823 | |
| 3824 | - } | |
| 3824 | + } | |
| 3825 | 3825 | |
| 3826 | 3826 | |
| 3827 | - return (int)$lastid; | |
| 3827 | + return (int)$lastid; | |
| 3828 | 3828 | |
| 3829 | - } | |
| 3829 | + } | |
| 3830 | 3830 | } | 
| 3831 | 3831 | |
| 3832 | 3832 | |
| 3833 | 3833 |  if (!function_exists('geodir_custom_sort_field_delete')) {
 | 
| 3834 | - /** | |
| 3835 | - * Delete a custom sort field using field id. | |
| 3836 | - * @since 1.0.0 | |
| 3837 | - * @package GeoDirectory | |
| 3838 | - * @global object $wpdb WordPress Database object. | |
| 3839 | - * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 3840 | - * @param string $field_id The field ID. | |
| 3841 | - * @return int|string Returns field id when successful deletion, else returns 0. | |
| 3842 | - */ | |
| 3843 | - function geodir_custom_sort_field_delete($field_id = '') | |
| 3844 | -    {
 | |
| 3845 | - | |
| 3846 | - global $wpdb, $plugin_prefix; | |
| 3847 | -        if ($field_id != '') {
 | |
| 3848 | - $cf = trim($field_id, '_'); | |
| 3849 | - | |
| 3850 | -            $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
 | |
| 3851 | - | |
| 3852 | - return $field_id; | |
| 3853 | - | |
| 3854 | - } else | |
| 3855 | - return 0; | |
| 3856 | - | |
| 3857 | - } | |
| 3834 | + /** | |
| 3835 | + * Delete a custom sort field using field id. | |
| 3836 | + * @since 1.0.0 | |
| 3837 | + * @package GeoDirectory | |
| 3838 | + * @global object $wpdb WordPress Database object. | |
| 3839 | + * @global string $plugin_prefix Geodirectory plugin table prefix. | |
| 3840 | + * @param string $field_id The field ID. | |
| 3841 | + * @return int|string Returns field id when successful deletion, else returns 0. | |
| 3842 | + */ | |
| 3843 | + function geodir_custom_sort_field_delete($field_id = '') | |
| 3844 | +	{
 | |
| 3845 | + | |
| 3846 | + global $wpdb, $plugin_prefix; | |
| 3847 | +		if ($field_id != '') {
 | |
| 3848 | + $cf = trim($field_id, '_'); | |
| 3849 | + | |
| 3850 | +			$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
 | |
| 3851 | + | |
| 3852 | + return $field_id; | |
| 3853 | + | |
| 3854 | + } else | |
| 3855 | + return 0; | |
| 3856 | + | |
| 3857 | + } | |
| 3858 | 3858 | } | 
| 3859 | 3859 | |
| 3860 | 3860 | |
| 3861 | 3861 |  if (!function_exists('geodir_custom_sort_field_adminhtml')) {
 | 
| 3862 | - /** | |
| 3863 | - * Custom sort field admin html. | |
| 3864 | - * | |
| 3865 | - * @since 1.0.0 | |
| 3866 | - * @package GeoDirectory | |
| 3867 | - * @global object $wpdb WordPress Database object. | |
| 3868 | - * @param string $field_type The form field type. | |
| 3869 | - * @param object|int $result_str The custom field results object or row id. | |
| 3870 | - * @param string $field_ins_upd When set to "submit" displays form. | |
| 3871 | - * @param bool $default when set to true field will be for admin use only. | |
| 3872 | - */ | |
| 3873 | - function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) | |
| 3874 | -    {
 | |
| 3875 | - global $wpdb; | |
| 3876 | - $cf = $result_str; | |
| 3877 | -        if (!is_object($cf)) {
 | |
| 3878 | -            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
 | |
| 3879 | -        } else {
 | |
| 3880 | - $field_info = $cf; | |
| 3881 | - $result_str = $cf->id; | |
| 3882 | - } | |
| 3883 | - | |
| 3884 | - $field_info = stripslashes_deep($field_info); // strip slashes | |
| 3885 | - | |
| 3886 | -        if (!isset($field_info->post_type)) {
 | |
| 3887 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 3888 | -        } else {
 | |
| 3889 | - $post_type = $field_info->post_type; | |
| 3890 | - } | |
| 3891 | - | |
| 3892 | -        $field_types = explode('-_-', $field_type);
 | |
| 3893 | - $field_type = $field_types[0]; | |
| 3894 | - $htmlvar_name = isset($field_types[1]) ? $field_types[1] : ''; | |
| 3895 | - | |
| 3896 | - $site_title = ''; | |
| 3897 | - if ($site_title == '') | |
| 3898 | - $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; | |
| 3899 | - | |
| 3900 | -        if ($site_title == '') {
 | |
| 3901 | - $fields = geodir_get_custom_sort_options($post_type); | |
| 3902 | - | |
| 3903 | -            foreach ($fields as $val) {
 | |
| 3904 | - $val = stripslashes_deep($val); // strip slashes | |
| 3905 | - | |
| 3906 | -                if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
 | |
| 3907 | - $site_title = isset($val['site_title']) ? $val['site_title'] : ''; | |
| 3908 | - } | |
| 3909 | - } | |
| 3910 | - } | |
| 3911 | - | |
| 3912 | - if ($htmlvar_name == '') | |
| 3913 | - $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; | |
| 3914 | - | |
| 3915 | -        $nonce = wp_create_nonce('custom_fields_' . $result_str);
 | |
| 3916 | - | |
| 3917 | - ?> | |
| 3862 | + /** | |
| 3863 | + * Custom sort field admin html. | |
| 3864 | + * | |
| 3865 | + * @since 1.0.0 | |
| 3866 | + * @package GeoDirectory | |
| 3867 | + * @global object $wpdb WordPress Database object. | |
| 3868 | + * @param string $field_type The form field type. | |
| 3869 | + * @param object|int $result_str The custom field results object or row id. | |
| 3870 | + * @param string $field_ins_upd When set to "submit" displays form. | |
| 3871 | + * @param bool $default when set to true field will be for admin use only. | |
| 3872 | + */ | |
| 3873 | + function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) | |
| 3874 | +	{
 | |
| 3875 | + global $wpdb; | |
| 3876 | + $cf = $result_str; | |
| 3877 | +		if (!is_object($cf)) {
 | |
| 3878 | +			$field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
 | |
| 3879 | +		} else {
 | |
| 3880 | + $field_info = $cf; | |
| 3881 | + $result_str = $cf->id; | |
| 3882 | + } | |
| 3883 | + | |
| 3884 | + $field_info = stripslashes_deep($field_info); // strip slashes | |
| 3885 | + | |
| 3886 | +		if (!isset($field_info->post_type)) {
 | |
| 3887 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 3888 | +		} else {
 | |
| 3889 | + $post_type = $field_info->post_type; | |
| 3890 | + } | |
| 3891 | + | |
| 3892 | +		$field_types = explode('-_-', $field_type);
 | |
| 3893 | + $field_type = $field_types[0]; | |
| 3894 | + $htmlvar_name = isset($field_types[1]) ? $field_types[1] : ''; | |
| 3895 | + | |
| 3896 | + $site_title = ''; | |
| 3897 | + if ($site_title == '') | |
| 3898 | + $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; | |
| 3899 | + | |
| 3900 | +		if ($site_title == '') {
 | |
| 3901 | + $fields = geodir_get_custom_sort_options($post_type); | |
| 3902 | + | |
| 3903 | +			foreach ($fields as $val) {
 | |
| 3904 | + $val = stripslashes_deep($val); // strip slashes | |
| 3905 | + | |
| 3906 | +				if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
 | |
| 3907 | + $site_title = isset($val['site_title']) ? $val['site_title'] : ''; | |
| 3908 | + } | |
| 3909 | + } | |
| 3910 | + } | |
| 3911 | + | |
| 3912 | + if ($htmlvar_name == '') | |
| 3913 | + $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; | |
| 3914 | + | |
| 3915 | +		$nonce = wp_create_nonce('custom_fields_' . $result_str);
 | |
| 3916 | + | |
| 3917 | + ?> | |
| 3918 | 3918 | <li class="text" id="licontainer_<?php echo $result_str;?>"> | 
| 3919 | 3919 | <div class="title title<?php echo $result_str;?> gt-fieldset" | 
| 3920 | 3920 |                   title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory');?>"
 | 
| 3921 | 3921 |                   ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
 | 
| 3922 | 3922 | <?php | 
| 3923 | 3923 | |
| 3924 | -                $nonce = wp_create_nonce('custom_fields_' . $result_str);
 | |
| 3925 | - ?> | |
| 3924 | +				$nonce = wp_create_nonce('custom_fields_' . $result_str);
 | |
| 3925 | + ?> | |
| 3926 | 3926 | |
| 3927 | 3927 |                  <div title="<?php _e('Click to remove field', 'geodirectory');?>"
 | 
| 3928 | 3928 |                       onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
 | 
| @@ -3935,17 +3935,17 @@ discard block | ||
| 3935 | 3935 | |
| 3936 | 3936 | <div id="field_frm<?php echo $result_str;?>" class="field_frm" | 
| 3937 | 3937 |                   style="display:<?php if ($field_ins_upd == 'submit') {
 | 
| 3938 | - echo 'block;'; | |
| 3939 | -                 } else {
 | |
| 3940 | - echo 'none;'; | |
| 3941 | - } ?>"> | |
| 3938 | + echo 'block;'; | |
| 3939 | +				 } else {
 | |
| 3940 | + echo 'none;'; | |
| 3941 | + } ?>"> | |
| 3942 | 3942 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> | 
| 3943 | 3943 | <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> | 
| 3944 | 3944 | <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> | 
| 3945 | 3945 | <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/> | 
| 3946 | 3946 |                  <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
 | 
| 3947 | - echo $field_info->data_type; | |
| 3948 | - }?>"/> | |
| 3947 | + echo $field_info->data_type; | |
| 3948 | + }?>"/> | |
| 3949 | 3949 | <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/> | 
| 3950 | 3950 | |
| 3951 | 3951 | |
| @@ -3960,19 +3960,19 @@ discard block | ||
| 3960 | 3960 | <td> | 
| 3961 | 3961 | <input type="checkbox" name="asc" id="asc" | 
| 3962 | 3962 |                                         value="1" <?php if (isset($field_info->sort_asc) && $field_info->sort_asc == '1') {
 | 
| 3963 | - echo 'checked="checked"'; | |
| 3964 | - } ?>/> | |
| 3963 | + echo 'checked="checked"'; | |
| 3964 | + } ?>/> | |
| 3965 | 3965 | |
| 3966 | 3966 | <input type="text" name="asc_title" id="asc_title" | 
| 3967 | 3967 |                                         placeholder="<?php esc_attr_e('Ascending title', 'geodirectory'); ?>"
 | 
| 3968 | 3968 |                                         value="<?php if (isset($field_info->asc_title)) {
 | 
| 3969 | - echo esc_attr($field_info->asc_title); | |
| 3970 | - } ?>" style="width:45%;"/> | |
| 3969 | + echo esc_attr($field_info->asc_title); | |
| 3970 | + } ?>" style="width:45%;"/> | |
| 3971 | 3971 | |
| 3972 | 3972 | <input type="radio" name="is_default" | 
| 3973 | 3973 |                                         value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
 | 
| 3974 | - echo 'checked="checked"'; | |
| 3975 | -                                } ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
 | |
| 3974 | + echo 'checked="checked"'; | |
| 3975 | +								} ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
 | |
| 3976 | 3976 | |
| 3977 | 3977 | <br/> | 
| 3978 | 3978 |                                  <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?></span>
 | 
| @@ -3984,18 +3984,18 @@ discard block | ||
| 3984 | 3984 | <td> | 
| 3985 | 3985 | <input type="checkbox" name="desc" id="desc" | 
| 3986 | 3986 |                                         value="1" <?php if (isset($field_info->sort_desc) && $field_info->sort_desc == '1') {
 | 
| 3987 | - echo 'checked="checked"'; | |
| 3988 | - } ?>/> | |
| 3987 | + echo 'checked="checked"'; | |
| 3988 | + } ?>/> | |
| 3989 | 3989 | |
| 3990 | 3990 | <input type="text" name="desc_title" id="desc_title" | 
| 3991 | 3991 |                                         placeholder="<?php esc_attr_e('Descending title', 'geodirectory'); ?>"
 | 
| 3992 | 3992 |                                         value="<?php if (isset($field_info->desc_title)) {
 | 
| 3993 | - echo esc_attr($field_info->desc_title); | |
| 3994 | - } ?>" style="width:45%;"/> | |
| 3993 | + echo esc_attr($field_info->desc_title); | |
| 3994 | + } ?>" style="width:45%;"/> | |
| 3995 | 3995 | <input type="radio" name="is_default" | 
| 3996 | 3996 |                                         value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
 | 
| 3997 | - echo 'checked="checked"'; | |
| 3998 | -                                } ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
 | |
| 3997 | + echo 'checked="checked"'; | |
| 3998 | +								} ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
 | |
| 3999 | 3999 | <br/> | 
| 4000 | 4000 |                                  <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?></span>
 | 
| 4001 | 4001 | </td> | 
| @@ -4018,8 +4018,8 @@ discard block | ||
| 4018 | 4018 | <td align="left"> | 
| 4019 | 4019 | <input type="checkbox" name="is_default" | 
| 4020 | 4020 |                                         value="<?php echo $field_type; ?>"  <?php if (isset($field_info->is_default) && $field_info->is_default == '1') {
 | 
| 4021 | - echo 'checked="checked"'; | |
| 4022 | - } ?>/> | |
| 4021 | + echo 'checked="checked"'; | |
| 4022 | + } ?>/> | |
| 4023 | 4023 | <br/> | 
| 4024 | 4024 |                                  <span><?php _e('If field is checked then the field will be use as default sort.', 'geodirectory'); ?></span>
 | 
| 4025 | 4025 | </td> | 
| @@ -4033,12 +4033,12 @@ discard block | ||
| 4033 | 4033 | <select name="is_active" id="is_active"> | 
| 4034 | 4034 | <option | 
| 4035 | 4035 |                                      value="1" <?php if (isset($field_info->is_active) && $field_info->is_active == '1') {
 | 
| 4036 | - echo 'selected="selected"'; | |
| 4037 | -                                }?>><?php _e('Yes', 'geodirectory');?></option>
 | |
| 4036 | + echo 'selected="selected"'; | |
| 4037 | +								}?>><?php _e('Yes', 'geodirectory');?></option>
 | |
| 4038 | 4038 | <option | 
| 4039 | 4039 |                                      value="0" <?php if (isset($field_info->is_active) && $field_info->is_active == '0') {
 | 
| 4040 | - echo 'selected="selected"'; | |
| 4041 | -                                }?>><?php _e('No', 'geodirectory');?></option>
 | |
| 4040 | + echo 'selected="selected"'; | |
| 4041 | +								}?>><?php _e('No', 'geodirectory');?></option>
 | |
| 4042 | 4042 | </select> | 
| 4043 | 4043 | <br/> | 
| 4044 | 4044 |                              <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory');?></span>
 | 
| @@ -4049,8 +4049,8 @@ discard block | ||
| 4049 | 4049 |                          <td><strong><?php _e('Display order :', 'geodirectory');?></strong></td>
 | 
| 4050 | 4050 | <td align="left"><input type="text" readonly="readonly" name="sort_order" id="sort_order" | 
| 4051 | 4051 |                                                  value="<?php if (isset($field_info->sort_order)) {
 | 
| 4052 | - echo esc_attr($field_info->sort_order); | |
| 4053 | - }?>" size="50"/> | |
| 4052 | + echo esc_attr($field_info->sort_order); | |
| 4053 | + }?>" size="50"/> | |
| 4054 | 4054 | <br/> | 
| 4055 | 4055 |                              <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory');?></span>
 | 
| 4056 | 4056 | </td> | 
| @@ -4073,38 +4073,38 @@ discard block | ||
| 4073 | 4073 | </div> | 
| 4074 | 4074 | </li> <?php | 
| 4075 | 4075 | |
| 4076 | - } | |
| 4076 | + } | |
| 4077 | 4077 | } | 
| 4078 | 4078 | |
| 4079 | 4079 |  if (!function_exists('check_field_visibility')) {
 | 
| 4080 | - /** | |
| 4081 | - * Check field visibility as per price package. | |
| 4082 | - * | |
| 4083 | - * @since 1.0.0 | |
| 4084 | - * @package GeoDirectory | |
| 4085 | - * @global object $wpdb WordPress Database object. | |
| 4086 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. | |
| 4087 | - * @param int|string $package_id The package ID. | |
| 4088 | - * @param string $field_name The field name. | |
| 4089 | - * @param string $post_type Optional. The wordpress post type. | |
| 4090 | - * @return bool Returns true when field visible, otherwise false. | |
| 4091 | - */ | |
| 4092 | - function check_field_visibility($package_id, $field_name, $post_type) | |
| 4093 | -    {
 | |
| 4094 | - global $wpdb, $geodir_addon_list; | |
| 4095 | -        if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
 | |
| 4096 | - return true; | |
| 4097 | - } | |
| 4098 | -        if (!$package_id || !$field_name || !$post_type) {
 | |
| 4099 | - return true; | |
| 4100 | - } | |
| 4101 | -        $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));
 | |
| 4102 | - | |
| 4103 | -        if ($wpdb->get_var($sql)) {
 | |
| 4104 | - return true; | |
| 4105 | - } | |
| 4106 | - return false; | |
| 4107 | - } | |
| 4080 | + /** | |
| 4081 | + * Check field visibility as per price package. | |
| 4082 | + * | |
| 4083 | + * @since 1.0.0 | |
| 4084 | + * @package GeoDirectory | |
| 4085 | + * @global object $wpdb WordPress Database object. | |
| 4086 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. | |
| 4087 | + * @param int|string $package_id The package ID. | |
| 4088 | + * @param string $field_name The field name. | |
| 4089 | + * @param string $post_type Optional. The wordpress post type. | |
| 4090 | + * @return bool Returns true when field visible, otherwise false. | |
| 4091 | + */ | |
| 4092 | + function check_field_visibility($package_id, $field_name, $post_type) | |
| 4093 | +	{
 | |
| 4094 | + global $wpdb, $geodir_addon_list; | |
| 4095 | +		if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
 | |
| 4096 | + return true; | |
| 4097 | + } | |
| 4098 | +		if (!$package_id || !$field_name || !$post_type) {
 | |
| 4099 | + return true; | |
| 4100 | + } | |
| 4101 | +		$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));
 | |
| 4102 | + | |
| 4103 | +		if ($wpdb->get_var($sql)) {
 | |
| 4104 | + return true; | |
| 4105 | + } | |
| 4106 | + return false; | |
| 4107 | + } | |
| 4108 | 4108 | } | 
| 4109 | 4109 | |
| 4110 | 4110 | /** | 
| @@ -4119,43 +4119,43 @@ discard block | ||
| 4119 | 4119 | */ | 
| 4120 | 4120 | function geodir_string_to_options($input = '', $translated = false) | 
| 4121 | 4121 |  {
 | 
| 4122 | - $return = array(); | |
| 4123 | -    if ($input != '') {
 | |
| 4124 | - $input = trim($input); | |
| 4125 | - $input = rtrim($input, ","); | |
| 4126 | - $input = ltrim($input, ","); | |
| 4127 | - $input = trim($input); | |
| 4128 | - } | |
| 4129 | - | |
| 4130 | -    $input_arr = explode(',', $input);
 | |
| 4131 | - | |
| 4132 | -    if (!empty($input_arr)) {
 | |
| 4133 | -        foreach ($input_arr as $input_str) {
 | |
| 4134 | - $input_str = trim($input_str); | |
| 4135 | - | |
| 4136 | -            if (strpos($input_str, "/") !== false) {
 | |
| 4137 | -                $input_str = explode("/", $input_str, 2);
 | |
| 4138 | - $label = trim($input_str[0]); | |
| 4139 | -                if ($translated && $label != '') {
 | |
| 4140 | - $label = __($label, 'geodirectory'); | |
| 4141 | - } | |
| 4142 | - $label = ucfirst($label); | |
| 4143 | - $value = trim($input_str[1]); | |
| 4144 | -            } else {
 | |
| 4145 | -                if ($translated && $input_str != '') {
 | |
| 4146 | - $input_str = __($input_str, 'geodirectory'); | |
| 4147 | - } | |
| 4148 | - $label = ucfirst($input_str); | |
| 4149 | - $value = $input_str; | |
| 4150 | - } | |
| 4151 | - | |
| 4152 | -            if ($label != '') {
 | |
| 4153 | -                $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
 | |
| 4154 | - } | |
| 4155 | - } | |
| 4156 | - } | |
| 4157 | - | |
| 4158 | - return $return; | |
| 4122 | + $return = array(); | |
| 4123 | +	if ($input != '') {
 | |
| 4124 | + $input = trim($input); | |
| 4125 | + $input = rtrim($input, ","); | |
| 4126 | + $input = ltrim($input, ","); | |
| 4127 | + $input = trim($input); | |
| 4128 | + } | |
| 4129 | + | |
| 4130 | +	$input_arr = explode(',', $input);
 | |
| 4131 | + | |
| 4132 | +	if (!empty($input_arr)) {
 | |
| 4133 | +		foreach ($input_arr as $input_str) {
 | |
| 4134 | + $input_str = trim($input_str); | |
| 4135 | + | |
| 4136 | +			if (strpos($input_str, "/") !== false) {
 | |
| 4137 | +				$input_str = explode("/", $input_str, 2);
 | |
| 4138 | + $label = trim($input_str[0]); | |
| 4139 | +				if ($translated && $label != '') {
 | |
| 4140 | + $label = __($label, 'geodirectory'); | |
| 4141 | + } | |
| 4142 | + $label = ucfirst($label); | |
| 4143 | + $value = trim($input_str[1]); | |
| 4144 | +			} else {
 | |
| 4145 | +				if ($translated && $input_str != '') {
 | |
| 4146 | + $input_str = __($input_str, 'geodirectory'); | |
| 4147 | + } | |
| 4148 | + $label = ucfirst($input_str); | |
| 4149 | + $value = $input_str; | |
| 4150 | + } | |
| 4151 | + | |
| 4152 | +			if ($label != '') {
 | |
| 4153 | +				$return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
 | |
| 4154 | + } | |
| 4155 | + } | |
| 4156 | + } | |
| 4157 | + | |
| 4158 | + return $return; | |
| 4159 | 4159 | } | 
| 4160 | 4160 | |
| 4161 | 4161 | /** | 
| @@ -4170,51 +4170,51 @@ discard block | ||
| 4170 | 4170 | */ | 
| 4171 | 4171 | function geodir_string_values_to_options($option_values = '', $translated = false) | 
| 4172 | 4172 |  {
 | 
| 4173 | - $options = array(); | |
| 4174 | -    if ($option_values == '') {
 | |
| 4175 | - return NULL; | |
| 4176 | - } | |
| 4177 | - | |
| 4178 | -    if (strpos($option_values, "{/optgroup}") !== false) {
 | |
| 4179 | -        $option_values_arr = explode("{/optgroup}", $option_values);
 | |
| 4180 | - | |
| 4181 | -        foreach ($option_values_arr as $optgroup) {
 | |
| 4182 | -            if (strpos($optgroup, "{optgroup}") !== false) {
 | |
| 4183 | -                $optgroup_arr = explode("{optgroup}", $optgroup);
 | |
| 4184 | - | |
| 4185 | - $count = 0; | |
| 4186 | -                foreach ($optgroup_arr as $optgroup_str) {
 | |
| 4187 | - $count++; | |
| 4188 | - $optgroup_str = trim($optgroup_str); | |
| 4189 | - | |
| 4190 | - $optgroup_label = ''; | |
| 4191 | -                    if (strpos($optgroup_str, "|") !== false) {
 | |
| 4192 | -                        $optgroup_str_arr = explode("|", $optgroup_str, 2);
 | |
| 4193 | - $optgroup_label = trim($optgroup_str_arr[0]); | |
| 4194 | -                        if ($translated && $optgroup_label != '') {
 | |
| 4195 | - $optgroup_label = __($optgroup_label, 'geodirectory'); | |
| 4196 | - } | |
| 4197 | - $optgroup_label = ucfirst($optgroup_label); | |
| 4198 | - $optgroup_str = $optgroup_str_arr[1]; | |
| 4199 | - } | |
| 4200 | - | |
| 4201 | - $optgroup3 = geodir_string_to_options($optgroup_str, $translated); | |
| 4202 | - | |
| 4203 | -                    if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
 | |
| 4204 | -                        $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
 | |
| 4205 | -                        $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
 | |
| 4206 | - $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); | |
| 4207 | - } | |
| 4208 | - $options = array_merge($options, $optgroup3); | |
| 4209 | - } | |
| 4210 | -            } else {
 | |
| 4211 | - $optgroup1 = geodir_string_to_options($optgroup, $translated); | |
| 4212 | - $options = array_merge($options, $optgroup1); | |
| 4213 | - } | |
| 4214 | - } | |
| 4215 | -    } else {
 | |
| 4216 | - $options = geodir_string_to_options($option_values, $translated); | |
| 4217 | - } | |
| 4218 | - | |
| 4219 | - return $options; | |
| 4173 | + $options = array(); | |
| 4174 | +	if ($option_values == '') {
 | |
| 4175 | + return NULL; | |
| 4176 | + } | |
| 4177 | + | |
| 4178 | +	if (strpos($option_values, "{/optgroup}") !== false) {
 | |
| 4179 | +		$option_values_arr = explode("{/optgroup}", $option_values);
 | |
| 4180 | + | |
| 4181 | +		foreach ($option_values_arr as $optgroup) {
 | |
| 4182 | +			if (strpos($optgroup, "{optgroup}") !== false) {
 | |
| 4183 | +				$optgroup_arr = explode("{optgroup}", $optgroup);
 | |
| 4184 | + | |
| 4185 | + $count = 0; | |
| 4186 | +				foreach ($optgroup_arr as $optgroup_str) {
 | |
| 4187 | + $count++; | |
| 4188 | + $optgroup_str = trim($optgroup_str); | |
| 4189 | + | |
| 4190 | + $optgroup_label = ''; | |
| 4191 | +					if (strpos($optgroup_str, "|") !== false) {
 | |
| 4192 | +						$optgroup_str_arr = explode("|", $optgroup_str, 2);
 | |
| 4193 | + $optgroup_label = trim($optgroup_str_arr[0]); | |
| 4194 | +						if ($translated && $optgroup_label != '') {
 | |
| 4195 | + $optgroup_label = __($optgroup_label, 'geodirectory'); | |
| 4196 | + } | |
| 4197 | + $optgroup_label = ucfirst($optgroup_label); | |
| 4198 | + $optgroup_str = $optgroup_str_arr[1]; | |
| 4199 | + } | |
| 4200 | + | |
| 4201 | + $optgroup3 = geodir_string_to_options($optgroup_str, $translated); | |
| 4202 | + | |
| 4203 | +					if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
 | |
| 4204 | +						$optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
 | |
| 4205 | +						$optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
 | |
| 4206 | + $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); | |
| 4207 | + } | |
| 4208 | + $options = array_merge($options, $optgroup3); | |
| 4209 | + } | |
| 4210 | +			} else {
 | |
| 4211 | + $optgroup1 = geodir_string_to_options($optgroup, $translated); | |
| 4212 | + $options = array_merge($options, $optgroup1); | |
| 4213 | + } | |
| 4214 | + } | |
| 4215 | +	} else {
 | |
| 4216 | + $options = geodir_string_to_options($option_values, $translated); | |
| 4217 | + } | |
| 4218 | + | |
| 4219 | + return $options; | |
| 4220 | 4220 | } | 
| 4221 | 4221 | \ No newline at end of file |