Conditions | 7 |
Paths | 3 |
Total Lines | 79 |
Code Lines | 54 |
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 |
||
54 | public function display_page() { |
||
55 | global $post; |
||
56 | ?> |
||
57 | <div class="wrap"> |
||
58 | <h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e( 'Connect your Accommodation', 'lsx-wetu-importer' ); ?></h3> |
||
59 | |||
60 | <form method="get" action="" id="connect-accommodation-filter"> |
||
61 | <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
||
62 | |||
63 | <p><?php esc_html_e( 'Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'lsx-wetu-importer' ); ?></p> |
||
64 | |||
65 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
||
66 | <img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
||
67 | </div> |
||
68 | |||
69 | <?php |
||
70 | $loose_accommodation = $this->find_current_accommodation(); |
||
71 | ?> |
||
72 | <p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect', 'lsx-wetu-importer' ); ?>" /></p> |
||
73 | <table class="wp-list-table widefat fixed posts"> |
||
74 | <?php $this->table_header(); ?> |
||
75 | |||
76 | <tbody> |
||
77 | <?php |
||
78 | if ( false !== $loose_accommodation ) { |
||
79 | |||
80 | $loose_args = array( |
||
81 | 'post_type' => 'accommodation', |
||
82 | 'post_status' => array( 'publish', 'pending' ), |
||
83 | 'nopagin' => true, |
||
84 | 'post__in' => $loose_accommodation, |
||
85 | ); |
||
86 | $loose_accommodation_query = new WP_Query( $loose_args ); |
||
87 | $accommodation = get_transient( 'lsx_ti_accommodation' ); |
||
88 | $identifier = ''; |
||
89 | |||
90 | if ( $loose_accommodation_query->have_posts() && false !== $accommodation ) { |
||
91 | while ( $loose_accommodation_query->have_posts() ) { |
||
92 | $loose_accommodation_query->the_post(); |
||
93 | |||
94 | foreach ( $accommodation as $row_key => $row ) { |
||
95 | if ( stripos( ltrim( rtrim( $row->name ) ), $post->post_title ) !== false ) { |
||
96 | $identifier = $row->id; |
||
97 | } else { |
||
98 | continue; |
||
99 | } |
||
100 | } |
||
101 | ?> |
||
102 | <tr class="post-<?php the_ID(); ?> type-accommodation status-none" id="post-<?php the_ID(); ?>"> |
||
103 | <th class="check-column" scope="row"> |
||
104 | <label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"><?php the_title(); ?></label> |
||
105 | <input type="checkbox" data-identifier="<?php echo esc_attr( $identifier ); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>"> |
||
106 | </th> |
||
107 | <td class="post-title page-title column-title"> |
||
108 | <strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url( admin_url( '/post.php?post=' . $post->ID . '&action=edit' ) ); ?>" target="_blank"><?php echo esc_html( $post->post_status ); ?></a> |
||
109 | </td> |
||
110 | <td class="excerpt column-excerpt"> |
||
111 | <?php |
||
112 | echo wp_kses_post( strip_tags( get_the_excerpt() ) ); |
||
113 | ?> |
||
114 | </td> |
||
115 | </tr> |
||
116 | <?php |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 | ?> |
||
121 | </tbody> |
||
122 | |||
123 | <?php $this->table_footer(); ?> |
||
124 | |||
125 | </table> |
||
126 | |||
127 | <p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect', 'lsx-wetu-importer' ); ?>" /></p> |
||
128 | |||
129 | </form> |
||
130 | |||
131 | <div style="display:none;" class="completed-list-wrapper"> |
||
132 | <h3><?php esc_html_e( 'Completed' ); ?></h3> |
||
133 | <ul> |
||
259 |