Conditions | 4 |
Paths | 5 |
Total Lines | 58 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | 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 |
||
170 | public function admin_footer_text( $footer_text ) { |
||
171 | |||
172 | // Check to make sure we're on a SimpleCal admin page |
||
173 | $screen = simcal_is_admin_screen(); |
||
174 | if ( $screen !== false ) { |
||
|
|||
175 | |||
176 | if ( 'calendar' == $screen ) { |
||
177 | |||
178 | // Add Drip promo signup form (@see Newsletter meta box). |
||
179 | |||
180 | $drip_form_id = '9817628'; |
||
181 | |||
182 | ?> |
||
183 | <form id="simcal-drip-form" |
||
184 | method="post" |
||
185 | target="_blank" |
||
186 | action="https://www.getdrip.com/forms/<?php echo $drip_form_id; ?>/submissions/" |
||
1 ignored issue
–
show
|
|||
187 | data-drip-embedded-form="<?php echo $drip_form_id; ?>"> |
||
1 ignored issue
–
show
|
|||
188 | <input type="hidden" |
||
189 | id="simcal-drip-real-field-first_name" |
||
190 | name="fields[first_name]" |
||
191 | value="" /> |
||
192 | <input type="hidden" |
||
193 | id="simcal-drip-real-field-email" |
||
194 | name="fields[email]" |
||
195 | value="" /> |
||
196 | <input type="submit" |
||
197 | class="hidden"/> |
||
198 | </form> |
||
199 | <?php |
||
200 | |||
201 | } |
||
202 | |||
203 | // Change the footer text |
||
204 | if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
||
205 | |||
206 | $footer_text = sprintf( |
||
207 | __( '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' ), |
||
208 | '<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>' |
||
209 | ); |
||
210 | |||
211 | $footer_text .= '<script type="text/javascript">'; |
||
212 | $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
||
213 | jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
||
214 | jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
||
215 | });"; |
||
216 | $footer_text .= '</script>'; |
||
217 | |||
218 | } else { |
||
219 | |||
220 | $footer_text = __( 'Thank you for using Simple Calendar!', 'google-calendar-events' ); |
||
221 | |||
222 | } |
||
1 ignored issue
–
show
|
|||
223 | |||
224 | } |
||
225 | |||
226 | return $footer_text; |
||
227 | } |
||
228 | |||
230 |