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

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