Conditions | 4 |
Paths | 5 |
Total Lines | 60 |
Code Lines | 15 |
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 |
||
165 | public function admin_footer_text( $footer_text ) { |
||
166 | |||
167 | // Check to make sure we're on a SimpleCal admin page |
||
168 | $screen = simcal_is_admin_screen(); |
||
169 | if ( $screen !== false ) { |
||
170 | |||
171 | if ( 'calendar' == $screen ) { |
||
|
|||
172 | |||
173 | // Add Drip promo signup form (@see Newsletter meta box). |
||
174 | // Removed 9/26/16. |
||
175 | |||
176 | /* |
||
177 | $drip_form_id = '5368192'; |
||
178 | |||
179 | ?> |
||
180 | <form id="simcal-drip-form" |
||
181 | method="post" |
||
182 | target="_blank" |
||
183 | action="https://www.getdrip.com/forms/<?php echo $drip_form_id; ?>/submissions/" |
||
184 | data-drip-embedded-form="<?php echo $drip_form_id; ?>"> |
||
185 | <input type="hidden" |
||
186 | id="simcal-drip-real-field-first_name" |
||
187 | name="fields[first_name]" |
||
188 | value="" /> |
||
189 | <input type="hidden" |
||
190 | id="simcal-drip-real-field-email" |
||
191 | name="fields[email]" |
||
192 | value="" /> |
||
193 | <input type="submit" |
||
194 | class="hidden"/> |
||
195 | </form> |
||
196 | <?php |
||
197 | */ |
||
198 | } |
||
199 | |||
200 | // Change the footer text |
||
201 | if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
||
202 | |||
203 | $footer_text = sprintf( |
||
204 | __( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ), |
||
205 | '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' |
||
206 | ); |
||
207 | |||
208 | $footer_text .= '<script type="text/javascript">'; |
||
209 | $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
||
210 | jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
||
211 | jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
||
212 | });"; |
||
213 | $footer_text .= '</script>'; |
||
214 | |||
215 | } else { |
||
216 | |||
217 | $footer_text = __( 'Thanks for using Simple Calendar!', 'google-calendar-events' ); |
||
218 | |||
219 | } |
||
220 | |||
221 | } |
||
222 | |||
223 | return $footer_text; |
||
224 | } |
||
225 | |||
227 |
This check looks for the bodies of
if
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
if
bodies can be removed. If you have an empty if but statements in theelse
branch, consider inverting the condition.could be turned into
This is much more concise to read.