Code Duplication    Length = 57-57 lines in 2 locations

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

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

@@ 99-155 (lines=57) @@
96
                        </tr>
97
                    </thead>
98
                    <tbody>
99
                        <?php foreach ( $invoices_template->invoices as $invoice ) {
100
                            ?>
101
                            <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
102
                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
103
                                    <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'] ); ?>">
104
                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
105
                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
106
107
                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
108
                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
109
                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
110
                                            </a>
111
112
                                        <?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' ); ?>
113
                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
114
115
                                        <?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 ); ?>
116
                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
117
118
                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
119
                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
120
121
                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
122
                                            <?php echo $invoice->get_total( true ); ?>
123
124
                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
125
                                            <?php
126
                                                $actions = array(
127
                                                    'pay'    => array(
128
                                                        'url'  => $invoice->get_checkout_payment_url(),
129
                                                        'name' => __( 'Pay Now', 'invoicing' ),
130
                                                        'class' => 'btn-success'
131
                                                    ),
132
                                                    'print'   => array(
133
                                                        'url'  => $invoice->get_view_url(),
134
                                                        'name' => __( 'Print', 'invoicing' ),
135
                                                        'class' => 'btn-primary',
136
                                                        'attrs' => 'target="_blank"'
137
                                                    )
138
                                                );
139
140
                                                if ( ! $invoice->needs_payment() ) {
141
                                                    unset( $actions['pay'] );
142
                                                }
143
144
                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
145
                                                    foreach ( $actions as $key => $action ) {
146
                                                        $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
147
                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
148
                                                    }
149
                                                }
150
                                            ?>
151
                                        <?php endif; ?>
152
                                    </td>
153
                                <?php endforeach; ?>
154
                            </tr>
155
                        <?php } ?>
156
                    </tbody>
157
                </table>
158
                <div id="pag-bottom" class="pagination">