Code Duplication    Length = 57-57 lines in 2 locations

includes/class-wpinv-bp-core.php 1 location

@@ 142-198 (lines=57) @@
139
                        </tr>
140
                    </thead>
141
                    <tbody>
142
                        <?php foreach ( $invoices_template->invoices as $invoice ) {
143
                            ?>
144
                            <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
145
                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
146
                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
147
                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
148
                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
149
150
                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
151
                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
152
                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
153
                                            </a>
154
155
                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
156
                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
157
158
                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
159
                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
160
161
                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
162
                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
163
164
                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
165
                                            <?php echo $invoice->get_total( true ); ?>
166
167
                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
168
                                            <?php
169
                                                $actions = array(
170
                                                    'pay'    => array(
171
                                                        'url'  => $invoice->get_checkout_payment_url(),
172
                                                        'name' => __( 'Pay Now', 'invoicing' ),
173
                                                        'class' => 'btn-success'
174
                                                    ),
175
                                                    'print'   => array(
176
                                                        'url'  => $invoice->get_view_url(),
177
                                                        'name' => __( 'Print', 'invoicing' ),
178
                                                        'class' => 'btn-primary',
179
                                                        'attrs' => 'target="_blank"'
180
                                                    )
181
                                                );
182
183
                                                if ( ! $invoice->needs_payment() ) {
184
                                                    unset( $actions['pay'] );
185
                                                }
186
187
                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
188
                                                    foreach ( $actions as $key => $action ) {
189
                                                        $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
190
                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
191
                                                    }
192
                                                }
193
                                            ?>
194
                                        <?php endif; ?>
195
                                    </td>
196
                                <?php endforeach; ?>
197
                            </tr>
198
                        <?php } ?>
199
                    </tbody>
200
                </table>
201
                <div id="pag-bottom" class="pagination">

templates/wpinv-invoice-history.php 1 location

@@ 32-88 (lines=57) @@
29
		</thead>
30
31
		<tbody>
32
			<?php foreach ( $user_invoices->invoices as $invoice ) {
33
				?>
34
				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
35
					<?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
36
						<td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
37
							<?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
38
								<?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
39
40
							<?php elseif ( 'invoice-number' === $column_id ) : ?>
41
								<a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
42
									<?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
43
								</a>
44
45
							<?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
46
								<time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
47
48
							<?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
49
								<time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
50
51
							<?php elseif ( 'invoice-status' === $column_id ) : ?>
52
								<?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
53
54
							<?php elseif ( 'invoice-total' === $column_id ) : ?>
55
								<?php echo $invoice->get_total( true ); ?>
56
57
							<?php elseif ( 'invoice-actions' === $column_id ) : ?>
58
								<?php
59
									$actions = array(
60
										'pay'    => array(
61
											'url'  => $invoice->get_checkout_payment_url(),
62
											'name' => __( 'Pay Now', 'invoicing' ),
63
                                            'class' => 'btn-success'
64
										),
65
                                        'print'   => array(
66
											'url'  => $invoice->get_view_url(),
67
											'name' => __( 'Print', 'invoicing' ),
68
                                            'class' => 'btn-primary',
69
                                            'attrs' => 'target="_blank"'
70
										)
71
									);
72
73
									if ( ! $invoice->needs_payment() ) {
74
										unset( $actions['pay'] );
75
									}
76
77
									if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
78
										foreach ( $actions as $key => $action ) {
79
											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
80
                                            echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
81
										}
82
									}
83
								?>
84
							<?php endif; ?>
85
						</td>
86
					<?php endforeach; ?>
87
				</tr>
88
			<?php } ?>
89
		</tbody>
90
	</table>
91