Conditions | 6 |
Paths | 32 |
Total Lines | 106 |
Code Lines | 74 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
59 | public function form( $instance ) { |
||
60 | $instance = wp_parse_args( ( array ) $instance, array( |
||
61 | 'title' => 'about.me', |
||
62 | 'fontsize' => 'large', |
||
63 | 'photo' => 'background', |
||
64 | 'client_id' => '', |
||
65 | 'error' => 0, |
||
66 | 'debug_url' => '', |
||
67 | 'src_url' => str_ireplace( array( |
||
68 | 'https://', |
||
69 | 'http://' |
||
70 | ), '', get_site_url() ), |
||
71 | 'username' => '', |
||
72 | 'headline' => '1', |
||
73 | 'biography' => 1, |
||
74 | 'apps' => 1, |
||
75 | 'links' => 1 |
||
76 | ) ); |
||
77 | $title = $instance['title']; |
||
78 | $fontsize = $instance['fontsize']; |
||
79 | $photo = 'no-photo' === $instance['photo'] ? 'no-photo' : 'background'; |
||
80 | $username = array_key_exists( 'username', $instance ) ? $instance['username'] : ''; |
||
81 | $headline = array_key_exists( 'headline', $instance ) ? $instance['headline'] : '1'; |
||
82 | $biography = array_key_exists( 'biography', $instance ) ? $instance['biography'] : '1'; |
||
83 | $apps = array_key_exists( 'apps', $instance ) ? $instance['apps'] : '1'; |
||
84 | |||
85 | ?> |
||
86 | <p> |
||
87 | <strong style="color: #ff6347;"> |
||
88 | <?php _e( 'The about.me widget will no longer be available after July 1, 2016. ' . |
||
89 | 'After this date, the widget will display a simple text link to your about.me profile. ' . |
||
90 | 'Please remove this widget.', 'jetpack' ); |
||
91 | ?> |
||
92 | </strong> |
||
93 | </p> |
||
94 | <p> |
||
95 | <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Widget title', 'jetpack' ); ?> |
||
96 | :</label> |
||
97 | <input id="<?php echo $this->get_field_id( 'title' ); ?>" |
||
98 | name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" |
||
99 | value="<?php echo esc_attr( $title ); ?>"/> |
||
100 | </p> |
||
101 | <p> |
||
102 | <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e( 'Your about.me URL', 'jetpack' ); ?> |
||
103 | :</label> |
||
104 | <input id="<?php echo $this->get_field_id( 'username' ); ?>" |
||
105 | name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo esc_url( $username ); ?>" |
||
106 | style="width: 100%;" type="text"/> |
||
107 | </p> |
||
108 | <p> |
||
109 | <label for="<?php echo $this->get_field_id( 'fontsize' ); ?>"><?php _e( 'Name', 'jetpack' ); ?>:</label> |
||
110 | <select id="<?php echo $this->get_field_id( 'fontsize' ); ?>" |
||
111 | name="<?php echo $this->get_field_name( 'fontsize' ); ?>"> |
||
112 | <option |
||
113 | value='x-large' <?php selected( $fontsize, 'x-large' ); ?>><?php _e( 'Display X-Large', 'jetpack' ) ?></option> |
||
114 | <option |
||
115 | value='large' <?php selected( $fontsize, 'large' ); ?>><?php _e( 'Display Large', 'jetpack' ) ?></option> |
||
116 | <option |
||
117 | value='medium' <?php selected( $fontsize, 'medium' ); ?>><?php _e( 'Display Medium', 'jetpack' ) ?></option> |
||
118 | <option |
||
119 | value='small' <?php selected( $fontsize, 'small' ); ?>><?php _e( 'Display Small', 'jetpack' ) ?></option> |
||
120 | <option |
||
121 | value='no-name' <?php selected( $fontsize, 'no-name' ); ?>><?php _e( "Don't Display Name", 'jetpack' ) ?></option> |
||
122 | </select> |
||
123 | </p> |
||
124 | <p> |
||
125 | <label for="<?php echo $this->get_field_id( 'photo' ); ?>"><?php _e( 'Photo', 'jetpack' ); ?>: |
||
126 | <input type="checkbox" id="<?php echo $this->get_field_id( 'photo' ); ?>" |
||
127 | name="<?php echo $this->get_field_name( 'photo' ); ?>" |
||
128 | value="background" <?php checked( $photo, 'background' ); ?> /> |
||
129 | </label> |
||
130 | </p> |
||
131 | <p> |
||
132 | <label for="<?php echo $this->get_field_id( 'headline' ); ?>"><?php _e( 'Headline', 'jetpack' ); ?>: |
||
133 | <input type="checkbox" id="<?php echo $this->get_field_id( 'headline' ); ?>" |
||
134 | name="<?php echo $this->get_field_name( 'headline' ); ?>" |
||
135 | value="1" <?php checked( $headline, '1' ); ?> /> |
||
136 | </label> |
||
137 | </p> |
||
138 | <p> |
||
139 | <label for="<?php echo $this->get_field_id( 'biography' ); ?>"><?php _e( 'Biography', 'jetpack' ); ?>: |
||
140 | <input type="checkbox" id="<?php echo $this->get_field_id( 'biography' ); ?>" |
||
141 | name="<?php echo $this->get_field_name( 'biography' ); ?>" |
||
142 | value="1" <?php checked( $biography, '1' ); ?> /> |
||
143 | </label> |
||
144 | </p> |
||
145 | <p> |
||
146 | <label for="<?php echo $this->get_field_id( 'apps' ); ?>"><?php _e( 'Apps', 'jetpack' ); ?>: |
||
147 | <input type="checkbox" id="<?php echo $this->get_field_id( 'apps' ); ?>" |
||
148 | name="<?php echo $this->get_field_name( 'apps' ); ?>" |
||
149 | value="1" <?php checked( $apps, '1' ); ?> /> |
||
150 | </label> |
||
151 | </p> |
||
152 | <p> |
||
153 | <input type="hidden" id="<?php echo $this->get_field_id( 'client_id' ); ?>" |
||
154 | name="<?php echo $this->get_field_name( 'client_id' ); ?>" |
||
155 | value="<?php echo esc_attr( $instance['client_id'] ); ?>"> |
||
156 | <input type="hidden" id="<?php echo $this->get_field_id( 'error' ); ?>" |
||
157 | name="<?php echo $this->get_field_name( 'error' ); ?>" |
||
158 | value="<?php echo esc_attr( $instance['error'] ); ?>"> |
||
159 | <input type="hidden" id="<?php echo $this->get_field_id( 'src_url' ); ?>" |
||
160 | name="<?php echo $this->get_field_name( 'src_url' ); ?>" |
||
161 | value="<?php echo esc_attr( $instance['src_url'] ); ?>"> |
||
162 | </p> |
||
163 | <?php |
||
164 | } |
||
165 | } |
||
179 |
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.