| Conditions | 12 |
| Paths | 192 |
| Total Lines | 112 |
| Code Lines | 68 |
| Lines | 8 |
| Ratio | 7.14 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 126 | public function form($instance) |
||
| 127 | {
|
||
| 128 | //widgetform in backend |
||
| 129 | |||
| 130 | $instance = wp_parse_args((array)$instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'child_collapse' => '0', 'scrollwheel' => '0'));
|
||
| 131 | $width = strip_tags($instance['width']); |
||
| 132 | $heigh = strip_tags($instance['heigh']); |
||
| 133 | $maptype = strip_tags($instance['maptype']); |
||
| 134 | $zoom = strip_tags($instance['zoom']); |
||
| 135 | $autozoom = strip_tags($instance['autozoom']); |
||
| 136 | $child_collapse = strip_tags($instance['child_collapse']); |
||
| 137 | $scrollwheel = strip_tags($instance['scrollwheel']); |
||
| 138 | ?> |
||
| 139 | |||
| 140 | <p> |
||
| 141 | <label |
||
| 142 | for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Map Width <small>(Default is : 100%) you can use px or % here</small>', 'geodirectory'); ?>
|
||
| 143 | : |
||
| 144 | <input class="widefat" id="<?php echo $this->get_field_id('width'); ?>"
|
||
| 145 | name="<?php echo $this->get_field_name('width'); ?>" type="text"
|
||
| 146 | value="<?php echo esc_attr($width); ?>"/> |
||
| 147 | </label> |
||
| 148 | </p> |
||
| 149 | <p> |
||
| 150 | <label |
||
| 151 | for="<?php echo $this->get_field_id('heigh'); ?>"><?php _e('Map Height <small>(Default is : 425px) you can use px or vh here</small>', 'geodirectory'); ?>
|
||
| 152 | : |
||
| 153 | <input class="widefat" id="<?php echo $this->get_field_id('heigh'); ?>"
|
||
| 154 | name="<?php echo $this->get_field_name('heigh'); ?>" type="text"
|
||
| 155 | value="<?php echo esc_attr($heigh); ?>"/> |
||
| 156 | </label> |
||
| 157 | </p> |
||
| 158 | |||
| 159 | <p> |
||
| 160 | <label |
||
| 161 | for="<?php echo $this->get_field_id('maptype'); ?>"><?php _e(' Select Map View', 'geodirectory'); ?>
|
||
| 162 | : |
||
| 163 | <select class="widefat" id="<?php echo $this->get_field_id('maptype'); ?>"
|
||
| 164 | name="<?php echo $this->get_field_name('maptype'); ?>">
|
||
| 165 | |||
| 166 | <option <?php if (isset($maptype) && $maptype == 'ROADMAP') {
|
||
| 167 | echo 'selected="selected"'; |
||
| 168 | } ?> value="ROADMAP"><?php _e('Road Map', 'geodirectory'); ?></option>
|
||
| 169 | <option <?php if (isset($maptype) && $maptype == 'SATELLITE') {
|
||
| 170 | echo 'selected="selected"'; |
||
| 171 | } ?> value="SATELLITE"><?php _e('Satellite Map', 'geodirectory'); ?></option>
|
||
| 172 | <option <?php if (isset($maptype) && $maptype == 'HYBRID') {
|
||
| 173 | echo 'selected="selected"'; |
||
| 174 | } ?> value="HYBRID"><?php _e('Hybrid Map', 'geodirectory'); ?></option>
|
||
| 175 | <option <?php selected($maptype, 'TERRAIN');?> |
||
| 176 | value="TERRAIN"><?php _e('Terrain Map', 'geodirectory'); ?></option>
|
||
| 177 | </select> |
||
| 178 | </label> |
||
| 179 | </p> |
||
| 180 | |||
| 181 | <?php |
||
| 182 | $map_zoom_level = geodir_map_zoom_level(); |
||
| 183 | ?> |
||
| 184 | |||
| 185 | <p> |
||
| 186 | <label |
||
| 187 | for="<?php echo $this->get_field_id('zoom'); ?>"><?php _e('Map Zoom level', 'geodirectory'); ?>
|
||
| 188 | : |
||
| 189 | <select class="widefat" id="<?php echo $this->get_field_id('zoom'); ?>"
|
||
| 190 | name="<?php echo $this->get_field_name('zoom'); ?>"> <?php
|
||
| 191 | |||
| 192 | View Code Duplication | foreach ($map_zoom_level as $level) {
|
|
| 193 | $selected = ''; |
||
| 194 | if ($level == $zoom) |
||
| 195 | $selected = 'selected="selected"'; |
||
| 196 | |||
| 197 | echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; |
||
| 198 | |||
| 199 | } ?> |
||
| 200 | |||
| 201 | </select> |
||
| 202 | </label> |
||
| 203 | </p> |
||
| 204 | |||
| 205 | |||
| 206 | <p> |
||
| 207 | <label |
||
| 208 | for="<?php echo $this->get_field_id('autozoom'); ?>"><?php _e('Map Auto Zoom ?', 'geodirectory'); ?>
|
||
| 209 | : |
||
| 210 | <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('autozoom'); ?>"
|
||
| 211 | name="<?php echo $this->get_field_name('autozoom'); ?>"<?php if ($autozoom) {
|
||
| 212 | echo 'checked="checked"'; |
||
| 213 | } ?> /></label> |
||
| 214 | </p> |
||
| 215 | |||
| 216 | <p> |
||
| 217 | <label |
||
| 218 | for="<?php echo $this->get_field_id('child_collapse'); ?>"><?php _e('Collapse child/sub categories ?', 'geodirectory'); ?>
|
||
| 219 | : |
||
| 220 | <input id="<?php echo $this->get_field_id('child_collapse'); ?>"
|
||
| 221 | name="<?php echo $this->get_field_name('child_collapse'); ?>" type="checkbox" value="1"
|
||
| 222 | <?php if ($child_collapse){ ?>checked="checked" <?php } ?> />
|
||
| 223 | </label> |
||
| 224 | </p> |
||
| 225 | |||
| 226 | <p> |
||
| 227 | <label |
||
| 228 | for="<?php echo $this->get_field_id('scrollwheel'); ?>"><?php _e('Enable mouse scroll zoom ?', 'geodirectory'); ?>
|
||
| 229 | : |
||
| 230 | <input id="<?php echo $this->get_field_id('scrollwheel'); ?>"
|
||
| 231 | name="<?php echo $this->get_field_name('scrollwheel'); ?>" type="checkbox" value="1"
|
||
| 232 | <?php if ($scrollwheel){ ?>checked="checked" <?php } ?> />
|
||
| 233 | </label> |
||
| 234 | </p> |
||
| 235 | |||
| 236 | <?php |
||
| 237 | } |
||
| 238 | |||
| 324 | ?> |