| Conditions | 7 |
| Paths | 2 |
| Total Lines | 129 |
| Code Lines | 91 |
| 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 |
||
| 36 | public function display_page() { |
||
| 37 | ?> |
||
| 38 | <div class="wrap"> |
||
| 39 | <h2><?php esc_html_e( 'Download new banners straight from WETU', 'lsx-wetu-importer' ); ?></h2> |
||
| 40 | |||
| 41 | <form method="get" action="" id="banners-filter"> |
||
| 42 | <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
||
| 43 | |||
| 44 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
||
| 45 | <img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
||
| 46 | </div> |
||
| 47 | |||
| 48 | <table class="wp-list-table widefat fixed posts"> |
||
| 49 | <thead> |
||
| 50 | <tr> |
||
| 51 | <th style="" class="manage-column column-cb check-column" id="cb" scope="col"> |
||
| 52 | <label for="cb-select-all-1" class="screen-reader-text">Select All</label> |
||
| 53 | <input type="checkbox" id="cb-select-all-1"> |
||
| 54 | </th> |
||
| 55 | <th style="width:15%" class="manage-column column-title " id="title" scope="col">Title</th> |
||
| 56 | <th style="" class="manage-column column-date" id="date" scope="col">Images</th> |
||
| 57 | </tr> |
||
| 58 | </thead> |
||
| 59 | |||
| 60 | <?php |
||
| 61 | $accommodation_args = array( |
||
| 62 | 'post_type' => 'accommodation', |
||
| 63 | 'post_status' => array( 'publish', 'pending', 'draft', 'future', 'private' ), |
||
| 64 | 'nopagin' => 'true', |
||
| 65 | 'posts_per_page' => '1000', |
||
| 66 | 'meta_query' => array( |
||
| 67 | 'relation' => 'AND', |
||
| 68 | array( |
||
| 69 | 'key' => 'lsx_wetu_id', |
||
| 70 | 'compare' => 'EXISTS', |
||
| 71 | ), |
||
| 72 | array( |
||
| 73 | 'key' => 'image_group', |
||
| 74 | 'compare' => 'EXISTS', |
||
| 75 | ), |
||
| 76 | array( |
||
| 77 | 'key' => 'image_group', |
||
| 78 | 'value' => 'a:1:{s:12:"banner_image";a:0:{}}', |
||
| 79 | 'compare' => '!=', |
||
| 80 | ), |
||
| 81 | ), |
||
| 82 | ); |
||
| 83 | $accommodation = new WP_Query( $accommodation_args ); |
||
| 84 | ?> |
||
| 85 | |||
| 86 | <tbody id="the-list"> |
||
| 87 | <?php |
||
| 88 | if ( $accommodation->have_posts() ) { |
||
| 89 | while ( $accommodation->have_posts() ) { |
||
| 90 | $accommodation->the_post(); |
||
| 91 | ?> |
||
| 92 | <tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>"> |
||
| 93 | <?php |
||
| 94 | $banner_size_appropriate = false; |
||
| 95 | $min_width = '1920'; |
||
| 96 | $min_height = '500'; |
||
| 97 | |||
| 98 | $img_group = get_post_meta( get_the_ID(), 'image_group', true ); |
||
| 99 | |||
| 100 | $thumbnails_html = false; |
||
| 101 | |||
| 102 | if ( false !== $img_group ) { |
||
| 103 | foreach ( $img_group['banner_image'] as $banner_image ) { |
||
| 104 | $large = wp_get_attachment_image_src( $banner_image, 'full' ); |
||
| 105 | $real_width = $large[1]; |
||
| 106 | $real_height = $large[2]; |
||
| 107 | |||
| 108 | $status = 'optimized'; |
||
| 109 | if ( $real_width < intval( $real_width ) ) { |
||
| 110 | $status = 'width not enough.'; |
||
| 111 | } |
||
| 112 | |||
| 113 | $thumbnail = wp_get_attachment_image_src( $banner_image, 'thumbnail' ); |
||
| 114 | $thumbnails_html[] = ' |
||
| 115 | <div style="display:block;float:left;"> |
||
| 116 | <img src="' . $thumbnail[0] . '" /> |
||
| 117 | <p style="text-align:center;">' . $real_width . 'px by ' . $real_height . 'px</p> |
||
| 118 | </div>'; |
||
| 119 | } |
||
| 120 | } |
||
| 121 | ?> |
||
| 122 | <th class="check-column" scope="row"> |
||
| 123 | <label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"></label> |
||
| 124 | <input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>"> |
||
| 125 | </th> |
||
| 126 | |||
| 127 | <td class="post-title page-title column-title"> |
||
| 128 | <?php |
||
| 129 | echo '<a href="' . esc_url( admin_url( '/post.php?post=' . get_the_ID() . '&action=edit' ) ) . '" target="_blank">'; |
||
| 130 | the_title(); |
||
| 131 | echo '</a>'; |
||
| 132 | ?> |
||
| 133 | </td> |
||
| 134 | |||
| 135 | <td colspan="2" class="thumbnails column-thumbnails"> |
||
| 136 | <?php |
||
| 137 | if ( false !== $thumbnails_html ) { |
||
| 138 | echo wp_kses_post( implode( '', $thumbnails_html ) ); |
||
| 139 | } else { |
||
| 140 | echo '<p>There was an error retrieving your images.</p>'; |
||
| 141 | } |
||
| 142 | ?> |
||
| 143 | </td> |
||
| 144 | </tr> |
||
| 145 | <?php |
||
| 146 | } |
||
| 147 | } |
||
| 148 | ?> |
||
| 149 | </tbody> |
||
| 150 | |||
| 151 | <tfoot> |
||
| 152 | <tr> |
||
| 153 | <th style="" class="manage-column column-cb check-column" id="cb" scope="col"> |
||
| 154 | <label for="cb-select-all-1" class="screen-reader-text">Select All</label> |
||
| 155 | <input type="checkbox" id="cb-select-all-1"> |
||
| 156 | </th> |
||
| 157 | <th style="width:15%;" class="manage-column column-title " id="title" scope="col">Title</th> |
||
| 158 | <th style="" class="manage-column column-date" id="date" scope="col">Images</th> |
||
| 159 | </tr> |
||
| 160 | </tfoot> |
||
| 161 | |||
| 162 | </table> |
||
| 163 | |||
| 164 | <p><input class="button button-primary download" type="button" value="<?php esc_html_e( 'Download new Banners', 'lsx-wetu-importer' ); ?>" /> |
||
| 165 | </p> |
||
| 291 |