function set_options($input) { global $mappress; // If reset defaults was clicked if (isset($_POST['reset_defaults'])) { $options = new Mappress_Options(); return get_object_vars($this); } // Sizes foreach ($input['sizes'] as &$size) { // Strip 'px' from value but allow '%'. also, % min/max = 5%/100%, px min/max = 200/2048 if (strpos($size['width'], '%')) { $size['width'] = max(5, min(100, (int) $size['width'])) . '%'; } else { $size['width'] = max(200, min(2048, (int) $size['width'])); } if (strpos($size['height'], '%')) { $size['height'] = max(5, min(100, (int) $size['height'])) . '%'; } else { $size['height'] = max(200, min(2048, (int) $size['height'])); } } // If NO post types selected, set value to empty array if (!isset($input['postTypes'])) { $input['postTypes'] = array(); } // Force checkboxes to boolean foreach ($input as &$item) { $item = Mappress::string_to_boolean($item); } // For arrays passed as checkboxes set empty array for no selection // Note: for maptypeids, if no checkboxes are set it will revert back to the default $input['poiLinks'] = isset($input['poiLinks']) ? $input['poiLinks'] : array(); $input['mapLinks'] = isset($input['mapLinks']) ? $input['mapLinks'] : array(); $input['postTypes'] = isset($input['postTypes']) ? $input['postTypes'] : array(); // Must select at least 1 geocoder $input['geocoders'] = isset($input['geocoders']) ? $input['geocoders'] : array('google'); return $input; }