Conditions | 3 |
Paths | 2 |
Total Lines | 109 |
Code Lines | 38 |
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 |
||
227 | private static function form_template( $button, $action ) { |
||
228 | // Enqueue Scripts for Media Manager |
||
229 | wp_enqueue_media(); |
||
230 | // Adjust if is_network |
||
231 | $is_network = is_network_admin(); |
||
232 | ?> |
||
233 | <form method="post" action="<?php echo ( $is_network === true ? '/wp-admin/network/settings' : 'options-general' ) ?>.php?page=podlove-subscribe-button&button=<?php echo $button->id; ?>&action=<?php echo $action; ?>&network=<?php echo $is_network; ?>"> |
||
234 | <input type="hidden" value="<?php echo $button->id; ?>" name="podlove_button[id]" /> |
||
235 | <table class="form-table" border="0" cellspacing="0"> |
||
236 | <tbody> |
||
237 | <tr> |
||
238 | <th scope="row"> |
||
239 | <label for="podlove_button_name"><?php _e( 'Button ID', 'podlove-subscribe-button' ); ?></label> |
||
240 | </th> |
||
241 | <td> |
||
242 | <input type="text" class="regular-text" id="podlove_button_name" name="podlove_button[name]" value="<?php echo $button->name; ?>" /> |
||
243 | <p class="description"><?php _e( 'The ID will be used as in internal identifier for shortcodes.', 'podlove-subscribe-button' ); ?></p> |
||
244 | </td> |
||
245 | </tr> |
||
246 | <tr> |
||
247 | <th scope="row"> |
||
248 | <label for="podlove_button_title"><?php _e( 'Podcast Title', 'podlove-subscribe-button' ); ?></label> |
||
249 | </th> |
||
250 | <td> |
||
251 | <input type="text" class="regular-text" id="podlove_button_title" name="podlove_button[title]" value="<?php echo $button->title; ?>" /> |
||
252 | </td> |
||
253 | </tr> |
||
254 | <tr> |
||
255 | <th scope="row"> |
||
256 | <label for="podlove_button_subtitle"><?php _e( 'Podcast Subtitle', 'podlove-subscribe-button' ); ?></label> |
||
257 | </th> |
||
258 | <td> |
||
259 | <input type="text" class="regular-text" id="podlove_button_subtitle" name="podlove_button[subtitle]" value="<?php echo $button->subtitle; ?>" /> |
||
260 | </td> |
||
261 | </tr> |
||
262 | <tr> |
||
263 | <th scope="row"> |
||
264 | <label for="podlove_button_description"><?php _e( 'Podcast Description', 'podlove-subscribe-button' ); ?></label> |
||
265 | </th> |
||
266 | <td> |
||
267 | <textarea class="autogrow" cols="40" rows="3" id="podlove_button_description" name="podlove_button[description]"><?php echo $button->description; ?></textarea> |
||
268 | </td> |
||
269 | </tr> |
||
270 | <tr> |
||
271 | <th scope="row"> |
||
272 | <label for="podlove-button-cover"><?php _e( 'Podcast Image URL', 'podlove-subscribe-button' ); ?></label> |
||
273 | </th> |
||
274 | <td> |
||
275 | <input type="text" class="regular-text" id="podlove-button-cover" name="podlove_button[cover]" value="<?php echo $button->cover; ?>" /> |
||
276 | <a id="Podlove_cover_image_select" class="button" href="#">Select</a> |
||
277 | <br /><img src="<?php echo $button->cover; ?>" alt="" style="width: 200px" /> |
||
278 | <script type="text/javascript"> |
||
279 | (function($) { |
||
280 | $("#podlove-button-cover").on( 'change', function() { |
||
281 | url = $(this).val(); |
||
282 | $(this).parent().find("img").attr("src", url); |
||
283 | } ); |
||
284 | })(jQuery); |
||
285 | </script> |
||
286 | </td> |
||
287 | </tr> |
||
288 | <tr> |
||
289 | <th scope="row"> |
||
290 | <label for="feeds_table"><?php _e( 'Podcast Feeds', 'podlove-subscribe-button' ); ?></label> |
||
291 | </th> |
||
292 | <td> |
||
293 | <table id="feeds_table" class="podlove_alternating widefat striped"> |
||
294 | <thead> |
||
295 | <tr> |
||
296 | <th scope="col" id="url" class="manage-column column-primary"><?php _e( 'URL', 'podlove-subscribe-button' ); ?></th> |
||
297 | <th scope="col" id="itunes_id" class="manage-column"><?php _e( 'iTunes feed ID', 'podlove-subscribe-button' ); ?></th> |
||
298 | <th scope="col" id="format" class="manage-column"><?php _e( 'Media format', 'podlove-subscribe-button' ); ?></th> |
||
299 | <th scope="col" id="action" class="manage-column"><?php _e( 'Actions', 'podlove-subscribe-button' ); ?></th> |
||
300 | </tr> |
||
301 | </thead> |
||
302 | <tbody id="feeds_table_body"> |
||
303 | </tbody> |
||
304 | </table> |
||
305 | <input type="button" class="button add_feed" value="+" /> |
||
306 | <p><span class="description"><?php _e( 'Provide all Feeds with their corresponding Media File Type. The Subscribe Button will then automatically provide the most suitable feed to the subscriber with respect to their Podcast Client.', 'podlove-subscribe-button' ); ?></span></p> |
||
307 | </td> |
||
308 | </tr> |
||
309 | </tbody> |
||
310 | </table> |
||
311 | <input name="submit" id="submit" class="button button-primary" value="<?php _e( 'Save Changes', 'podlove-subscribe-button' ); ?>" type="submit" /> |
||
312 | <input type="submit" name="submit_and_stay" id="submit_and_stay" class="button" value="<?php _e( 'Save Changes and Continue Editing', 'podlove-subscribe-button' ); ?>" /> |
||
313 | |||
314 | <script type="text/template" id="feed_line_template"> |
||
315 | <tr> |
||
316 | <td> |
||
317 | <input type="text" class="regular-text" name="podlove_button[feeds][{{id}}][url]" value="{{url}}" /> |
||
318 | </td> |
||
319 | <td> |
||
320 | <input type="text" class="regular-text" name="podlove_button[feeds][{{id}}][itunesfeedid]" value="{{itunesfeedid}}" /> |
||
321 | </td> |
||
322 | <td> |
||
323 | <select class="regular-text podlove-media-format" name="podlove_button[feeds][{{id}}][format]"> |
||
324 | <?php |
||
325 | foreach ( \PodloveSubscribeButton\Defaults::media_types() as $id => $audio ) { |
||
326 | echo "<option value='" . $id . "'>" . $audio[ 'title' ] . "</option>\n"; |
||
327 | } |
||
328 | ?> |
||
329 | </select> |
||
330 | </td> |
||
331 | <td><span class="dashicons dashicons-trash clickable podlove-icon-remove"></span></td> |
||
332 | </tr> |
||
333 | </script> |
||
334 | <script type="text/javascript"> |
||
335 | var feeds = <?php echo json_encode( $button->feeds ); ?>; |
||
336 | </script> |
||
364 |