| Conditions | 11 |
| Paths | 32 |
| Total Lines | 190 |
| Code Lines | 146 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 151 | public function form( $instance ) { |
||
| 152 | $defaults = array( |
||
| 153 | 'title' => 'Team Members', |
||
| 154 | 'title_link' => '', |
||
| 155 | 'tagline' => '', |
||
| 156 | 'columns' => '1', |
||
| 157 | 'orderby' => 'name', |
||
| 158 | 'order' => 'ASC', |
||
| 159 | 'role' => '', |
||
| 160 | 'limit' => '', |
||
| 161 | 'include' => '', |
||
| 162 | 'display' => 'excerpt', |
||
| 163 | 'size' => 'lsx-team-archive', |
||
| 164 | 'show_link' => 0, |
||
| 165 | 'show_image' => 1, |
||
| 166 | 'show_roles' => 0, |
||
| 167 | 'show_job_title' => 1, |
||
| 168 | 'show_desc' => 1, |
||
| 169 | 'show_social' => 1, |
||
| 170 | 'button_text' => '', |
||
| 171 | 'carousel' => 1, |
||
| 172 | 'featured' => 0, |
||
| 173 | ); |
||
| 174 | |||
| 175 | $instance = wp_parse_args( (array) $instance, $defaults ); |
||
| 176 | |||
| 177 | $title = esc_attr( $instance['title'] ); |
||
| 178 | $title_link = esc_attr( $instance['title_link'] ); |
||
| 179 | $tagline = esc_attr( $instance['tagline'] ); |
||
| 180 | $columns = esc_attr( $instance['columns'] ); |
||
| 181 | $orderby = esc_attr( $instance['orderby'] ); |
||
| 182 | $order = esc_attr( $instance['order'] ); |
||
| 183 | $role = esc_attr( $instance['role'] ); |
||
| 184 | $limit = esc_attr( $instance['limit'] ); |
||
| 185 | $include = esc_attr( $instance['include'] ); |
||
| 186 | $display = esc_attr( $instance['display'] ); |
||
| 187 | $size = esc_attr( $instance['size'] ); |
||
| 188 | $show_link = esc_attr( $instance['show_link'] ); |
||
| 189 | $show_image = esc_attr( $instance['show_image'] ); |
||
| 190 | $show_roles = esc_attr( $instance['show_roles'] ); |
||
| 191 | $show_job_title = esc_attr( $instance['show_job_title'] ); |
||
| 192 | $show_desc = esc_attr( $instance['show_desc'] ); |
||
| 193 | $show_social = esc_attr( $instance['show_social'] ); |
||
| 194 | $button_text = esc_attr( $instance['button_text'] ); |
||
| 195 | $carousel = esc_attr( $instance['carousel'] ); |
||
| 196 | $featured = esc_attr( $instance['featured'] ); |
||
| 197 | ?> |
||
| 198 | <p> |
||
| 199 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'lsx-team' ); ?></label> |
||
| 200 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> |
||
| 201 | </p> |
||
| 202 | <p> |
||
| 203 | <label for="<?php echo esc_attr( $this->get_field_id( 'title_link' ) ); ?>"><?php esc_html_e( 'Page Link:', 'lsx-team' ); ?></label> |
||
| 204 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title_link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title_link' ) ); ?>" type="text" value="<?php echo esc_attr( $title_link ); ?>" /> |
||
| 205 | <small><?php esc_html_e( 'Link the widget to a page', 'lsx-team' ); ?></small> |
||
| 206 | </p> |
||
| 207 | <p> |
||
| 208 | <label for="<?php echo esc_attr( $this->get_field_id( 'tagline' ) ); ?>"><?php esc_html_e( 'Tagline:', 'lsx-team' ); ?></label> |
||
| 209 | <textarea class="widefat" rows="8" cols="20" id="<?php echo esc_attr( $this->get_field_id( 'tagline' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'tagline' ) ); ?>"><?php echo esc_html( $tagline ); ?></textarea> |
||
| 210 | <small><?php esc_html_e( 'Tagline to display below the widget title', 'lsx-team' ); ?></small> |
||
| 211 | </p> |
||
| 212 | <p> |
||
| 213 | <label for="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>"><?php esc_html_e( 'Columns:', 'lsx-team' ); ?></label> |
||
| 214 | <select name="<?php echo esc_attr( $this->get_field_name( 'columns' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>" class="widefat layout"> |
||
| 215 | <?php |
||
| 216 | $options = array( '1', '2', '3', '4' ); |
||
| 217 | |||
| 218 | foreach ( $options as $option ) { |
||
| 219 | echo '<option value="' . lcfirst( esc_attr( $option ) ) . '" id="' . esc_attr( $option ) . '"', lcfirst( $option ) == $columns ? ' selected="selected"' : '', '>', esc_html( $option ), '</option>'; |
||
| 220 | } |
||
| 221 | ?> |
||
| 222 | </select> |
||
| 223 | </p> |
||
| 224 | <p> |
||
| 225 | <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order By:', 'lsx-team' ); ?></label> |
||
| 226 | <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat"> |
||
| 227 | <?php |
||
| 228 | $options = array( |
||
| 229 | esc_html__( 'None', 'lsx-team' ) => 'none', |
||
| 230 | esc_html__( 'ID', 'lsx-team' ) => 'ID', |
||
| 231 | esc_html__( 'Name', 'lsx-team' ) => 'name', |
||
| 232 | esc_html__( 'Date', 'lsx-team' ) => 'date', |
||
| 233 | esc_html__( 'Modified Date', 'lsx-team' ) => 'modified', |
||
| 234 | esc_html__( 'Random', 'lsx-team' ) => 'rand', |
||
| 235 | esc_html__( 'Menu (WP dashboard order)', 'lsx-team' ) => 'menu_order', |
||
| 236 | ); |
||
| 237 | |||
| 238 | foreach ( $options as $name => $value ) { |
||
| 239 | echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $orderby == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
||
| 240 | } |
||
| 241 | ?> |
||
| 242 | </select> |
||
| 243 | </p> |
||
| 244 | <p> |
||
| 245 | <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order:', 'lsx-team' ); ?></label> |
||
| 246 | <select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" class="widefat"> |
||
| 247 | <?php |
||
| 248 | $options = array( |
||
| 249 | esc_html__( 'Ascending', 'lsx-team' ) => 'ASC', |
||
| 250 | esc_html__( 'Descending', 'lsx-team' ) => 'DESC', |
||
| 251 | ); |
||
| 252 | |||
| 253 | foreach ( $options as $name => $value ) { |
||
| 254 | echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $order == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
||
| 255 | } |
||
| 256 | ?> |
||
| 257 | </select> |
||
| 258 | </p> |
||
| 259 | <p> |
||
| 260 | <label for="<?php echo esc_attr( $this->get_field_id( 'role' ) ); ?>"><?php esc_html_e( 'Role:', 'lsx-team' ); ?></label> |
||
| 261 | <select name="<?php echo esc_attr( $this->get_field_name( 'role' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'role' ) ); ?>" class="widefat"> |
||
| 262 | <?php |
||
| 263 | $options = get_terms( 'team_role' ); |
||
| 264 | ?> |
||
| 265 | <option value="all" id="all"> |
||
| 266 | <?php esc_html_e( 'All Roles', 'lsx-team' ); ?> |
||
| 267 | </option> |
||
| 268 | <?php |
||
| 269 | foreach ( $options as $option ) { |
||
| 270 | echo '<option value="' . esc_attr( $option->slug ) . '" id="' . esc_attr( $option->slug ) . '"', $role == $option->slug ? ' selected="selected"' : '', '>', esc_html( $option->name ), '</option>'; |
||
| 271 | } |
||
| 272 | ?> |
||
| 273 | </select> |
||
| 274 | <small><?php esc_html_e( 'Display team members within a specific role', 'lsx-team' ); ?></small> |
||
| 275 | </p> |
||
| 276 | <p> |
||
| 277 | <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php esc_html_e( 'Maximum amount:', 'lsx-team' ); ?></label> |
||
| 278 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" /> |
||
| 279 | <small><?php esc_html_e( 'Leave empty to display all', 'lsx-team' ); ?></small> |
||
| 280 | </p> |
||
| 281 | <p> |
||
| 282 | <label for="<?php echo esc_attr( $this->get_field_id( 'include' ) ); ?>"><?php esc_html_e( 'Specify Team Members by ID:', 'lsx-team' ); ?></label> |
||
| 283 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'include' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'include' ) ); ?>" type="text" value="<?php echo esc_attr( $include ); ?>" /> |
||
| 284 | <small><?php esc_html_e( 'Comma separated list, overrides limit setting', 'lsx-team' ); ?></small> |
||
| 285 | </p> |
||
| 286 | <p> |
||
| 287 | <label for="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>"><?php esc_html_e( 'Display:', 'lsx-team' ); ?></label> |
||
| 288 | <select name="<?php echo esc_attr( $this->get_field_name( 'display' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>" class="widefat"> |
||
| 289 | <?php |
||
| 290 | $options = array( |
||
| 291 | esc_html__( 'Excerpt', 'lsx-team' ) => 'excerpt', |
||
| 292 | esc_html__( 'Full Content', 'lsx-team' ) => 'full', |
||
| 293 | ); |
||
| 294 | |||
| 295 | foreach ( $options as $name => $value ) { |
||
| 296 | echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $display == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
||
| 297 | } |
||
| 298 | ?> |
||
| 299 | </select> |
||
| 300 | </p> |
||
| 301 | <p> |
||
| 302 | <label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php esc_html_e( 'Image size:', 'lsx-team' ); ?></label> |
||
| 303 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'size' ) ); ?>" type="text" value="<?php echo esc_attr( $size ); ?>" /> |
||
| 304 | </p> |
||
| 305 | <p> |
||
| 306 | <label for="<?php echo esc_attr( $this->get_field_id( 'button_text' ) ); ?>"><?php esc_html_e( 'Button "view all" text:', 'lsx-team' ); ?></label> |
||
| 307 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'button_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'button_text' ) ); ?>" type="text" value="<?php echo esc_attr( $button_text ); ?>" /> |
||
| 308 | <small><?php esc_html_e( 'Leave empty to not display the button', 'lsx-team' ); ?></small> |
||
| 309 | </p> |
||
| 310 | <p> |
||
| 311 | <input id="<?php echo esc_attr( $this->get_field_id( 'show_link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_link' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_link ); ?> /> |
||
| 312 | <label for="<?php echo esc_attr( $this->get_field_id( 'show_link' ) ); ?>"><?php esc_html_e( 'Link to Single', 'lsx-team' ); ?></label> |
||
| 313 | </p> |
||
| 314 | <p> |
||
| 315 | <input id="<?php echo esc_attr( $this->get_field_id( 'show_image' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_image' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_image ); ?> /> |
||
| 316 | <label for="<?php echo esc_attr( $this->get_field_id( 'show_image' ) ); ?>"><?php esc_html_e( 'Show Images', 'lsx-team' ); ?></label> |
||
| 317 | </p> |
||
| 318 | <p> |
||
| 319 | <input id="<?php echo esc_attr( $this->get_field_id( 'show_roles' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_roles' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_roles ); ?> /> |
||
| 320 | <label for="<?php echo esc_attr( $this->get_field_id( 'show_roles' ) ); ?>"><?php esc_html_e( 'Show Roles', 'lsx-team' ); ?></label> |
||
| 321 | </p> |
||
| 322 | <p> |
||
| 323 | <input id="<?php echo esc_attr( $this->get_field_id( 'show_job_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_job_title' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_job_title ); ?> /> |
||
| 324 | <label for="<?php echo esc_attr( $this->get_field_id( 'show_job_title' ) ); ?>"><?php esc_html_e( 'Show Job Title', 'lsx-team' ); ?></label> |
||
| 325 | </p> |
||
| 326 | <p> |
||
| 327 | <input id="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_desc' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_desc ); ?> /> |
||
| 328 | <label for="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"><?php esc_html_e( 'Show Description', 'lsx-team' ); ?></label> |
||
| 329 | </p> |
||
| 330 | <p> |
||
| 331 | <input id="<?php echo esc_attr( $this->get_field_id( 'show_social' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_social' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_social ); ?> /> |
||
| 332 | <label for="<?php echo esc_attr( $this->get_field_id( 'show_social' ) ); ?>"><?php esc_html_e( 'Show Social Icons', 'lsx-team' ); ?></label> |
||
| 333 | </p> |
||
| 334 | <p> |
||
| 335 | <input id="<?php echo esc_attr( $this->get_field_id( 'carousel' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'carousel' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $carousel ); ?> /> |
||
| 336 | <label for="<?php echo esc_attr( $this->get_field_id( 'carousel' ) ); ?>"><?php esc_html_e( 'Carousel', 'lsx-team' ); ?></label> |
||
| 337 | </p> |
||
| 338 | <p> |
||
| 339 | <input id="<?php echo esc_attr( $this->get_field_id( 'featured' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'featured' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $featured ); ?> /> |
||
| 340 | <label for="<?php echo esc_attr( $this->get_field_id( 'featured' ) ); ?>"><?php esc_html_e( 'Featured posts', 'lsx-team' ); ?></label> |
||
| 341 | </p> |
||
| 355 |