Passed
Push — master ( 862b0e...047a35 )
by Stiofan
17:04
created
templates/invoice-history.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -42,86 +42,86 @@  discard block
 block discarded – undo
42 42
 					<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
43 43
 						<?php
44 44
 
45
-							foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
45
+                            foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
46 46
 
47
-								$column_id = sanitize_html_class( $column_id );
48
-								$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47
+                                $column_id = sanitize_html_class( $column_id );
48
+                                $class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
49 49
 
50
-								echo "<td class='$column_id $class'>";
51
-								switch ( $column_id ) {
50
+                                echo "<td class='$column_id $class'>";
51
+                                switch ( $column_id ) {
52 52
 
53
-									case 'invoice-number':
54
-										echo wpinv_invoice_link( $invoice );
55
-										break;
53
+                                    case 'invoice-number':
54
+                                        echo wpinv_invoice_link( $invoice );
55
+                                        break;
56 56
 
57
-									case 'created-date':
58
-										echo getpaid_format_date_value( $invoice->get_date_created() );
59
-										break;
57
+                                    case 'created-date':
58
+                                        echo getpaid_format_date_value( $invoice->get_date_created() );
59
+                                        break;
60 60
 
61
-									case 'payment-date':
61
+                                    case 'payment-date':
62 62
 
63
-										if ( $invoice->needs_payment() ) {
64
-											echo "&mdash;";
65
-										} else {
66
-											echo getpaid_format_date_value( $invoice->get_date_completed() );
67
-										}
63
+                                        if ( $invoice->needs_payment() ) {
64
+                                            echo "&mdash;";
65
+                                        } else {
66
+                                            echo getpaid_format_date_value( $invoice->get_date_completed() );
67
+                                        }
68 68
 
69
-										break;
69
+                                        break;
70 70
 
71
-									case 'invoice-status':
72
-										echo $invoice->get_status_label_html();
71
+                                    case 'invoice-status':
72
+                                        echo $invoice->get_status_label_html();
73 73
 
74
-										break;
74
+                                        break;
75 75
 
76
-									case 'invoice-total':
77
-										echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
76
+                                    case 'invoice-total':
77
+                                        echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
78 78
 
79
-										break;
79
+                                        break;
80 80
 
81
-									case 'invoice-actions':
81
+                                    case 'invoice-actions':
82 82
 
83
-										$actions = array(
83
+                                        $actions = array(
84 84
 
85
-											'pay'       => array(
86
-												'url'   => $invoice->get_checkout_payment_url(),
87
-												'name'  => __( 'Pay Now', 'invoicing' ),
88
-												'class' => 'btn-success'
89
-											),
85
+                                            'pay'       => array(
86
+                                                'url'   => $invoice->get_checkout_payment_url(),
87
+                                                'name'  => __( 'Pay Now', 'invoicing' ),
88
+                                                'class' => 'btn-success'
89
+                                            ),
90 90
 
91
-											'print'     => array(
92
-												'url'   => $invoice->get_view_url(),
93
-												'name'  => __( 'View', 'invoicing' ),
94
-												'class' => 'btn-secondary',
95
-												'attrs' => 'target="_blank"'
96
-											)
97
-										);
91
+                                            'print'     => array(
92
+                                                'url'   => $invoice->get_view_url(),
93
+                                                'name'  => __( 'View', 'invoicing' ),
94
+                                                'class' => 'btn-secondary',
95
+                                                'attrs' => 'target="_blank"'
96
+                                            )
97
+                                        );
98 98
 
99
-										if ( ! $invoice->needs_payment() ) {
100
-											unset( $actions['pay'] );
101
-										}
99
+                                        if ( ! $invoice->needs_payment() ) {
100
+                                            unset( $actions['pay'] );
101
+                                        }
102 102
 
103
-										$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
103
+                                        $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
104 104
 
105
-										foreach ( $actions as $key => $action ) {
106
-											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
107
-											echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
108
-										}
105
+                                        foreach ( $actions as $key => $action ) {
106
+                                            $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
107
+                                            echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
108
+                                        }
109 109
 
110
-										break;
110
+                                        break;
111 111
 
112
-									default:
113
-										do_action( "wpinv_user_invoices_column_$column_id", $invoice );
114
-										break;
112
+                                    default:
113
+                                        do_action( "wpinv_user_invoices_column_$column_id", $invoice );
114
+                                        break;
115 115
 
116 116
 
117
-								}
117
+                                }
118 118
 
119
-								do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
119
+                                do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
120 120
 
121
-								echo '</td>';
121
+                                echo '</td>';
122 122
 
123
-							endforeach;
124
-						?>
123
+                            endforeach;
124
+                        ?>
125 125
 					</tr>
126 126
 
127 127
 				<?php endforeach; ?>
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	<?php if ( 1 < $invoices->max_num_pages ) : ?>
136 136
 		<div class="invoicing-Pagination">
137 137
 			<?php
138
-			$big = 999999;
139
-
140
-			echo paginate_links( array(
141
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
142
-				'format'  => '?paged=%#%',
143
-				'total'   => $invoices->max_num_pages,
144
-			) );
145
-			?>
138
+            $big = 999999;
139
+
140
+            echo paginate_links( array(
141
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
142
+                'format'  => '?paged=%#%',
143
+                'total'   => $invoices->max_num_pages,
144
+            ) );
145
+            ?>
146 146
 		</div>
147 147
 	<?php endif; ?>
148 148
 
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Current page.
13
-$current_page   = empty( $_GET[ 'page' ] ) ? 1 : absint( $_GET[ 'page' ] );
13
+$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']);
14 14
 
15 15
 // Fires before displaying user invoices.
16
-do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type );
16
+do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type);
17 17
 
18 18
 ?>
19 19
 
20 20
 
21 21
 	<div class="table-responsive">
22
-		<table class="table table-bordered table-hover getpaid-user-invoices <?php echo sanitize_html_class( $post_type ); ?>">
22
+		<table class="table table-bordered table-hover getpaid-user-invoices <?php echo sanitize_html_class($post_type); ?>">
23 23
 
24 24
 
25 25
 			<thead>
26 26
 				<tr>
27 27
 
28
-					<?php foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : ?>
29
-						<th class="<?php echo sanitize_html_class( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : '');?> border-bottom-0">
30
-							<span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span>
28
+					<?php foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : ?>
29
+						<th class="<?php echo sanitize_html_class($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0">
30
+							<span class="nobr"><?php echo esc_html($column_name['title']); ?></span>
31 31
 						</th>
32 32
 					<?php endforeach; ?>
33 33
 
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 			<tbody>
40
-				<?php foreach ( $invoices->invoices as $invoice ) : ?>
40
+				<?php foreach ($invoices->invoices as $invoice) : ?>
41 41
 
42 42
 					<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
43 43
 						<?php
44 44
 
45
-							foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
45
+							foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) :
46 46
 
47
-								$column_id = sanitize_html_class( $column_id );
48
-								$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47
+								$column_id = sanitize_html_class($column_id);
48
+								$class     = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']);
49 49
 
50 50
 								echo "<td class='$column_id $class'>";
51
-								switch ( $column_id ) {
51
+								switch ($column_id) {
52 52
 
53 53
 									case 'invoice-number':
54
-										echo wpinv_invoice_link( $invoice );
54
+										echo wpinv_invoice_link($invoice);
55 55
 										break;
56 56
 
57 57
 									case 'created-date':
58
-										echo getpaid_format_date_value( $invoice->get_date_created() );
58
+										echo getpaid_format_date_value($invoice->get_date_created());
59 59
 										break;
60 60
 
61 61
 									case 'payment-date':
62 62
 
63
-										if ( $invoice->needs_payment() ) {
63
+										if ($invoice->needs_payment()) {
64 64
 											echo "&mdash;";
65 65
 										} else {
66
-											echo getpaid_format_date_value( $invoice->get_date_completed() );
66
+											echo getpaid_format_date_value($invoice->get_date_completed());
67 67
 										}
68 68
 
69 69
 										break;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 										break;
75 75
 
76 76
 									case 'invoice-total':
77
-										echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
77
+										echo wpinv_price($invoice->get_total(), $invoice->get_currency());
78 78
 
79 79
 										break;
80 80
 
@@ -84,39 +84,39 @@  discard block
 block discarded – undo
84 84
 
85 85
 											'pay'       => array(
86 86
 												'url'   => $invoice->get_checkout_payment_url(),
87
-												'name'  => __( 'Pay Now', 'invoicing' ),
87
+												'name'  => __('Pay Now', 'invoicing'),
88 88
 												'class' => 'btn-success'
89 89
 											),
90 90
 
91 91
 											'print'     => array(
92 92
 												'url'   => $invoice->get_view_url(),
93
-												'name'  => __( 'View', 'invoicing' ),
93
+												'name'  => __('View', 'invoicing'),
94 94
 												'class' => 'btn-secondary',
95 95
 												'attrs' => 'target="_blank"'
96 96
 											)
97 97
 										);
98 98
 
99
-										if ( ! $invoice->needs_payment() ) {
100
-											unset( $actions['pay'] );
99
+										if (!$invoice->needs_payment()) {
100
+											unset($actions['pay']);
101 101
 										}
102 102
 
103
-										$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
103
+										$actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice, $post_type);
104 104
 
105
-										foreach ( $actions as $key => $action ) {
105
+										foreach ($actions as $key => $action) {
106 106
 											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
107
-											echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
107
+											echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
108 108
 										}
109 109
 
110 110
 										break;
111 111
 
112 112
 									default:
113
-										do_action( "wpinv_user_invoices_column_$column_id", $invoice );
113
+										do_action("wpinv_user_invoices_column_$column_id", $invoice);
114 114
 										break;
115 115
 
116 116
 
117 117
 								}
118 118
 
119
-								do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
119
+								do_action("wpinv_user_invoices_column_after_$column_id", $invoice);
120 120
 
121 121
 								echo '</td>';
122 122
 
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		</table>
131 131
 	</div>
132 132
 
133
-	<?php do_action( 'wpinv_before_user_invoices_pagination' ); ?>
133
+	<?php do_action('wpinv_before_user_invoices_pagination'); ?>
134 134
 
135
-	<?php if ( 1 < $invoices->max_num_pages ) : ?>
135
+	<?php if (1 < $invoices->max_num_pages) : ?>
136 136
 		<div class="invoicing-Pagination">
137 137
 			<?php
138 138
 			$big = 999999;
139 139
 
140
-			echo paginate_links( array(
141
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
140
+			echo paginate_links(array(
141
+				'base'    => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
142 142
 				'format'  => '?paged=%#%',
143 143
 				'total'   => $invoices->max_num_pages,
144
-			) );
144
+			));
145 145
 			?>
146 146
 		</div>
147 147
 	<?php endif; ?>
148 148
 
149
-<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type  ); ?>
149
+<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); ?>
Please login to merge, or discard this patch.
templates/emails/invoice-item.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,67 +10,67 @@  discard block
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 ?>
16 16
 
17
-<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?>
17
+<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?>
18 18
 
19
-<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>">
19
+<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>">
20 20
 
21
-    <?php foreach ( array_keys( $columns ) as $column ): ?>
21
+    <?php foreach (array_keys($columns) as $column): ?>
22 22
 
23
-        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>">
23
+        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>">
24 24
             
25 25
             <?php
26 26
 
27 27
                 // Fires before printing a line item column.
28
-                do_action( "getpaid_email_line_item_before_$column", $item, $invoice );
28
+                do_action("getpaid_email_line_item_before_$column", $item, $invoice);
29 29
 
30 30
                 // Item name.
31
-                if ( 'name' == $column ) {
31
+                if ('name' == $column) {
32 32
 
33 33
                     // Display the name.
34
-                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>';
34
+                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>';
35 35
 
36 36
                     // And an optional description.
37 37
                     $description = $item->get_description();
38 38
 
39
-                    if ( ! empty( $description ) ) {
40
-                        $description = wp_kses_post( $description );
39
+                    if (!empty($description)) {
40
+                        $description = wp_kses_post($description);
41 41
                         echo "<p class='small'>$description</p>";
42 42
                     }
43 43
 
44 44
                     // Price help text
45
-                    $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() );
46
-                    if ( $description ) {
45
+                    $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency());
46
+                    if ($description) {
47 47
                         echo "<p class='small'>$description</p>";
48 48
                     }
49 49
 
50 50
                 }
51 51
 
52 52
                 // Item price.
53
-                if ( 'price' == $column ) {
53
+                if ('price' == $column) {
54 54
 
55 55
                     // Display the item price (or recurring price if this is a renewal invoice)
56 56
                     $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
57
-                    echo wpinv_price( $price, $invoice->get_currency() );
57
+                    echo wpinv_price($price, $invoice->get_currency());
58 58
 
59 59
                 }
60 60
 
61 61
                 // Item quantity.
62
-                if ( 'quantity' == $column ) {
62
+                if ('quantity' == $column) {
63 63
                     echo (float) $item->get_quantity();
64 64
                 }
65 65
 
66 66
                 // Item sub total.
67
-                if ( 'subtotal' == $column ) {
67
+                if ('subtotal' == $column) {
68 68
                     $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
69
-                    echo wpinv_price( $subtotal, $invoice->get_currency() );
69
+                    echo wpinv_price($subtotal, $invoice->get_currency());
70 70
                 }
71 71
 
72 72
                 // Fires when printing a line item column.
73
-                do_action( "getpaid_email_line_item_$column", $item, $invoice );
73
+                do_action("getpaid_email_line_item_$column", $item, $invoice);
74 74
 
75 75
             ?>
76 76
 
@@ -80,4 +80,4 @@  discard block
 block discarded – undo
80 80
 
81 81
 </tr>
82 82
 
83
-<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?>
83
+<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?>
Please login to merge, or discard this patch.
templates/invoice/line-item.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15
-do_action( 'getpaid_before_invoice_line_item', $invoice, $item );
15
+do_action('getpaid_before_invoice_line_item', $invoice, $item);
16 16
 
17 17
 ?>
18 18
 
19
-<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'>
19
+<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'>
20 20
 
21 21
     <div class="form-row">
22 22
 
23
-        <?php foreach ( array_keys( $columns ) as $column ): ?>
23
+        <?php foreach (array_keys($columns) as $column): ?>
24 24
 
25
-            <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>">
25
+            <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>">
26 26
 
27 27
                 <?php
28 28
 
29 29
                     // Fires before printing a line item column.
30
-                    do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
30
+                    do_action("getpaid_invoice_line_item_before_$column", $item, $invoice);
31 31
 
32 32
                     // Item name.
33
-                    if ( 'name' == $column ) {
33
+                    if ('name' == $column) {
34 34
 
35 35
                         // Display the name.
36
-                        echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
36
+                        echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>';
37 37
 
38 38
                         // And an optional description.
39 39
                         $description = $item->get_description();
40 40
 
41
-                        if ( ! empty( $description ) ) {
42
-                            $description = wp_kses_post( $description );
41
+                        if (!empty($description)) {
42
+                            $description = wp_kses_post($description);
43 43
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
44 44
                         }
45 45
 
46 46
                         // Price help text.
47
-                        $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() );
48
-                        if ( $description ) {
47
+                        $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency());
48
+                        if ($description) {
49 49
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
50 50
                         }
51 51
 
52 52
                         // Fires before printing the line item actions.
53
-                        do_action( "getpaid_before_invoice_line_item_actions", $item, $invoice );
53
+                        do_action("getpaid_before_invoice_line_item_actions", $item, $invoice);
54 54
 
55
-                        $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
55
+                        $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice);
56 56
 
57
-                        if ( ! empty( $actions ) ) {
57
+                        if (!empty($actions)) {
58 58
 
59
-                            $sanitized  = array();
60
-                            foreach ( $actions as $key => $action ) {
61
-                                $key         = sanitize_html_class( $key );
62
-                                $action      = wp_kses_post( $action );
59
+                            $sanitized = array();
60
+                            foreach ($actions as $key => $action) {
61
+                                $key         = sanitize_html_class($key);
62
+                                $action      = wp_kses_post($action);
63 63
                                 $sanitized[] = "<span class='$key'>$action</span>";
64 64
                             }
65 65
 
66 66
                             echo "<small class='form-text getpaid-line-item-actions'>";
67
-                            echo implode( ' | ', $sanitized );
67
+                            echo implode(' | ', $sanitized);
68 68
                             echo '</small>';
69 69
 
70 70
                         }
@@ -72,30 +72,30 @@  discard block
 block discarded – undo
72 72
                     }
73 73
 
74 74
                     // Item price.
75
-                    if ( 'price' == $column ) {
75
+                    if ('price' == $column) {
76 76
 
77 77
                         // Display the item price (or recurring price if this is a renewal invoice)
78 78
                         $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
79
-                        echo wpinv_price( $price, $invoice->get_currency() );
79
+                        echo wpinv_price($price, $invoice->get_currency());
80 80
 
81 81
                     }
82 82
 
83 83
                     // Item quantity.
84
-                    if ( 'quantity' == $column ) {
84
+                    if ('quantity' == $column) {
85 85
                         echo (float) $item->get_quantity();
86 86
                     }
87 87
 
88 88
                     // Item sub total.
89
-                    if ( 'subtotal' == $column ) {
89
+                    if ('subtotal' == $column) {
90 90
                         $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
91
-                        echo wpinv_price( $subtotal, $invoice->get_currency() );
91
+                        echo wpinv_price($subtotal, $invoice->get_currency());
92 92
                     }
93 93
 
94 94
                     // Fires when printing a line item column.
95
-                    do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
95
+                    do_action("getpaid_invoice_line_item_$column", $item, $invoice);
96 96
 
97 97
                     // Fires after printing a line item column.
98
-                    do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
98
+                    do_action("getpaid_invoice_line_item_after_$column", $item, $invoice);
99 99
 
100 100
                 ?>
101 101
 
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -24,48 +24,48 @@  discard block
 block discarded – undo
24 24
 
25 25
 				<?php
26 26
 
27
-					// Fires before printing a line item column.
28
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
27
+                    // Fires before printing a line item column.
28
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
29 29
 
30
-					// Item name.
31
-					if ( 'name' == $key ) {
30
+                    // Item name.
31
+                    if ( 'name' == $key ) {
32 32
 
33
-						// Display the name.
34
-						echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
33
+                        // Display the name.
34
+                        echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
35 35
 
36
-						// And an optional description.
36
+                        // And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39 39
                         if ( ! empty( $description ) ) {
40 40
                             $description = wp_kses_post( $description );
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42
-						}
42
+                        }
43 43
 
44
-						// Price help text.
44
+                        // Price help text.
45 45
                         $description = getpaid_item_recurring_price_help_text( $item, $currency );
46 46
                         if ( $description ) {
47 47
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
48
-						}
48
+                        }
49 49
 
50
-					}
50
+                    }
51 51
 
52
-					// Item price.
53
-					if ( 'price' == $key ) {
52
+                    // Item price.
53
+                    if ( 'price' == $key ) {
54 54
 
55
-						// Set the currency position.
56
-						$position = wpinv_currency_position();
55
+                        // Set the currency position.
56
+                        $position = wpinv_currency_position();
57 57
 
58
-						if ( $position == 'left_space' ) {
59
-							$position = 'left';
60
-						}
58
+                        if ( $position == 'left_space' ) {
59
+                            $position = 'left';
60
+                        }
61 61
 
62
-						if ( $position == 'right_space' ) {
63
-							$position = 'right';
64
-						}
62
+                        if ( $position == 'right_space' ) {
63
+                            $position = 'right';
64
+                        }
65 65
 
66
-						if ( $item->user_can_set_their_price() ) {
67
-							$price = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
68
-							?>
66
+                        if ( $item->user_can_set_their_price() ) {
67
+                            $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
68
+                            ?>
69 69
 								<div class="input-group input-group-sm">
70 70
 									<?php if( 'left' == $position ) : ?>
71 71
 										<div class="input-group-prepend">
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 									<?php endif; ?>
82 82
 								</div>
83 83
 							<?php
84
-						} else {
85
-							echo wpinv_price( $item->get_price(), $currency );
86
-							?>
84
+                        } else {
85
+                            echo wpinv_price( $item->get_price(), $currency );
86
+                            ?>
87 87
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
88 88
 							<?php
89
-						}
90
-					}
89
+                        }
90
+                    }
91 91
 
92
-					// Item quantity.
93
-					if ( 'quantity' == $key ) {
92
+                    // Item quantity.
93
+                    if ( 'quantity' == $key ) {
94 94
 
95
-						if ( $item->allows_quantities() ) {
96
-							?>
95
+                        if ( $item->allows_quantities() ) {
96
+                            ?>
97 97
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required>
98 98
 							<?php
99
-						} else {
100
-							echo (float) $item->get_quantity();
101
-							echo '&nbsp;&nbsp;&nbsp;';
102
-							?>
99
+                        } else {
100
+                            echo (float) $item->get_quantity();
101
+                            echo '&nbsp;&nbsp;&nbsp;';
102
+                            ?>
103 103
 								<input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'>
104 104
 							<?php
105
-						}
106
-					}
105
+                        }
106
+                    }
107 107
 
108
-					// Item sub total.
109
-					if ( 'subtotal' == $key ) {
110
-						echo wpinv_price( $item->get_sub_total(), $currency );
111
-					}
108
+                    // Item sub total.
109
+                    if ( 'subtotal' == $key ) {
110
+                        echo wpinv_price( $item->get_sub_total(), $currency );
111
+                    }
112 112
 
113
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
114
-				?>
113
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
114
+                ?>
115 115
 
116 116
 			</div>
117 117
 
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,92 +7,92 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
12
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
13 13
 
14 14
 $currency = $form->get_currency();
15 15
 
16 16
 ?>
17
-<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required'  : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
17
+<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
18 18
 
19 19
 	<div class="form-row">
20 20
 
21
-		<?php foreach ( array_keys( $columns ) as $key ) : ?>
21
+		<?php foreach (array_keys($columns) as $key) : ?>
22 22
 
23
-			<div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>">
23
+			<div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>">
24 24
 
25 25
 				<?php
26 26
 
27 27
 					// Fires before printing a line item column.
28
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
28
+					do_action("getpaid_form_cart_item_before_$key", $item, $form);
29 29
 
30 30
 					// Item name.
31
-					if ( 'name' == $key ) {
31
+					if ('name' == $key) {
32 32
 
33 33
 						// Display the name.
34
-						echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
34
+						echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>';
35 35
 
36 36
 						// And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39
-                        if ( ! empty( $description ) ) {
40
-                            $description = wp_kses_post( $description );
39
+                        if (!empty($description)) {
40
+                            $description = wp_kses_post($description);
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42 42
 						}
43 43
 
44 44
 						// Price help text.
45
-                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
46
-                        if ( $description ) {
45
+                        $description = getpaid_item_recurring_price_help_text($item, $currency);
46
+                        if ($description) {
47 47
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
48 48
 						}
49 49
 
50 50
 					}
51 51
 
52 52
 					// Item price.
53
-					if ( 'price' == $key ) {
53
+					if ('price' == $key) {
54 54
 
55 55
 						// Set the currency position.
56 56
 						$position = wpinv_currency_position();
57 57
 
58
-						if ( $position == 'left_space' ) {
58
+						if ($position == 'left_space') {
59 59
 							$position = 'left';
60 60
 						}
61 61
 
62
-						if ( $position == 'right_space' ) {
62
+						if ($position == 'right_space') {
63 63
 							$position = 'right';
64 64
 						}
65 65
 
66
-						if ( $item->user_can_set_their_price() ) {
67
-							$price = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
66
+						if ($item->user_can_set_their_price()) {
67
+							$price = max((float) $item->get_price(), (float) $item->get_minimum_price());
68 68
 							?>
69 69
 								<div class="input-group input-group-sm">
70
-									<?php if( 'left' == $position ) : ?>
70
+									<?php if ('left' == $position) : ?>
71 71
 										<div class="input-group-prepend">
72
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
72
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
73 73
 										</div>
74 74
 									<?php endif; ?>
75
-									<input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border border">
75
+									<input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border border">
76 76
 
77
-									<?php if( 'left' != $position ) : ?>
77
+									<?php if ('left' != $position) : ?>
78 78
 										<div class="input-group-append">
79
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
79
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
80 80
 										</div>
81 81
 									<?php endif; ?>
82 82
 								</div>
83 83
 							<?php
84 84
 						} else {
85
-							echo wpinv_price( $item->get_price(), $currency );
85
+							echo wpinv_price($item->get_price(), $currency);
86 86
 							?>
87
-								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
87
+								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'>
88 88
 							<?php
89 89
 						}
90 90
 					}
91 91
 
92 92
 					// Item quantity.
93
-					if ( 'quantity' == $key ) {
93
+					if ('quantity' == $key) {
94 94
 
95
-						if ( $item->allows_quantities() ) {
95
+						if ($item->allows_quantities()) {
96 96
 							?>
97 97
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required>
98 98
 							<?php
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 					}
107 107
 
108 108
 					// Item sub total.
109
-					if ( 'subtotal' == $key ) {
110
-						echo wpinv_price( $item->get_sub_total(), $currency );
109
+					if ('subtotal' == $key) {
110
+						echo wpinv_price($item->get_sub_total(), $currency);
111 111
 					}
112 112
 
113
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
113
+					do_action("getpaid_payment_form_cart_item_$key", $item, $form);
114 114
 				?>
115 115
 
116 116
 			</div>
@@ -121,4 +121,4 @@  discard block
 block discarded – undo
121 121
 
122 122
 </div>
123 123
 <?php
124
-do_action(  'getpaid_payment_form_cart_item', $form, $item );
124
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -13,94 +13,94 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
49
-
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49
+
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
     
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title                = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85 85
         $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86 86
         $this->notify_url           = wpinv_get_ipn_url( $this->id );
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
88
+        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89 89
         add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90 90
 
91 91
         parent::__construct();
92 92
     }
93 93
 
94 94
     /**
95
-	 * Process Payment.
96
-	 *
97
-	 *
98
-	 * @param WPInv_Invoice $invoice Invoice.
99
-	 * @param array $submission_data Posted checkout fields.
100
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
-	 * @return array
102
-	 */
103
-	public function process_payment( $invoice, $submission_data, $submission ) {
95
+     * Process Payment.
96
+     *
97
+     *
98
+     * @param WPInv_Invoice $invoice Invoice.
99
+     * @param array $submission_data Posted checkout fields.
100
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
+     * @return array
102
+     */
103
+    public function process_payment( $invoice, $submission_data, $submission ) {
104 104
 
105 105
         // Get redirect url.
106 106
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     /**
126
-	 * Get the PayPal request URL for an invoice.
127
-	 *
128
-	 * @param  WPInv_Invoice $invoice Invoice object.
129
-	 * @return string
130
-	 */
131
-	public function get_request_url( $invoice ) {
126
+     * Get the PayPal request URL for an invoice.
127
+     *
128
+     * @param  WPInv_Invoice $invoice Invoice object.
129
+     * @return string
130
+     */
131
+    public function get_request_url( $invoice ) {
132 132
 
133 133
         // Endpoint for this request
134
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
134
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
135 135
 
136 136
         // Retrieve paypal args.
137 137
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -144,44 +144,44 @@  discard block
 block discarded – undo
144 144
 
145 145
         return add_query_arg( $paypal_args, $this->endpoint );
146 146
 
147
-	}
147
+    }
148 148
 
149 149
     /**
150
-	 * Get PayPal Args for passing to PP.
151
-	 *
152
-	 * @param  WPInv_Invoice $invoice Invoice object.
153
-	 * @return array
154
-	 */
155
-	protected function get_paypal_args( $invoice ) {
150
+     * Get PayPal Args for passing to PP.
151
+     *
152
+     * @param  WPInv_Invoice $invoice Invoice object.
153
+     * @return array
154
+     */
155
+    protected function get_paypal_args( $invoice ) {
156 156
 
157 157
         // Whether or not to send the line items as one item.
158
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
-
160
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
-			$force_one_line_item = true;
162
-		}
163
-
164
-		$paypal_args = apply_filters(
165
-			'getpaid_paypal_args',
166
-			array_merge(
167
-				$this->get_transaction_args( $invoice ),
168
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
-			),
170
-			$invoice
171
-		);
172
-
173
-		return $this->fix_request_length( $invoice, $paypal_args );
158
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
+
160
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
+            $force_one_line_item = true;
162
+        }
163
+
164
+        $paypal_args = apply_filters(
165
+            'getpaid_paypal_args',
166
+            array_merge(
167
+                $this->get_transaction_args( $invoice ),
168
+                $this->get_line_item_args( $invoice, $force_one_line_item )
169
+            ),
170
+            $invoice
171
+        );
172
+
173
+        return $this->fix_request_length( $invoice, $paypal_args );
174 174
     }
175 175
 
176 176
     /**
177
-	 * Get transaction args for paypal request.
178
-	 *
179
-	 * @param WPInv_Invoice $invoice Invoice object.
180
-	 * @return array
181
-	 */
182
-	protected function get_transaction_args( $invoice ) {
183
-
184
-		return array(
177
+     * Get transaction args for paypal request.
178
+     *
179
+     * @param WPInv_Invoice $invoice Invoice object.
180
+     * @return array
181
+     */
182
+    protected function get_transaction_args( $invoice ) {
183
+
184
+        return array(
185 185
             'cmd'           => '_cart',
186 186
             'business'      => wpinv_get_option( 'paypal_email', false ),
187 187
             'no_shipping'   => '1',
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
     }
207 207
 
208 208
     /**
209
-	 * Get line item args for paypal request.
210
-	 *
211
-	 * @param  WPInv_Invoice $invoice Invoice object.
212
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
213
-	 * @return array
214
-	 */
215
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
209
+     * Get line item args for paypal request.
210
+     *
211
+     * @param  WPInv_Invoice $invoice Invoice object.
212
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
213
+     * @return array
214
+     */
215
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
216 216
 
217 217
         // Maybe send invoice as a single item.
218
-		if ( $force_one_line_item ) {
218
+        if ( $force_one_line_item ) {
219 219
             return $this->get_line_item_args_single_item( $invoice );
220 220
         }
221 221
 
@@ -235,129 +235,129 @@  discard block
 block discarded – undo
235 235
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
236 236
         }
237 237
 
238
-		return array_merge( $line_item_args, $this->get_line_items() );
238
+        return array_merge( $line_item_args, $this->get_line_items() );
239 239
 
240 240
     }
241 241
 
242 242
     /**
243
-	 * Get line item args for paypal request as a single line item.
244
-	 *
245
-	 * @param  WPInv_Invoice $invoice Invoice object.
246
-	 * @return array
247
-	 */
248
-	protected function get_line_item_args_single_item( $invoice ) {
249
-		$this->delete_line_items();
243
+     * Get line item args for paypal request as a single line item.
244
+     *
245
+     * @param  WPInv_Invoice $invoice Invoice object.
246
+     * @return array
247
+     */
248
+    protected function get_line_item_args_single_item( $invoice ) {
249
+        $this->delete_line_items();
250 250
 
251 251
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
252
-		$this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
252
+        $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
253 253
 
254
-		return $this->get_line_items();
254
+        return $this->get_line_items();
255 255
     }
256 256
 
257 257
     /**
258
-	 * Return all line items.
259
-	 */
260
-	protected function get_line_items() {
261
-		return $this->line_items;
262
-	}
258
+     * Return all line items.
259
+     */
260
+    protected function get_line_items() {
261
+        return $this->line_items;
262
+    }
263 263
 
264 264
     /**
265
-	 * Remove all line items.
266
-	 */
267
-	protected function delete_line_items() {
268
-		$this->line_items = array();
265
+     * Remove all line items.
266
+     */
267
+    protected function delete_line_items() {
268
+        $this->line_items = array();
269 269
     }
270 270
 
271 271
     /**
272
-	 * Prepare line items to send to paypal.
273
-	 *
274
-	 * @param  WPInv_Invoice $invoice Invoice object.
275
-	 */
276
-	protected function prepare_line_items( $invoice ) {
277
-		$this->delete_line_items();
278
-
279
-		// Items.
280
-		foreach ( $invoice->get_items() as $item ) {
281
-			$amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
272
+     * Prepare line items to send to paypal.
273
+     *
274
+     * @param  WPInv_Invoice $invoice Invoice object.
275
+     */
276
+    protected function prepare_line_items( $invoice ) {
277
+        $this->delete_line_items();
278
+
279
+        // Items.
280
+        foreach ( $invoice->get_items() as $item ) {
281
+            $amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
284 284
         }
285 285
 
286 286
         // Fees.
287
-		foreach ( $invoice->get_fees() as $fee => $data ) {
287
+        foreach ( $invoice->get_fees() as $fee => $data ) {
288 288
             $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
289 289
         }
290 290
 
291 291
     }
292 292
 
293 293
     /**
294
-	 * Add PayPal Line Item.
295
-	 *
296
-	 * @param  string $item_name Item name.
297
-	 * @param  int    $quantity Item quantity.
298
-	 * @param  float  $amount Amount.
299
-	 * @param  string $item_number Item number.
300
-	 */
301
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
-		$index = ( count( $this->line_items ) / 4 ) + 1;
303
-
304
-		$item = apply_filters(
305
-			'getpaid_paypal_line_item',
306
-			array(
307
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
-				'quantity'    => (float) $quantity,
309
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
-				'item_number' => $item_number,
311
-			),
312
-			$item_name,
313
-			$quantity,
314
-			$amount,
315
-			$item_number
316
-		);
317
-
318
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
294
+     * Add PayPal Line Item.
295
+     *
296
+     * @param  string $item_name Item name.
297
+     * @param  int    $quantity Item quantity.
298
+     * @param  float  $amount Amount.
299
+     * @param  string $item_number Item number.
300
+     */
301
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
+        $index = ( count( $this->line_items ) / 4 ) + 1;
303
+
304
+        $item = apply_filters(
305
+            'getpaid_paypal_line_item',
306
+            array(
307
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
+                'quantity'    => (float) $quantity,
309
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
+                'item_number' => $item_number,
311
+            ),
312
+            $item_name,
313
+            $quantity,
314
+            $amount,
315
+            $item_number
316
+        );
317
+
318
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
319 319
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
320 320
         
321 321
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
322
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
322
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324 324
     }
325 325
 
326 326
     /**
327
-	 * If the default request with line items is too long, generate a new one with only one line item.
328
-	 *
329
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
-	 *
331
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
333
-	 * @return array
334
-	 */
335
-	protected function fix_request_length( $invoice, $paypal_args ) {
336
-		$max_paypal_length = 2083;
337
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
338
-
339
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
-			return $paypal_args;
341
-		}
342
-
343
-		return apply_filters(
344
-			'getpaid_paypal_args',
345
-			array_merge(
346
-				$this->get_transaction_args( $invoice ),
347
-				$this->get_line_item_args( $invoice, true )
348
-			),
349
-			$invoice
350
-		);
327
+     * If the default request with line items is too long, generate a new one with only one line item.
328
+     *
329
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
+     *
331
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
333
+     * @return array
334
+     */
335
+    protected function fix_request_length( $invoice, $paypal_args ) {
336
+        $max_paypal_length = 2083;
337
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
338
+
339
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
+            return $paypal_args;
341
+        }
342
+
343
+        return apply_filters(
344
+            'getpaid_paypal_args',
345
+            array_merge(
346
+                $this->get_transaction_args( $invoice ),
347
+                $this->get_line_item_args( $invoice, true )
348
+            ),
349
+            $invoice
350
+        );
351 351
 
352 352
     }
353 353
     
354 354
     /**
355
-	 * Processes recurring invoices.
356
-	 *
357
-	 * @param  array $paypal_args PayPal args.
358
-	 * @param  WPInv_Invoice    $invoice Invoice object.
359
-	 */
360
-	public function process_subscription( $paypal_args, $invoice ) {
355
+     * Processes recurring invoices.
356
+     *
357
+     * @param  array $paypal_args PayPal args.
358
+     * @param  WPInv_Invoice    $invoice Invoice object.
359
+     */
360
+    public function process_subscription( $paypal_args, $invoice ) {
361 361
 
362 362
         // Make sure this is a subscription.
363 363
         if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) {
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 
383 383
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
384 384
 
385
-			// Trial period length.
386
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
385
+            // Trial period length.
386
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
387 387
 
388
-			// Trial period.
389
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
388
+            // Trial period.
389
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
390 390
 
391 391
         } else if ( $initial_amount != $recurring_amount ) {
392 392
 
@@ -409,40 +409,40 @@  discard block
 block discarded – undo
409 409
         }
410 410
 
411 411
         // We have a recurring payment
412
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
412
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
413 413
 
414
-			// Subscription price
415
-			$paypal_args['a3'] = $recurring_amount;
414
+            // Subscription price
415
+            $paypal_args['a3'] = $recurring_amount;
416 416
 
417
-			// Subscription duration
418
-			$paypal_args['p3'] = $interval;
417
+            // Subscription duration
418
+            $paypal_args['p3'] = $interval;
419 419
 
420
-			// Subscription period
421
-			$paypal_args['t3'] = $period;
420
+            // Subscription period
421
+            $paypal_args['t3'] = $period;
422 422
 
423 423
         }
424 424
         
425 425
         // Recurring payments
426
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
426
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
427 427
 
428
-			// Non-recurring payments
429
-			$paypal_args['src'] = 0;
428
+            // Non-recurring payments
429
+            $paypal_args['src'] = 0;
430 430
 
431
-		} else {
431
+        } else {
432 432
 
433
-			$paypal_args['src'] = 1;
433
+            $paypal_args['src'] = 1;
434 434
 
435
-			if ( $bill_times > 0 ) {
435
+            if ( $bill_times > 0 ) {
436 436
 
437
-				// An initial period is being used to charge a sign-up fee
438
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
-					$bill_times--;
440
-				}
437
+                // An initial period is being used to charge a sign-up fee
438
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
+                    $bill_times--;
440
+                }
441 441
 
442 442
                 // Make sure it's not over the max of 52
443 443
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
444 444
 
445
-			}
445
+            }
446 446
         }
447 447
         
448 448
         // Force return URL so that order description & instructions display
@@ -458,19 +458,19 @@  discard block
 block discarded – undo
458 458
         }
459 459
 
460 460
         return apply_filters(
461
-			'getpaid_paypal_subscription_args',
462
-			$paypal_args,
463
-			$invoice
461
+            'getpaid_paypal_subscription_args',
462
+            $paypal_args,
463
+            $invoice
464 464
         );
465 465
 
466 466
     }
467 467
 
468 468
     /**
469
-	 * Processes ipns and marks payments as complete.
470
-	 *
471
-	 * @return void
472
-	 */
473
-	public function verify_ipn() {
469
+     * Processes ipns and marks payments as complete.
470
+     *
471
+     * @return void
472
+     */
473
+    public function verify_ipn() {
474 474
         new GetPaid_Paypal_Gateway_IPN_Handler( $this );
475 475
     }
476 476
 
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
     public function sandbox_notice() {
481 481
 
482 482
         return sprintf(
483
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
484
-			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
485
-			'</a>'
486
-		);
483
+            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
484
+            '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
485
+            '</a>'
486
+        );
487 487
 
488 488
     }
489 489
 
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox' );
27
+    protected $supports = array('subscription', 'sandbox');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __construct() {
82 82
 
83
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
84
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
83
+        $this->title                = __('PayPal Standard', 'invoicing');
84
+        $this->method_title         = __('PayPal Standard', 'invoicing');
85
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
86
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89
-        add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
88
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
89
+        add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
90 90
 
91 91
         parent::__construct();
92 92
     }
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101 101
 	 * @return array
102 102
 	 */
103
-	public function process_payment( $invoice, $submission_data, $submission ) {
103
+	public function process_payment($invoice, $submission_data, $submission) {
104 104
 
105 105
         // Get redirect url.
106
-        $paypal_redirect = $this->get_request_url( $invoice );
106
+        $paypal_redirect = $this->get_request_url($invoice);
107 107
 
108 108
         // Add a note about the request url.
109 109
         $invoice->add_note(
110 110
             sprintf(
111
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
112
-                esc_url( $paypal_redirect )
111
+                __('Redirecting to PayPal: %s', 'invoicing'),
112
+                esc_url($paypal_redirect)
113 113
             ),
114 114
             false,
115 115
             false,
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         );
118 118
 
119 119
         // Redirect to PayPal
120
-        wp_redirect( $paypal_redirect );
120
+        wp_redirect($paypal_redirect);
121 121
         exit;
122 122
 
123 123
     }
@@ -128,21 +128,21 @@  discard block
 block discarded – undo
128 128
 	 * @param  WPInv_Invoice $invoice Invoice object.
129 129
 	 * @return string
130 130
 	 */
131
-	public function get_request_url( $invoice ) {
131
+	public function get_request_url($invoice) {
132 132
 
133 133
         // Endpoint for this request
134
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
134
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
135 135
 
136 136
         // Retrieve paypal args.
137
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
137
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
138 138
 
139
-        if ( $invoice->is_recurring() ) {
139
+        if ($invoice->is_recurring()) {
140 140
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
141 141
         } else {
142 142
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
143 143
         }
144 144
 
145
-        return add_query_arg( $paypal_args, $this->endpoint );
145
+        return add_query_arg($paypal_args, $this->endpoint);
146 146
 
147 147
 	}
148 148
 
@@ -152,25 +152,25 @@  discard block
 block discarded – undo
152 152
 	 * @param  WPInv_Invoice $invoice Invoice object.
153 153
 	 * @return array
154 154
 	 */
155
-	protected function get_paypal_args( $invoice ) {
155
+	protected function get_paypal_args($invoice) {
156 156
 
157 157
         // Whether or not to send the line items as one item.
158
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
158
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', false, $invoice);
159 159
 
160
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
160
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
161 161
 			$force_one_line_item = true;
162 162
 		}
163 163
 
164 164
 		$paypal_args = apply_filters(
165 165
 			'getpaid_paypal_args',
166 166
 			array_merge(
167
-				$this->get_transaction_args( $invoice ),
168
-				$this->get_line_item_args( $invoice, $force_one_line_item )
167
+				$this->get_transaction_args($invoice),
168
+				$this->get_line_item_args($invoice, $force_one_line_item)
169 169
 			),
170 170
 			$invoice
171 171
 		);
172 172
 
173
-		return $this->fix_request_length( $invoice, $paypal_args );
173
+		return $this->fix_request_length($invoice, $paypal_args);
174 174
     }
175 175
 
176 176
     /**
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 	 * @param WPInv_Invoice $invoice Invoice object.
180 180
 	 * @return array
181 181
 	 */
182
-	protected function get_transaction_args( $invoice ) {
182
+	protected function get_transaction_args($invoice) {
183 183
 
184 184
 		return array(
185 185
             'cmd'           => '_cart',
186
-            'business'      => wpinv_get_option( 'paypal_email', false ),
186
+            'business'      => wpinv_get_option('paypal_email', false),
187 187
             'no_shipping'   => '1',
188 188
             'shipping'      => '0',
189 189
             'no_note'       => '1',
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
             'rm'            => is_ssl() ? 2 : 1,
192 192
             'upload'        => 1,
193 193
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
194
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
195
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
196
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
197
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
194
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
195
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
196
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
197
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
198 198
             'custom'        => $invoice->get_id(),
199
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
200
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
201
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
202
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
203
-            'cbt'           => get_bloginfo( 'name' )
199
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
200
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
201
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
202
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
203
+            'cbt'           => get_bloginfo('name')
204 204
         );
205 205
 
206 206
     }
@@ -212,30 +212,30 @@  discard block
 block discarded – undo
212 212
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
213 213
 	 * @return array
214 214
 	 */
215
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
215
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
216 216
 
217 217
         // Maybe send invoice as a single item.
218
-		if ( $force_one_line_item ) {
219
-            return $this->get_line_item_args_single_item( $invoice );
218
+		if ($force_one_line_item) {
219
+            return $this->get_line_item_args_single_item($invoice);
220 220
         }
221 221
 
222 222
         // Send each line item individually.
223 223
         $line_item_args = array();
224 224
 
225 225
         // Prepare line items.
226
-        $this->prepare_line_items( $invoice );
226
+        $this->prepare_line_items($invoice);
227 227
 
228 228
         // Add taxes to the cart
229
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
230
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
229
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
230
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
231 231
         }
232 232
 
233 233
         // Add discount.
234
-        if ( $invoice->get_total_discount() > 0 ) {
235
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
234
+        if ($invoice->get_total_discount() > 0) {
235
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
236 236
         }
237 237
 
238
-		return array_merge( $line_item_args, $this->get_line_items() );
238
+		return array_merge($line_item_args, $this->get_line_items());
239 239
 
240 240
     }
241 241
 
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 * @param  WPInv_Invoice $invoice Invoice object.
246 246
 	 * @return array
247 247
 	 */
248
-	protected function get_line_item_args_single_item( $invoice ) {
248
+	protected function get_line_item_args_single_item($invoice) {
249 249
 		$this->delete_line_items();
250 250
 
251
-        $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
252
-		$this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
251
+        $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
252
+		$this->add_line_item($item_name, 1, wpinv_sanitize_amount((float) $invoice->get_total(), 2), $invoice->get_id());
253 253
 
254 254
 		return $this->get_line_items();
255 255
     }
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @param  WPInv_Invoice $invoice Invoice object.
275 275
 	 */
276
-	protected function prepare_line_items( $invoice ) {
276
+	protected function prepare_line_items($invoice) {
277 277
 		$this->delete_line_items();
278 278
 
279 279
 		// Items.
280
-		foreach ( $invoice->get_items() as $item ) {
280
+		foreach ($invoice->get_items() as $item) {
281 281
 			$amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282 282
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
283
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
284 284
         }
285 285
 
286 286
         // Fees.
287
-		foreach ( $invoice->get_fees() as $fee => $data ) {
288
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
287
+		foreach ($invoice->get_fees() as $fee => $data) {
288
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
289 289
         }
290 290
 
291 291
     }
@@ -298,15 +298,15 @@  discard block
 block discarded – undo
298 298
 	 * @param  float  $amount Amount.
299 299
 	 * @param  string $item_number Item number.
300 300
 	 */
301
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
-		$index = ( count( $this->line_items ) / 4 ) + 1;
301
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
302
+		$index = (count($this->line_items) / 4) + 1;
303 303
 
304 304
 		$item = apply_filters(
305 305
 			'getpaid_paypal_line_item',
306 306
 			array(
307
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
307
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
308 308
 				'quantity'    => (float) $quantity,
309
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
309
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
310 310
 				'item_number' => $item_number,
311 311
 			),
312 312
 			$item_name,
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 			$item_number
316 316
 		);
317 317
 
318
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
319
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
318
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
319
+        $this->line_items['quantity_' . $index] = $item['quantity'];
320 320
         
321 321
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
322
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
322
+		$this->line_items['amount_' . $index]      = $item['amount'];
323
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
324 324
     }
325 325
 
326 326
     /**
@@ -332,19 +332,19 @@  discard block
 block discarded – undo
332 332
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
333 333
 	 * @return array
334 334
 	 */
335
-	protected function fix_request_length( $invoice, $paypal_args ) {
335
+	protected function fix_request_length($invoice, $paypal_args) {
336 336
 		$max_paypal_length = 2083;
337
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
337
+		$query_candidate   = http_build_query($paypal_args, '', '&');
338 338
 
339
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
339
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
340 340
 			return $paypal_args;
341 341
 		}
342 342
 
343 343
 		return apply_filters(
344 344
 			'getpaid_paypal_args',
345 345
 			array_merge(
346
-				$this->get_transaction_args( $invoice ),
347
-				$this->get_line_item_args( $invoice, true )
346
+				$this->get_transaction_args($invoice),
347
+				$this->get_line_item_args($invoice, true)
348 348
 			),
349 349
 			$invoice
350 350
 		);
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 	 * @param  array $paypal_args PayPal args.
358 358
 	 * @param  WPInv_Invoice    $invoice Invoice object.
359 359
 	 */
360
-	public function process_subscription( $paypal_args, $invoice ) {
360
+	public function process_subscription($paypal_args, $invoice) {
361 361
 
362 362
         // Make sure this is a subscription.
363
-        if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) {
363
+        if (!$invoice->is_recurring() || !$subscription = wpinv_get_subscription($invoice)) {
364 364
             return $paypal_args;
365 365
         }
366 366
 
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
         $paypal_args['cmd'] = '_xclick-subscriptions';
369 369
 
370 370
         // Subscription name.
371
-        $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
371
+        $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
372 372
 
373 373
         // Get subscription args.
374
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1) );
374
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
375 375
         $interval               = (int) $subscription->get_frequency();
376 376
         $bill_times             = (int) $subscription->get_bill_times();
377
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
378
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
379
-        $subscription_item      = $invoice->get_recurring( true );
377
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
378
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
379
+        $subscription_item      = $invoice->get_recurring(true);
380 380
 
381
-        if ( $subscription_item->has_free_trial() ) {
381
+        if ($subscription_item->has_free_trial()) {
382 382
 
383 383
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
384 384
 
@@ -388,28 +388,28 @@  discard block
 block discarded – undo
388 388
 			// Trial period.
389 389
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
390 390
 
391
-        } else if ( $initial_amount != $recurring_amount ) {
391
+        } else if ($initial_amount != $recurring_amount) {
392 392
 
393 393
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
394 394
 
395
-            if ( 1 == $bill_times ) {
395
+            if (1 == $bill_times) {
396 396
                 $param_number = 3;
397 397
             } else {
398 398
                 $param_number = 1;
399 399
             }
400 400
 
401
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
401
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
402 402
 
403 403
             // Sign Up interval
404
-            $paypal_args[ 'p' . $param_number ] = $interval;
404
+            $paypal_args['p' . $param_number] = $interval;
405 405
 
406 406
             // Sign Up unit of duration
407
-            $paypal_args[ 't' . $param_number ] = $period;
407
+            $paypal_args['t' . $param_number] = $period;
408 408
 
409 409
         }
410 410
 
411 411
         // We have a recurring payment
412
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
412
+		if (!isset($param_number) || 1 == $param_number) {
413 413
 
414 414
 			// Subscription price
415 415
 			$paypal_args['a3'] = $recurring_amount;
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         }
424 424
         
425 425
         // Recurring payments
426
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
426
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
427 427
 
428 428
 			// Non-recurring payments
429 429
 			$paypal_args['src'] = 0;
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
 
433 433
 			$paypal_args['src'] = 1;
434 434
 
435
-			if ( $bill_times > 0 ) {
435
+			if ($bill_times > 0) {
436 436
 
437 437
 				// An initial period is being used to charge a sign-up fee
438
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
438
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
439 439
 					$bill_times--;
440 440
 				}
441 441
 
442 442
                 // Make sure it's not over the max of 52
443
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
443
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
444 444
 
445 445
 			}
446 446
         }
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
         $paypal_args['rm'] = 2;
450 450
         
451 451
         // Get rid of redudant items.
452
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
452
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
453 453
 
454
-            if ( isset( $paypal_args[ $arg ] ) ) {
455
-                unset( $paypal_args[ $arg ] );
454
+            if (isset($paypal_args[$arg])) {
455
+                unset($paypal_args[$arg]);
456 456
             }
457 457
 
458 458
         }
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @return void
472 472
 	 */
473 473
 	public function verify_ipn() {
474
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
474
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
475 475
     }
476 476
 
477 477
     /**
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
     public function sandbox_notice() {
481 481
 
482 482
         return sprintf(
483
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
483
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
484 484
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
485 485
 			'</a>'
486 486
 		);
Please login to merge, or discard this patch.
includes/api/class-getpaid-rest-report-top-sellers-controller.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -18,179 +18,179 @@
 block discarded – undo
18 18
  */
19 19
 class GetPaid_REST_Report_Top_Sellers_Controller extends GetPaid_REST_Report_Sales_Controller {
20 20
 
21
-	/**
22
-	 * Route base.
23
-	 *
24
-	 * @var string
25
-	 */
26
-	protected $rest_base = 'reports/top_sellers';
27
-
28
-	/**
29
-	 * Get top sellers report.
30
-	 *
31
-	 * @param WP_REST_Request $request
32
-	 * @return array|WP_Error
33
-	 */
34
-	public function get_items( $request ) {
35
-
36
-		// Prepare items.
37
-		$this->report_range = $this->get_date_range( $request );
38
-		$report_data        = $this->get_report_data();
39
-
40
-		$top_sellers = array();
41
-
42
-		foreach ( $report_data as $item ) {
43
-
44
-			$item_obj  = new WPInv_Item( $item );
45
-			$item_name = $item->invoice_item_name;
46
-			$item_qty  = floatval( $item->invoice_item_qty );
47
-			$item_id   = absint( $item->invoice_item_id );
48
-			$price     = sanitize_text_field( wpinv_price( $item->invoice_item_price ) );
49
-
50
-			$item_obj  = new WPInv_Item( $item_id );
51
-
52
-			if ( $item_obj->exists() ) {
53
-				$item_name = $item_obj->get_name();
54
-			} else {
55
-				$item_id   = 0; 
56
-			}
57
-
58
-			$top_sellers[] = array(
59
-				'name'               =>sanitize_text_field( $item_name ),
60
-				'item_id'            => $item_id,
61
-				'quantity'           => $item_qty,
62
-				'earnings'           => wpinv_round_amount( $item->invoice_item_price ),
63
-				'earnings_formatted' => sanitize_text_field( wpinv_price( $price ) ),
64
-			);
65
-
66
-		}
67
-
68
-		$data = array();
69
-		foreach ( $top_sellers as $top_seller ) {
70
-			$item   = $this->prepare_item_for_response( (object) $top_seller, $request );
71
-			$data[] = $this->prepare_response_for_collection( $item );
72
-		}
73
-
74
-		return rest_ensure_response( $data );
75
-
76
-	}
77
-
78
-	/**
79
-	 * Prepare a report sales object for serialization.
80
-	 *
81
-	 * @param stdClass $top_seller
82
-	 * @param WP_REST_Request $request Request object.
83
-	 * @return WP_REST_Response $response Response data.
84
-	 */
85
-	public function prepare_item_for_response( $top_seller, $request ) {
86
-		$data    = (array) $top_seller;
87
-
88
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
89
-		$data    = $this->add_additional_fields_to_object( $data, $request );
90
-		$data    = $this->filter_response_by_context( $data, $context );
91
-
92
-		// Wrap the data in a response object.
93
-		$response = rest_ensure_response( $data );
94
-		$links = array(
95
-			'about' => array(
96
-				'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ),
97
-			),
98
-		);
99
-
100
-		if ( ! empty( $top_seller->item_id ) ) {
101
-			$links['item']   = array(
102
-				'href'       => rest_url( sprintf( '/%s/items/%s', $this->namespace, $top_seller->item_id ) ),
103
-				'embeddable' => true,
104
-			);
105
-		}
106
-
107
-		$response->add_links( $links );
108
-		return apply_filters( 'getpaid_rest_prepare_report_' . $this->rest_base, $response, $top_seller, $request );
109
-	}
110
-
111
-	/**
112
-	 * Get all data needed for this report and store in the class.
113
-	 */
114
-	protected function query_report_data() {
115
-
116
-		$this->report_data = GetPaid_Reports_Helper::get_invoice_report_data(
117
-			array(
118
-				'data'              => array(
119
-					'quantity'      => array(
120
-						'type'            => 'invoice_item',
121
-						'function'        => 'SUM',
122
-						'name'            => 'invoice_item_qty',
123
-					),
124
-					'item_id'             => array(
125
-						'type'            => 'invoice_item',
126
-						'function'        => '',
127
-						'name'            => 'invoice_item_id',
128
-					),
129
-					'item_name'           => array(
130
-						'type'            => 'invoice_item',
131
-						'function'        => '',
132
-						'name'            => 'invoice_item_name',
133
-					),
134
-					'price'               => array(
135
-						'type'            => 'invoice_item',
136
-						'function'        => 'SUM',
137
-						'name'            => 'invoice_item_price',
138
-					),
139
-				),
140
-				'group_by'       => 'invoice_item_id',
141
-				'order_by'       => 'invoice_item_qty DESC',
142
-				'query_type'     => 'get_results',
143
-				'limit'          => 10,
144
-				'filter_range'   => $this->report_range,
145
-			)
146
-		);
147
-
148
-	}
149
-
150
-	/**
151
-	 * Get the Report's schema, conforming to JSON Schema.
152
-	 *
153
-	 * @return array
154
-	 */
155
-	public function get_item_schema() {
156
-		$schema = array(
157
-			'$schema'    => 'http://json-schema.org/draft-04/schema#',
158
-			'title'      => $this->rest_base,
159
-			'type'       => 'object',
160
-			'properties' => array(
161
-				'name' => array(
162
-					'description' => __( 'Item name.', 'invoicing' ),
163
-					'type'        => 'string',
164
-					'context'     => array( 'view' ),
165
-					'readonly'    => true,
166
-				),
167
-				'item_id'         => array(
168
-					'description' => __( 'Item ID.', 'invoicing' ),
169
-					'type'        => 'integer',
170
-					'context'     => array( 'view' ),
171
-					'readonly'    => true,
172
-				),
173
-				'quantity' => array(
174
-					'description' => __( 'Total number of purchases.', 'invoicing' ),
175
-					'type'        => 'number',
176
-					'context'     => array( 'view' ),
177
-					'readonly'    => true,
178
-				),
179
-				'earnings' => array(
180
-					'description' => __( 'Total earnings for the item.', 'invoicing' ),
181
-					'type'        => 'number',
182
-					'context'     => array( 'view' ),
183
-					'readonly'    => true,
184
-				),
185
-				'earnings_formatted"' => array(
186
-					'description' => __( 'Total earnings (formatted) for the item.', 'invoicing' ),
187
-					'type'        => 'string',
188
-					'context'     => array( 'view' ),
189
-					'readonly'    => true,
190
-				),
191
-			),
192
-		);
193
-
194
-		return $this->add_additional_fields_schema( $schema );
195
-	}
21
+    /**
22
+     * Route base.
23
+     *
24
+     * @var string
25
+     */
26
+    protected $rest_base = 'reports/top_sellers';
27
+
28
+    /**
29
+     * Get top sellers report.
30
+     *
31
+     * @param WP_REST_Request $request
32
+     * @return array|WP_Error
33
+     */
34
+    public function get_items( $request ) {
35
+
36
+        // Prepare items.
37
+        $this->report_range = $this->get_date_range( $request );
38
+        $report_data        = $this->get_report_data();
39
+
40
+        $top_sellers = array();
41
+
42
+        foreach ( $report_data as $item ) {
43
+
44
+            $item_obj  = new WPInv_Item( $item );
45
+            $item_name = $item->invoice_item_name;
46
+            $item_qty  = floatval( $item->invoice_item_qty );
47
+            $item_id   = absint( $item->invoice_item_id );
48
+            $price     = sanitize_text_field( wpinv_price( $item->invoice_item_price ) );
49
+
50
+            $item_obj  = new WPInv_Item( $item_id );
51
+
52
+            if ( $item_obj->exists() ) {
53
+                $item_name = $item_obj->get_name();
54
+            } else {
55
+                $item_id   = 0; 
56
+            }
57
+
58
+            $top_sellers[] = array(
59
+                'name'               =>sanitize_text_field( $item_name ),
60
+                'item_id'            => $item_id,
61
+                'quantity'           => $item_qty,
62
+                'earnings'           => wpinv_round_amount( $item->invoice_item_price ),
63
+                'earnings_formatted' => sanitize_text_field( wpinv_price( $price ) ),
64
+            );
65
+
66
+        }
67
+
68
+        $data = array();
69
+        foreach ( $top_sellers as $top_seller ) {
70
+            $item   = $this->prepare_item_for_response( (object) $top_seller, $request );
71
+            $data[] = $this->prepare_response_for_collection( $item );
72
+        }
73
+
74
+        return rest_ensure_response( $data );
75
+
76
+    }
77
+
78
+    /**
79
+     * Prepare a report sales object for serialization.
80
+     *
81
+     * @param stdClass $top_seller
82
+     * @param WP_REST_Request $request Request object.
83
+     * @return WP_REST_Response $response Response data.
84
+     */
85
+    public function prepare_item_for_response( $top_seller, $request ) {
86
+        $data    = (array) $top_seller;
87
+
88
+        $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
89
+        $data    = $this->add_additional_fields_to_object( $data, $request );
90
+        $data    = $this->filter_response_by_context( $data, $context );
91
+
92
+        // Wrap the data in a response object.
93
+        $response = rest_ensure_response( $data );
94
+        $links = array(
95
+            'about' => array(
96
+                'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ),
97
+            ),
98
+        );
99
+
100
+        if ( ! empty( $top_seller->item_id ) ) {
101
+            $links['item']   = array(
102
+                'href'       => rest_url( sprintf( '/%s/items/%s', $this->namespace, $top_seller->item_id ) ),
103
+                'embeddable' => true,
104
+            );
105
+        }
106
+
107
+        $response->add_links( $links );
108
+        return apply_filters( 'getpaid_rest_prepare_report_' . $this->rest_base, $response, $top_seller, $request );
109
+    }
110
+
111
+    /**
112
+     * Get all data needed for this report and store in the class.
113
+     */
114
+    protected function query_report_data() {
115
+
116
+        $this->report_data = GetPaid_Reports_Helper::get_invoice_report_data(
117
+            array(
118
+                'data'              => array(
119
+                    'quantity'      => array(
120
+                        'type'            => 'invoice_item',
121
+                        'function'        => 'SUM',
122
+                        'name'            => 'invoice_item_qty',
123
+                    ),
124
+                    'item_id'             => array(
125
+                        'type'            => 'invoice_item',
126
+                        'function'        => '',
127
+                        'name'            => 'invoice_item_id',
128
+                    ),
129
+                    'item_name'           => array(
130
+                        'type'            => 'invoice_item',
131
+                        'function'        => '',
132
+                        'name'            => 'invoice_item_name',
133
+                    ),
134
+                    'price'               => array(
135
+                        'type'            => 'invoice_item',
136
+                        'function'        => 'SUM',
137
+                        'name'            => 'invoice_item_price',
138
+                    ),
139
+                ),
140
+                'group_by'       => 'invoice_item_id',
141
+                'order_by'       => 'invoice_item_qty DESC',
142
+                'query_type'     => 'get_results',
143
+                'limit'          => 10,
144
+                'filter_range'   => $this->report_range,
145
+            )
146
+        );
147
+
148
+    }
149
+
150
+    /**
151
+     * Get the Report's schema, conforming to JSON Schema.
152
+     *
153
+     * @return array
154
+     */
155
+    public function get_item_schema() {
156
+        $schema = array(
157
+            '$schema'    => 'http://json-schema.org/draft-04/schema#',
158
+            'title'      => $this->rest_base,
159
+            'type'       => 'object',
160
+            'properties' => array(
161
+                'name' => array(
162
+                    'description' => __( 'Item name.', 'invoicing' ),
163
+                    'type'        => 'string',
164
+                    'context'     => array( 'view' ),
165
+                    'readonly'    => true,
166
+                ),
167
+                'item_id'         => array(
168
+                    'description' => __( 'Item ID.', 'invoicing' ),
169
+                    'type'        => 'integer',
170
+                    'context'     => array( 'view' ),
171
+                    'readonly'    => true,
172
+                ),
173
+                'quantity' => array(
174
+                    'description' => __( 'Total number of purchases.', 'invoicing' ),
175
+                    'type'        => 'number',
176
+                    'context'     => array( 'view' ),
177
+                    'readonly'    => true,
178
+                ),
179
+                'earnings' => array(
180
+                    'description' => __( 'Total earnings for the item.', 'invoicing' ),
181
+                    'type'        => 'number',
182
+                    'context'     => array( 'view' ),
183
+                    'readonly'    => true,
184
+                ),
185
+                'earnings_formatted"' => array(
186
+                    'description' => __( 'Total earnings (formatted) for the item.', 'invoicing' ),
187
+                    'type'        => 'string',
188
+                    'context'     => array( 'view' ),
189
+                    'readonly'    => true,
190
+                ),
191
+            ),
192
+        );
193
+
194
+        return $this->add_additional_fields_schema( $schema );
195
+    }
196 196
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since   2.0.0
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 /**
15 15
  * GetPaid REST top sellers controller class.
@@ -31,47 +31,47 @@  discard block
 block discarded – undo
31 31
 	 * @param WP_REST_Request $request
32 32
 	 * @return array|WP_Error
33 33
 	 */
34
-	public function get_items( $request ) {
34
+	public function get_items($request) {
35 35
 
36 36
 		// Prepare items.
37
-		$this->report_range = $this->get_date_range( $request );
37
+		$this->report_range = $this->get_date_range($request);
38 38
 		$report_data        = $this->get_report_data();
39 39
 
40 40
 		$top_sellers = array();
41 41
 
42
-		foreach ( $report_data as $item ) {
42
+		foreach ($report_data as $item) {
43 43
 
44
-			$item_obj  = new WPInv_Item( $item );
44
+			$item_obj  = new WPInv_Item($item);
45 45
 			$item_name = $item->invoice_item_name;
46
-			$item_qty  = floatval( $item->invoice_item_qty );
47
-			$item_id   = absint( $item->invoice_item_id );
48
-			$price     = sanitize_text_field( wpinv_price( $item->invoice_item_price ) );
46
+			$item_qty  = floatval($item->invoice_item_qty);
47
+			$item_id   = absint($item->invoice_item_id);
48
+			$price     = sanitize_text_field(wpinv_price($item->invoice_item_price));
49 49
 
50
-			$item_obj  = new WPInv_Item( $item_id );
50
+			$item_obj  = new WPInv_Item($item_id);
51 51
 
52
-			if ( $item_obj->exists() ) {
52
+			if ($item_obj->exists()) {
53 53
 				$item_name = $item_obj->get_name();
54 54
 			} else {
55 55
 				$item_id   = 0; 
56 56
 			}
57 57
 
58 58
 			$top_sellers[] = array(
59
-				'name'               =>sanitize_text_field( $item_name ),
59
+				'name'               =>sanitize_text_field($item_name),
60 60
 				'item_id'            => $item_id,
61 61
 				'quantity'           => $item_qty,
62
-				'earnings'           => wpinv_round_amount( $item->invoice_item_price ),
63
-				'earnings_formatted' => sanitize_text_field( wpinv_price( $price ) ),
62
+				'earnings'           => wpinv_round_amount($item->invoice_item_price),
63
+				'earnings_formatted' => sanitize_text_field(wpinv_price($price)),
64 64
 			);
65 65
 
66 66
 		}
67 67
 
68 68
 		$data = array();
69
-		foreach ( $top_sellers as $top_seller ) {
70
-			$item   = $this->prepare_item_for_response( (object) $top_seller, $request );
71
-			$data[] = $this->prepare_response_for_collection( $item );
69
+		foreach ($top_sellers as $top_seller) {
70
+			$item   = $this->prepare_item_for_response((object) $top_seller, $request);
71
+			$data[] = $this->prepare_response_for_collection($item);
72 72
 		}
73 73
 
74
-		return rest_ensure_response( $data );
74
+		return rest_ensure_response($data);
75 75
 
76 76
 	}
77 77
 
@@ -82,30 +82,30 @@  discard block
 block discarded – undo
82 82
 	 * @param WP_REST_Request $request Request object.
83 83
 	 * @return WP_REST_Response $response Response data.
84 84
 	 */
85
-	public function prepare_item_for_response( $top_seller, $request ) {
85
+	public function prepare_item_for_response($top_seller, $request) {
86 86
 		$data    = (array) $top_seller;
87 87
 
88
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
89
-		$data    = $this->add_additional_fields_to_object( $data, $request );
90
-		$data    = $this->filter_response_by_context( $data, $context );
88
+		$context = !empty($request['context']) ? $request['context'] : 'view';
89
+		$data    = $this->add_additional_fields_to_object($data, $request);
90
+		$data    = $this->filter_response_by_context($data, $context);
91 91
 
92 92
 		// Wrap the data in a response object.
93
-		$response = rest_ensure_response( $data );
93
+		$response = rest_ensure_response($data);
94 94
 		$links = array(
95 95
 			'about' => array(
96
-				'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ),
96
+				'href' => rest_url(sprintf('%s/reports', $this->namespace)),
97 97
 			),
98 98
 		);
99 99
 
100
-		if ( ! empty( $top_seller->item_id ) ) {
101
-			$links['item']   = array(
102
-				'href'       => rest_url( sprintf( '/%s/items/%s', $this->namespace, $top_seller->item_id ) ),
100
+		if (!empty($top_seller->item_id)) {
101
+			$links['item'] = array(
102
+				'href'       => rest_url(sprintf('/%s/items/%s', $this->namespace, $top_seller->item_id)),
103 103
 				'embeddable' => true,
104 104
 			);
105 105
 		}
106 106
 
107
-		$response->add_links( $links );
108
-		return apply_filters( 'getpaid_rest_prepare_report_' . $this->rest_base, $response, $top_seller, $request );
107
+		$response->add_links($links);
108
+		return apply_filters('getpaid_rest_prepare_report_' . $this->rest_base, $response, $top_seller, $request);
109 109
 	}
110 110
 
111 111
 	/**
@@ -159,38 +159,38 @@  discard block
 block discarded – undo
159 159
 			'type'       => 'object',
160 160
 			'properties' => array(
161 161
 				'name' => array(
162
-					'description' => __( 'Item name.', 'invoicing' ),
162
+					'description' => __('Item name.', 'invoicing'),
163 163
 					'type'        => 'string',
164
-					'context'     => array( 'view' ),
164
+					'context'     => array('view'),
165 165
 					'readonly'    => true,
166 166
 				),
167 167
 				'item_id'         => array(
168
-					'description' => __( 'Item ID.', 'invoicing' ),
168
+					'description' => __('Item ID.', 'invoicing'),
169 169
 					'type'        => 'integer',
170
-					'context'     => array( 'view' ),
170
+					'context'     => array('view'),
171 171
 					'readonly'    => true,
172 172
 				),
173 173
 				'quantity' => array(
174
-					'description' => __( 'Total number of purchases.', 'invoicing' ),
174
+					'description' => __('Total number of purchases.', 'invoicing'),
175 175
 					'type'        => 'number',
176
-					'context'     => array( 'view' ),
176
+					'context'     => array('view'),
177 177
 					'readonly'    => true,
178 178
 				),
179 179
 				'earnings' => array(
180
-					'description' => __( 'Total earnings for the item.', 'invoicing' ),
180
+					'description' => __('Total earnings for the item.', 'invoicing'),
181 181
 					'type'        => 'number',
182
-					'context'     => array( 'view' ),
182
+					'context'     => array('view'),
183 183
 					'readonly'    => true,
184 184
 				),
185 185
 				'earnings_formatted"' => array(
186
-					'description' => __( 'Total earnings (formatted) for the item.', 'invoicing' ),
186
+					'description' => __('Total earnings (formatted) for the item.', 'invoicing'),
187 187
 					'type'        => 'string',
188
-					'context'     => array( 'view' ),
188
+					'context'     => array('view'),
189 189
 					'readonly'    => true,
190 190
 				),
191 191
 			),
192 192
 		);
193 193
 
194
-		return $this->add_additional_fields_schema( $schema );
194
+		return $this->add_additional_fields_schema($schema);
195 195
 	}
196 196
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-items.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -12,79 +12,79 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Items {
14 14
 
15
-	/**
16
-	 * Submission items.
17
-	 * @var GetPaid_Form_Item[]
18
-	 */
19
-	public $items = array();
20
-
21 15
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$data         = $submission->get_data();
29
-		$payment_form = $submission->get_payment_form();
30
-
31
-		// Prepare the selected items.
32
-		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
35
-		}
36
-
37
-		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
-		}
16
+     * Submission items.
17
+     * @var GetPaid_Form_Item[]
18
+     */
19
+    public $items = array();
42 20
 
43
-		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items );
46
-		}
47
-
48
-	}
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $data         = $submission->get_data();
29
+        $payment_form = $submission->get_payment_form();
30
+
31
+        // Prepare the selected items.
32
+        $selected_items = array();
33
+        if ( ! empty( $data['getpaid-items'] ) ) {
34
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
35
+        }
36
+
37
+        // For default forms, ensure that an item has been set.
38
+        if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
+            $form_items = wpinv_clean( $data['getpaid-form-items'] );
40
+            $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
+        }
42
+
43
+        // Process each individual item.
44
+        foreach ( $payment_form->get_items() as $item ) {
45
+            $this->process_item( $item, $selected_items );
46
+        }
47
+
48
+    }
49 49
 
50
-	/**
51
-	 * Process a single item.
52
-	 *
53
-	 * @param GetPaid_Form_Item $item
54
-	 * @param array $selected_items
55
-	 */
56
-	public function process_item( $item, $selected_items ) {
50
+    /**
51
+     * Process a single item.
52
+     *
53
+     * @param GetPaid_Form_Item $item
54
+     * @param array $selected_items
55
+     */
56
+    public function process_item( $item, $selected_items ) {
57 57
 
58
-		// Abort if this is an optional item and it has not been selected.
59
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
-			return;
61
-		}
58
+        // Abort if this is an optional item and it has not been selected.
59
+        if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
+            return;
61
+        }
62 62
 
63
-		// (maybe) let customers change the quantities and prices.
64
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
63
+        // (maybe) let customers change the quantities and prices.
64
+        if ( isset( $selected_items[ $item->get_id() ] ) ) {
65 65
 
66
-			// Maybe change the quantities.
67
-			if ( $item->allows_quantities() ) {
68
-				$item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
69
-			}
66
+            // Maybe change the quantities.
67
+            if ( $item->allows_quantities() ) {
68
+                $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
69
+            }
70 70
 
71
-			// Maybe change the price.
72
-			if ( $item->user_can_set_their_price() ) {
73
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
71
+            // Maybe change the price.
72
+            if ( $item->user_can_set_their_price() ) {
73
+                $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
74 74
 
75
-				if ( $item->get_minimum_price() > $price ) {
76
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
77
-				}
75
+                if ( $item->get_minimum_price() > $price ) {
76
+                    throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
77
+                }
78 78
 
79
-				$item->set_price( $price );
79
+                $item->set_price( $price );
80 80
 
81
-			}
81
+            }
82 82
 
83
-		}
83
+        }
84 84
 
85
-		// Save the item.
86
-		$this->items[] = $item;
85
+        // Save the item.
86
+        $this->items[] = $item;
87 87
 
88
-	}
88
+    }
89 89
 
90 90
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission itemss class
@@ -23,26 +23,26 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$data         = $submission->get_data();
29 29
 		$payment_form = $submission->get_payment_form();
30 30
 
31 31
 		// Prepare the selected items.
32 32
 		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
33
+		if (!empty($data['getpaid-items'])) {
34
+			$selected_items = wpinv_clean($data['getpaid-items']);
35 35
 		}
36 36
 
37 37
 		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
38
+		if ($payment_form->is_default() && !$submission->has_invoice() && isset($data['getpaid-form-items'])) {
39
+			$form_items = wpinv_clean($data['getpaid-form-items']);
40
+			$payment_form->set_items(getpaid_convert_items_to_array($form_items));
41 41
 		}
42 42
 
43 43
 		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items );
44
+		foreach ($payment_form->get_items() as $item) {
45
+			$this->process_item($item, $selected_items);
46 46
 		}
47 47
 
48 48
 	}
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
 	 * @param GetPaid_Form_Item $item
54 54
 	 * @param array $selected_items
55 55
 	 */
56
-	public function process_item( $item, $selected_items ) {
56
+	public function process_item($item, $selected_items) {
57 57
 
58 58
 		// Abort if this is an optional item and it has not been selected.
59
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
59
+		if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
60 60
 			return;
61 61
 		}
62 62
 
63 63
 		// (maybe) let customers change the quantities and prices.
64
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
64
+		if (isset($selected_items[$item->get_id()])) {
65 65
 
66 66
 			// Maybe change the quantities.
67
-			if ( $item->allows_quantities() ) {
68
-				$item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
67
+			if ($item->allows_quantities()) {
68
+				$item->set_quantity((float) $selected_items[$item->get_id()]['quantity']);
69 69
 			}
70 70
 
71 71
 			// Maybe change the price.
72
-			if ( $item->user_can_set_their_price() ) {
73
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
72
+			if ($item->user_can_set_their_price()) {
73
+				$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
74 74
 
75
-				if ( $item->get_minimum_price() > $price ) {
76
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
75
+				if ($item->get_minimum_price() > $price) {
76
+					throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_sanitize_amount($item->get_minimum_price())));
77 77
 				}
78 78
 
79
-				$item->set_price( $price );
79
+				$item->set_price($price);
80 80
 
81 81
 			}
82 82
 
Please login to merge, or discard this patch.
includes/data/invoice-schema.php 2 patches
Indentation   +621 added lines, -621 removed lines patch added patch discarded remove patch
@@ -13,629 +13,629 @@
 block discarded – undo
13 13
 
14 14
 return array(
15 15
 
16
-	'id'              => array(
17
-		'description' => __( 'Unique identifier for the invoice.', 'invoicing' ),
18
-		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
20
-		'readonly'    => true,
21
-	),
22
-
23
-	'parent_id'       => array(
24
-		'description' => __( 'Parent invoice ID.', 'invoicing' ),
25
-		'type'        => 'integer',
26
-		'minimum'     => 0,
27
-		'default'     => 0,
28
-		'context'     => array( 'view', 'edit' ),
29
-	),
30
-
31
-	'key'			  => array(
32
-		'description' => __( 'A unique key for the invoice.', 'invoicing' ),
33
-		'type'        => 'string',
34
-		'context'     => array( 'view', 'edit' ),
35
-		'readonly'    => true,
36
-	),
37
-
38
-	'number'		  => array(
39
-		'description' => __( 'A unique number for the invoice.', 'invoicing' ),
40
-		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit', 'embed' ),
42
-	),
43
-
44
-	'type'			  => array(
45
-		'description' => __( 'Get the invoice type (e.g invoice, quote etc).', 'invoicing' ),
46
-		'type'        => 'string',
47
-		'context'     => array( 'view', 'edit', 'embed' ),
48
-		'readonly'    => true,
49
-	),
50
-
51
-	'post_type'		  => array(
52
-		'description' => __( 'Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing' ),
53
-		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
55
-		'readonly'    => true,
56
-	),
57
-
58
-	'version'         => array(
59
-		'description' => __( 'Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing' ),
60
-		'type'        => 'integer',
61
-		'context'     => array( 'view', 'edit' ),
62
-		'readonly'    => true,
63
-	),
64
-
65
-	'template'        => array(
66
-		'description' => __( 'The invoice template.', 'invoicing' ),
67
-		'type'        => 'string',
68
-		'default'     => 'quantity',
69
-		'enum'        => array( 'quantity', 'hours', 'amount' ),
70
-		'context'     => array( 'view', 'edit', 'embed' ),
71
-	),
72
-
73
-	'status'          => array(
74
-		'description' => __( 'Invoice status.', 'invoicing' ),
75
-		'type'        => 'string',
76
-		'default'     => 'wpi-pending',
77
-		'enum'        => array_keys( wpinv_get_invoice_statuses( true ) ),
78
-		'context'     => array( 'view', 'edit', 'embed' ),
79
-	),
80
-
81
-	'status_nicename' => array(
82
-		'description' => __( 'A human readable name for the invoice status.', 'invoicing' ),
83
-		'type'        => 'string',
84
-		'context'     => array( 'view', 'edit', 'embed' ),
85
-		'readonly'    => true,
86
-	),
87
-
88
-	'currency'        => array(
89
-		'description' => __( 'The invoice currency in ISO format.', 'invoicing' ),
90
-		'type'        => 'string',
91
-		'default'     => wpinv_get_currency(),
92
-		'enum'        => array_keys( wpinv_get_currencies() ),
93
-		'context'     => array( 'view', 'edit', 'embed' ),
94
-	),
95
-
96
-	'date_created'    => array(
97
-		'description' => __( "The date the invoice was created, in the site's timezone.", 'invoicing' ),
98
-		'type'        => 'string',
99
-		'context'     => array( 'view', 'edit', 'embed' ),
100
-	),
101
-
102
-	'date_created_gmt'    => array(
103
-		'description' => __( 'The GMT date the invoice was created.', 'invoicing' ),
104
-		'type'        => 'string',
105
-		'context'     => array( 'view', 'edit', 'embed' ),
106
-		'readonly'    => true,
107
-	),
108
-
109
-	'date_modified'   => array(
110
-		'description' => __( "The date the invoice was last modified, in the site's timezone.", 'invoicing' ),
111
-		'type'        => 'string',
112
-		'context'     => array( 'view', 'edit', 'embed' ),
113
-		'readonly'    => true,
114
-	),
115
-
116
-	'date_modified_gmt'    => array(
117
-		'description' => __( 'The GMT date the invoice was last modified.', 'invoicing' ),
118
-		'type'        => 'string',
119
-		'context'     => array( 'view', 'edit', 'embed' ),
120
-		'readonly'    => true,
121
-	),
122
-
123
-	'due_date'        => array(
124
-		'description' => __( "The invoice's due date, in the site's timezone.", 'invoicing' ),
125
-		'type'        => 'string',
126
-		'context'     => array( 'view', 'edit', 'embed' ),
127
-	),
128
-
129
-	'due_date_gmt'    => array(
130
-		'description' => __( 'The GMT date the invoice is/was due.', 'invoicing' ),
131
-		'type'        => 'string',
132
-		'context'     => array( 'view', 'edit', 'embed' ),
133
-		'readonly'    => true,
134
-	),
135
-
136
-	'completed_date'  => array(
137
-		'description' => __( "The date the invoice was paid, in the site's timezone.", 'invoicing' ),
138
-		'type'        => 'string',
139
-		'context'     => array( 'view', 'edit', 'embed' ),
140
-		'readonly'    => true,
141
-	),
142
-
143
-	'completed_date_gmt'    => array(
144
-		'description' => __( 'The GMT date the invoice was paid.', 'invoicing' ),
145
-		'type'        => 'string',
146
-		'context'     => array( 'view', 'edit', 'embed' ),
147
-		'readonly'    => true,
148
-	),
149
-
150
-	'total_discount'   => array(
151
-		'description' => __( 'Total discount amount for the invoice.', 'invoicing' ),
152
-		'type'        => 'number',
153
-		'context'     => array( 'view', 'edit', 'embed' ),
154
-		'readonly'    => true,
155
-	),
156
-
157
-	'total_tax'       => array(
158
-		'description' => __( 'Total tax amount for the invoice.', 'invoicing' ),
159
-		'type'        => 'number',
160
-		'context'     => array( 'view', 'edit', 'embed' ),
161
-		'readonly'    => true,
162
-	),
163
-
164
-	'total_fees'      => array(
165
-		'description' => __( 'Total fees amount for the invoice.', 'invoicing' ),
166
-		'type'        => 'number',
167
-		'context'     => array( 'view', 'edit', 'embed' ),
168
-		'readonly'    => true,
169
-	),
170
-
171
-	'subtotal'        => array(
172
-		'description' => __( 'Invoice subtotal.', 'invoicing' ),
173
-		'type'        => 'number',
174
-		'context'     => array( 'view', 'edit', 'embed' ),
175
-		'readonly'    => true,
176
-	),
177
-
178
-	'total'           => array(
179
-		'description' => __( 'Grand total.', 'invoicing' ),
180
-		'type'        => 'number',
181
-		'context'     => array( 'view', 'edit', 'embed' ),
182
-		'readonly'    => true,
183
-	),
184
-
185
-	'initial_total'   => array(
186
-		'description' => __( 'Initial total (for recurring invoices).', 'invoicing' ),
187
-		'type'        => 'number',
188
-		'context'     => array( 'view', 'edit', 'embed' ),
189
-		'readonly'    => true,
190
-	),
191
-
192
-	'recurring_total'  => array(
193
-		'description' => __( 'Recurring total (for recurring invoices).', 'invoicing' ),
194
-		'type'        => 'number',
195
-		'context'     => array( 'view', 'edit', 'embed' ),
196
-		'readonly'    => true,
197
-	),
198
-
199
-	'totals'          => array(
200
-		'description' => __( 'Invoice totals.', 'invoicing' ),
201
-		'type'        => 'object',
202
-		'context'     => array( 'view', 'edit', 'embed' ),
203
-		'readonly'    => true,
204
-	),
205
-
206
-	'fees'            => array(
207
-		'description' => __( 'Invoice fees (Name => properties).', 'invoicing' ),
208
-		'type'        => 'object',
209
-		'context'     => array( 'view', 'edit', 'embed' ),
210
-		'items'       => array(
211
-			'type'                => 'object',
212
-			'required'            => array( 'amount' ),
213
-			'properties'          => array(
214
-				'amount'          => array(
215
-					'description' => __( 'Fee amount.', 'invoicing' ),
216
-					'type'        => 'string',
217
-					'context'     => array( 'view', 'edit', 'embed' ),
218
-				),
219
-				'recurring'       => array(
220
-					'description' => __( 'Whether this is a recurring or one-time fee.', 'invoicing' ),
221
-					'type'        => array( 'boolean', 'integer' ),
222
-					'context'     => array( 'view', 'edit', 'embed' ),
223
-				),
224
-			),
225
-		),
226
-	),
227
-
228
-	'discounts'       => array(
229
-		'description' => __( 'Invoice discounts (Name => properties).', 'invoicing' ),
230
-		'type'        => 'object',
231
-		'context'     => array( 'view', 'edit', 'embed' ),
232
-		'items'       => array(
233
-			'type'                => 'object',
234
-			'required'            => array( 'amount' ),
235
-			'properties'          => array(
236
-				'amount'          => array(
237
-					'description' => __( 'Fee amount.', 'invoicing' ),
238
-					'type'        => 'string',
239
-					'context'     => array( 'view', 'edit', 'embed' ),
240
-				),
241
-				'recurring'       => array(
242
-					'description' => __( 'Whether this is a recurring or one-time discount.', 'invoicing' ),
243
-					'type'        => array( 'boolean', 'integer' ),
244
-					'context'     => array( 'view', 'edit', 'embed' ),
245
-				),
246
-			),
247
-		),
248
-	),
249
-
250
-	'taxes'           => array(
251
-		'description' => __( 'Invoice taxes (Name => properties).', 'invoicing' ),
252
-		'type'        => 'object',
253
-		'context'     => array( 'view', 'edit', 'embed' ),
254
-		'items'       => array(
255
-			'type'                => 'object',
256
-			'required'            => array( 'amount' ),
257
-			'properties'          => array(
258
-				'amount'          => array(
259
-					'description' => __( 'Fee amount.', 'invoicing' ),
260
-					'type'        => 'string',
261
-					'context'     => array( 'view', 'edit', 'embed' ),
262
-				),
263
-				'recurring'       => array(
264
-					'description' => __( 'Whether this is a recurring or one-time tax.', 'invoicing' ),
265
-					'type'        => array( 'boolean', 'integer' ),
266
-					'context'     => array( 'view', 'edit', 'embed' ),
267
-				),
268
-			),
269
-		),
270
-	),
271
-
272
-	'items'           => array(
273
-		'description' => __( 'Invoice items.', 'invoicing' ),
274
-		'type'        => 'array',
275
-		'context'     => array( 'view', 'edit', 'embed' ),
276
-		'items'       => array(
277
-			'type'                => 'object',
278
-			'required'            => array( 'item_id' ),
279
-			'properties'          => array(
280
-				'item_id'         => array(
281
-					'description' => __( 'Item ID.', 'invoicing' ),
282
-					'type'        => 'integer',
283
-					'context'     => array( 'view', 'edit', 'embed' ),
284
-				),
285
-				'item_name'       => array(
286
-					'description' => __( 'Item Name.', 'invoicing' ),
287
-					'type'        => 'string',
288
-					'context'     => array( 'view', 'edit', 'embed' ),
289
-				),
290
-				'item_description' => array(
291
-					'description'  => __( 'Item Description.', 'invoicing' ),
292
-					'type'         => 'string',
293
-					'context'      => array( 'view', 'edit', 'embed' ),
294
-				),
295
-				'item_price'      => array(
296
-					'description' => __( 'Item Price.', 'invoicing' ),
297
-					'type'        => 'number',
298
-					'context'     => array( 'view', 'edit', 'embed' ),
299
-				),
300
-				'quantity'        => array(
301
-					'description' => __( 'Item Quantity.', 'invoicing' ),
302
-					'type'        => 'number',
303
-					'context'     => array( 'view', 'edit', 'embed' ),
304
-				),
305
-				'subtotal'        => array(
306
-					'description' => __( 'Item Subtotal.', 'invoicing' ),
307
-					'type'        => 'number',
308
-					'context'     => array( 'view', 'edit', 'embed' ),
309
-					'readonly'    => true,
310
-				),
311
-				'meta'            => array(
312
-					'description' => __( 'Item Meta.', 'invoicing' ),
313
-					'type'        => 'object',
314
-					'context'     => array( 'view', 'edit', 'embed' ),
315
-				),
316
-			),
317
-		),
318
-	),
319
-
320
-	'mode'			  => array(
321
-		'description' => __( 'The invoice transaction mode.', 'invoicing' ),
322
-		'type'        => 'string',
323
-		'context'     => array( 'view', 'edit', 'embed' ),
324
-		'enum'        => array( 'live', 'test' ),
325
-		'readonly'    => true,
326
-	),
16
+    'id'              => array(
17
+        'description' => __( 'Unique identifier for the invoice.', 'invoicing' ),
18
+        'type'        => 'integer',
19
+        'context'     => array( 'view', 'edit', 'embed' ),
20
+        'readonly'    => true,
21
+    ),
22
+
23
+    'parent_id'       => array(
24
+        'description' => __( 'Parent invoice ID.', 'invoicing' ),
25
+        'type'        => 'integer',
26
+        'minimum'     => 0,
27
+        'default'     => 0,
28
+        'context'     => array( 'view', 'edit' ),
29
+    ),
30
+
31
+    'key'			  => array(
32
+        'description' => __( 'A unique key for the invoice.', 'invoicing' ),
33
+        'type'        => 'string',
34
+        'context'     => array( 'view', 'edit' ),
35
+        'readonly'    => true,
36
+    ),
37
+
38
+    'number'		  => array(
39
+        'description' => __( 'A unique number for the invoice.', 'invoicing' ),
40
+        'type'        => 'string',
41
+        'context'     => array( 'view', 'edit', 'embed' ),
42
+    ),
43
+
44
+    'type'			  => array(
45
+        'description' => __( 'Get the invoice type (e.g invoice, quote etc).', 'invoicing' ),
46
+        'type'        => 'string',
47
+        'context'     => array( 'view', 'edit', 'embed' ),
48
+        'readonly'    => true,
49
+    ),
50
+
51
+    'post_type'		  => array(
52
+        'description' => __( 'Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing' ),
53
+        'type'        => 'string',
54
+        'context'     => array( 'view', 'edit', 'embed' ),
55
+        'readonly'    => true,
56
+    ),
57
+
58
+    'version'         => array(
59
+        'description' => __( 'Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing' ),
60
+        'type'        => 'integer',
61
+        'context'     => array( 'view', 'edit' ),
62
+        'readonly'    => true,
63
+    ),
64
+
65
+    'template'        => array(
66
+        'description' => __( 'The invoice template.', 'invoicing' ),
67
+        'type'        => 'string',
68
+        'default'     => 'quantity',
69
+        'enum'        => array( 'quantity', 'hours', 'amount' ),
70
+        'context'     => array( 'view', 'edit', 'embed' ),
71
+    ),
72
+
73
+    'status'          => array(
74
+        'description' => __( 'Invoice status.', 'invoicing' ),
75
+        'type'        => 'string',
76
+        'default'     => 'wpi-pending',
77
+        'enum'        => array_keys( wpinv_get_invoice_statuses( true ) ),
78
+        'context'     => array( 'view', 'edit', 'embed' ),
79
+    ),
80
+
81
+    'status_nicename' => array(
82
+        'description' => __( 'A human readable name for the invoice status.', 'invoicing' ),
83
+        'type'        => 'string',
84
+        'context'     => array( 'view', 'edit', 'embed' ),
85
+        'readonly'    => true,
86
+    ),
87
+
88
+    'currency'        => array(
89
+        'description' => __( 'The invoice currency in ISO format.', 'invoicing' ),
90
+        'type'        => 'string',
91
+        'default'     => wpinv_get_currency(),
92
+        'enum'        => array_keys( wpinv_get_currencies() ),
93
+        'context'     => array( 'view', 'edit', 'embed' ),
94
+    ),
95
+
96
+    'date_created'    => array(
97
+        'description' => __( "The date the invoice was created, in the site's timezone.", 'invoicing' ),
98
+        'type'        => 'string',
99
+        'context'     => array( 'view', 'edit', 'embed' ),
100
+    ),
101
+
102
+    'date_created_gmt'    => array(
103
+        'description' => __( 'The GMT date the invoice was created.', 'invoicing' ),
104
+        'type'        => 'string',
105
+        'context'     => array( 'view', 'edit', 'embed' ),
106
+        'readonly'    => true,
107
+    ),
108
+
109
+    'date_modified'   => array(
110
+        'description' => __( "The date the invoice was last modified, in the site's timezone.", 'invoicing' ),
111
+        'type'        => 'string',
112
+        'context'     => array( 'view', 'edit', 'embed' ),
113
+        'readonly'    => true,
114
+    ),
115
+
116
+    'date_modified_gmt'    => array(
117
+        'description' => __( 'The GMT date the invoice was last modified.', 'invoicing' ),
118
+        'type'        => 'string',
119
+        'context'     => array( 'view', 'edit', 'embed' ),
120
+        'readonly'    => true,
121
+    ),
122
+
123
+    'due_date'        => array(
124
+        'description' => __( "The invoice's due date, in the site's timezone.", 'invoicing' ),
125
+        'type'        => 'string',
126
+        'context'     => array( 'view', 'edit', 'embed' ),
127
+    ),
128
+
129
+    'due_date_gmt'    => array(
130
+        'description' => __( 'The GMT date the invoice is/was due.', 'invoicing' ),
131
+        'type'        => 'string',
132
+        'context'     => array( 'view', 'edit', 'embed' ),
133
+        'readonly'    => true,
134
+    ),
135
+
136
+    'completed_date'  => array(
137
+        'description' => __( "The date the invoice was paid, in the site's timezone.", 'invoicing' ),
138
+        'type'        => 'string',
139
+        'context'     => array( 'view', 'edit', 'embed' ),
140
+        'readonly'    => true,
141
+    ),
142
+
143
+    'completed_date_gmt'    => array(
144
+        'description' => __( 'The GMT date the invoice was paid.', 'invoicing' ),
145
+        'type'        => 'string',
146
+        'context'     => array( 'view', 'edit', 'embed' ),
147
+        'readonly'    => true,
148
+    ),
149
+
150
+    'total_discount'   => array(
151
+        'description' => __( 'Total discount amount for the invoice.', 'invoicing' ),
152
+        'type'        => 'number',
153
+        'context'     => array( 'view', 'edit', 'embed' ),
154
+        'readonly'    => true,
155
+    ),
156
+
157
+    'total_tax'       => array(
158
+        'description' => __( 'Total tax amount for the invoice.', 'invoicing' ),
159
+        'type'        => 'number',
160
+        'context'     => array( 'view', 'edit', 'embed' ),
161
+        'readonly'    => true,
162
+    ),
163
+
164
+    'total_fees'      => array(
165
+        'description' => __( 'Total fees amount for the invoice.', 'invoicing' ),
166
+        'type'        => 'number',
167
+        'context'     => array( 'view', 'edit', 'embed' ),
168
+        'readonly'    => true,
169
+    ),
170
+
171
+    'subtotal'        => array(
172
+        'description' => __( 'Invoice subtotal.', 'invoicing' ),
173
+        'type'        => 'number',
174
+        'context'     => array( 'view', 'edit', 'embed' ),
175
+        'readonly'    => true,
176
+    ),
177
+
178
+    'total'           => array(
179
+        'description' => __( 'Grand total.', 'invoicing' ),
180
+        'type'        => 'number',
181
+        'context'     => array( 'view', 'edit', 'embed' ),
182
+        'readonly'    => true,
183
+    ),
184
+
185
+    'initial_total'   => array(
186
+        'description' => __( 'Initial total (for recurring invoices).', 'invoicing' ),
187
+        'type'        => 'number',
188
+        'context'     => array( 'view', 'edit', 'embed' ),
189
+        'readonly'    => true,
190
+    ),
191
+
192
+    'recurring_total'  => array(
193
+        'description' => __( 'Recurring total (for recurring invoices).', 'invoicing' ),
194
+        'type'        => 'number',
195
+        'context'     => array( 'view', 'edit', 'embed' ),
196
+        'readonly'    => true,
197
+    ),
198
+
199
+    'totals'          => array(
200
+        'description' => __( 'Invoice totals.', 'invoicing' ),
201
+        'type'        => 'object',
202
+        'context'     => array( 'view', 'edit', 'embed' ),
203
+        'readonly'    => true,
204
+    ),
205
+
206
+    'fees'            => array(
207
+        'description' => __( 'Invoice fees (Name => properties).', 'invoicing' ),
208
+        'type'        => 'object',
209
+        'context'     => array( 'view', 'edit', 'embed' ),
210
+        'items'       => array(
211
+            'type'                => 'object',
212
+            'required'            => array( 'amount' ),
213
+            'properties'          => array(
214
+                'amount'          => array(
215
+                    'description' => __( 'Fee amount.', 'invoicing' ),
216
+                    'type'        => 'string',
217
+                    'context'     => array( 'view', 'edit', 'embed' ),
218
+                ),
219
+                'recurring'       => array(
220
+                    'description' => __( 'Whether this is a recurring or one-time fee.', 'invoicing' ),
221
+                    'type'        => array( 'boolean', 'integer' ),
222
+                    'context'     => array( 'view', 'edit', 'embed' ),
223
+                ),
224
+            ),
225
+        ),
226
+    ),
227
+
228
+    'discounts'       => array(
229
+        'description' => __( 'Invoice discounts (Name => properties).', 'invoicing' ),
230
+        'type'        => 'object',
231
+        'context'     => array( 'view', 'edit', 'embed' ),
232
+        'items'       => array(
233
+            'type'                => 'object',
234
+            'required'            => array( 'amount' ),
235
+            'properties'          => array(
236
+                'amount'          => array(
237
+                    'description' => __( 'Fee amount.', 'invoicing' ),
238
+                    'type'        => 'string',
239
+                    'context'     => array( 'view', 'edit', 'embed' ),
240
+                ),
241
+                'recurring'       => array(
242
+                    'description' => __( 'Whether this is a recurring or one-time discount.', 'invoicing' ),
243
+                    'type'        => array( 'boolean', 'integer' ),
244
+                    'context'     => array( 'view', 'edit', 'embed' ),
245
+                ),
246
+            ),
247
+        ),
248
+    ),
249
+
250
+    'taxes'           => array(
251
+        'description' => __( 'Invoice taxes (Name => properties).', 'invoicing' ),
252
+        'type'        => 'object',
253
+        'context'     => array( 'view', 'edit', 'embed' ),
254
+        'items'       => array(
255
+            'type'                => 'object',
256
+            'required'            => array( 'amount' ),
257
+            'properties'          => array(
258
+                'amount'          => array(
259
+                    'description' => __( 'Fee amount.', 'invoicing' ),
260
+                    'type'        => 'string',
261
+                    'context'     => array( 'view', 'edit', 'embed' ),
262
+                ),
263
+                'recurring'       => array(
264
+                    'description' => __( 'Whether this is a recurring or one-time tax.', 'invoicing' ),
265
+                    'type'        => array( 'boolean', 'integer' ),
266
+                    'context'     => array( 'view', 'edit', 'embed' ),
267
+                ),
268
+            ),
269
+        ),
270
+    ),
271
+
272
+    'items'           => array(
273
+        'description' => __( 'Invoice items.', 'invoicing' ),
274
+        'type'        => 'array',
275
+        'context'     => array( 'view', 'edit', 'embed' ),
276
+        'items'       => array(
277
+            'type'                => 'object',
278
+            'required'            => array( 'item_id' ),
279
+            'properties'          => array(
280
+                'item_id'         => array(
281
+                    'description' => __( 'Item ID.', 'invoicing' ),
282
+                    'type'        => 'integer',
283
+                    'context'     => array( 'view', 'edit', 'embed' ),
284
+                ),
285
+                'item_name'       => array(
286
+                    'description' => __( 'Item Name.', 'invoicing' ),
287
+                    'type'        => 'string',
288
+                    'context'     => array( 'view', 'edit', 'embed' ),
289
+                ),
290
+                'item_description' => array(
291
+                    'description'  => __( 'Item Description.', 'invoicing' ),
292
+                    'type'         => 'string',
293
+                    'context'      => array( 'view', 'edit', 'embed' ),
294
+                ),
295
+                'item_price'      => array(
296
+                    'description' => __( 'Item Price.', 'invoicing' ),
297
+                    'type'        => 'number',
298
+                    'context'     => array( 'view', 'edit', 'embed' ),
299
+                ),
300
+                'quantity'        => array(
301
+                    'description' => __( 'Item Quantity.', 'invoicing' ),
302
+                    'type'        => 'number',
303
+                    'context'     => array( 'view', 'edit', 'embed' ),
304
+                ),
305
+                'subtotal'        => array(
306
+                    'description' => __( 'Item Subtotal.', 'invoicing' ),
307
+                    'type'        => 'number',
308
+                    'context'     => array( 'view', 'edit', 'embed' ),
309
+                    'readonly'    => true,
310
+                ),
311
+                'meta'            => array(
312
+                    'description' => __( 'Item Meta.', 'invoicing' ),
313
+                    'type'        => 'object',
314
+                    'context'     => array( 'view', 'edit', 'embed' ),
315
+                ),
316
+            ),
317
+        ),
318
+    ),
319
+
320
+    'mode'			  => array(
321
+        'description' => __( 'The invoice transaction mode.', 'invoicing' ),
322
+        'type'        => 'string',
323
+        'context'     => array( 'view', 'edit', 'embed' ),
324
+        'enum'        => array( 'live', 'test' ),
325
+        'readonly'    => true,
326
+    ),
327 327
 	
328
-	'discount_code'   => array(
329
-		'description' => __( 'The discount code used on this invoice.', 'invoicing' ),
330
-		'type'        => 'string',
331
-		'context'     => array( 'view', 'edit', 'embed' ),
332
-	),
333
-
334
-	'gateway'         => array(
335
-		'description' => __( 'The gateway used to pay this invoice.', 'invoicing' ),
336
-		'type'        => 'string',
337
-		'context'     => array( 'view', 'edit', 'embed' ),
338
-	),
339
-
340
-	'gateway_title'   => array(
341
-		'description' => __( 'The title of the gateway used to pay this invoice.', 'invoicing' ),
342
-		'type'        => 'string',
343
-		'context'     => array( 'view', 'edit', 'embed' ),
344
-		'readonly'    => true,
345
-	),
346
-
347
-	'transaction_id'  => array(
348
-		'description' => __( 'The transaction id for this invoice.', 'invoicing' ),
349
-		'type'        => 'string',
350
-		'context'     => array( 'view', 'edit', 'embed' ),
351
-	),
328
+    'discount_code'   => array(
329
+        'description' => __( 'The discount code used on this invoice.', 'invoicing' ),
330
+        'type'        => 'string',
331
+        'context'     => array( 'view', 'edit', 'embed' ),
332
+    ),
333
+
334
+    'gateway'         => array(
335
+        'description' => __( 'The gateway used to pay this invoice.', 'invoicing' ),
336
+        'type'        => 'string',
337
+        'context'     => array( 'view', 'edit', 'embed' ),
338
+    ),
339
+
340
+    'gateway_title'   => array(
341
+        'description' => __( 'The title of the gateway used to pay this invoice.', 'invoicing' ),
342
+        'type'        => 'string',
343
+        'context'     => array( 'view', 'edit', 'embed' ),
344
+        'readonly'    => true,
345
+    ),
346
+
347
+    'transaction_id'  => array(
348
+        'description' => __( 'The transaction id for this invoice.', 'invoicing' ),
349
+        'type'        => 'string',
350
+        'context'     => array( 'view', 'edit', 'embed' ),
351
+    ),
352 352
 	
353
-	'disable_taxes'   => array(
354
-		'description' => __( 'Whether or not taxes should be disabled for this invoice.', 'invoicing' ),
355
-		'type'        => 'boolean ',
356
-		'context'     => array( 'view', 'edit', 'embed' ),
357
-	),
358
-
359
-	'is_viewed'       => array(
360
-		'description' => __( 'Whether or not this invoice has been viewed by the user.', 'invoicing' ),
361
-		'type'        => 'boolean ',
362
-		'context'     => array( 'view', 'edit', 'embed' ),
363
-		'readonly'    => true,
364
-	),
365
-
366
-	'email_cc'        => array(
367
-		'description' => __( 'A comma separated list of other emails that should receive communications for this invoice.', 'invoicing' ),
368
-		'type'        => 'string ',
369
-		'context'     => array( 'view', 'edit' ),
370
-	),
371
-
372
-	'subscription_id' => array(
373
-		'description' => __( 'The ID of the subscription associated with this invoice.', 'invoicing' ),
374
-		'type'        => 'string ',
375
-		'context'     => array( 'view', 'edit', 'embed' ),
376
-		'readonly'    => true,
377
-	),
378
-
379
-	'subscription_name' => array(
380
-		'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ),
381
-		'type'        => 'string ',
382
-		'context'     => array( 'view', 'edit', 'embed' ),
383
-		'readonly'    => true,
384
-	),
385
-
386
-	'subscription_name' => array(
387
-		'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ),
388
-		'type'        => 'string ',
389
-		'context'     => array( 'view', 'edit', 'embed' ),
390
-		'readonly'    => true,
391
-	),
392
-
393
-	'is_parent'		  => array(
394
-		'description' => __( 'Whether or not this is a parent invoice.', 'invoicing' ),
395
-		'type'        => 'boolean',
396
-		'context'     => array( 'view', 'edit', 'embed' ),
397
-		'readonly'    => true,
398
-	),
399
-
400
-	'is_renewal'      => array(
401
-		'description' => __( 'Whether or not this is a renewal invoice.', 'invoicing' ),
402
-		'type'        => 'boolean',
403
-		'context'     => array( 'view', 'edit', 'embed' ),
404
-		'readonly'    => true,
405
-	),
406
-
407
-	'is_recurring'    => array(
408
-		'description' => __( 'Whether or not this is a recurring invoice.', 'invoicing' ),
409
-		'type'        => 'boolean',
410
-		'context'     => array( 'view', 'edit', 'embed' ),
411
-		'readonly'    => true,
412
-	),
413
-
414
-	'is_free'         => array(
415
-		'description' => __( 'Whether or not this invoice is free.', 'invoicing' ),
416
-		'type'        => 'boolean',
417
-		'context'     => array( 'view', 'edit', 'embed' ),
418
-		'readonly'    => true,
419
-	),
420
-
421
-	'is_paid'         => array(
422
-		'description' => __( 'Whether or not this invoice has been paid.', 'invoicing' ),
423
-		'type'        => 'boolean',
424
-		'context'     => array( 'view', 'edit', 'embed' ),
425
-		'readonly'    => true,
426
-	),
427
-
428
-	'needs_payment'   => array(
429
-		'description' => __( 'Whether or not this invoice needs payment.', 'invoicing' ),
430
-		'type'        => 'boolean',
431
-		'context'     => array( 'view', 'edit', 'embed' ),
432
-		'readonly'    => true,
433
-	),
434
-
435
-	'is_refunded'     => array(
436
-		'description' => __( 'Whether or not this invoice was refunded.', 'invoicing' ),
437
-		'type'        => 'boolean',
438
-		'context'     => array( 'view', 'edit', 'embed' ),
439
-		'readonly'    => true,
440
-	),
441
-
442
-	'is_due'          => array(
443
-		'description' => __( 'Whether or not this invoice is due.', 'invoicing' ),
444
-		'type'        => 'boolean',
445
-		'context'     => array( 'view', 'edit', 'embed' ),
446
-		'readonly'    => true,
447
-	),
448
-
449
-	'is_held'         => array(
450
-		'description' => __( 'Whether or not this invoice has been held for payment confirmation.', 'invoicing' ),
451
-		'type'        => 'boolean',
452
-		'context'     => array( 'view', 'edit', 'embed' ),
453
-		'readonly'    => true,
454
-	),
455
-
456
-	'is_draft'        => array(
457
-		'description' => __( 'Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing' ),
458
-		'type'        => 'boolean',
459
-		'context'     => array( 'view', 'edit', 'embed' ),
460
-		'readonly'    => true,
461
-	),
462
-
463
-	'path'			  => array(
464
-		'description' => __( 'The invoice path/slug/name.', 'invoicing' ),
465
-		'type'        => 'string',
466
-		'context'     => array( 'view', 'edit', 'embed' ),
467
-		'readonly'    => true,
468
-	),
469
-
470
-	'description'     => array(
471
-		'description' => __( 'The invoice description.', 'invoicing' ),
472
-		'type'        => 'string',
473
-		'context'     => array( 'view', 'edit', 'embed' ),
474
-	),
475
-
476
-	'payment_form'    => array(
477
-		'description' => __( 'The id of the payment form used to pay for this invoice.', 'invoicing' ),
478
-		'type'        => 'integer',
479
-		'context'     => array( 'view', 'edit' ),
480
-		'readonly'    => true,
481
-	),
482
-
483
-	'submission_id'   => array(
484
-		'description' => __( 'A uniques ID of the submission details used to pay for this invoice.', 'invoicing' ),
485
-		'type'        => 'string',
486
-		'context'     => array( 'view', 'edit' ),
487
-		'readonly'    => true,
488
-	),
489
-
490
-	'customer_id'     => array(
491
-		'description' => __( 'The customer id.', 'invoicing' ),
492
-		'type'        => 'integer',
493
-		'context'     => array( 'view', 'edit', 'embed' ),
494
-	),
495
-
496
-	'customer_ip'     => array(
497
-		'description' => __( "The customer's ip address.", 'invoicing' ),
498
-		'type'        => 'string',
499
-		'format'      => 'ip',
500
-		'context'     => array( 'view', 'edit', 'embed' ),
501
-	),
502
-
503
-	'first_name'     => array(
504
-		'description' => __( "The customer's first name.", 'invoicing' ),
505
-		'type'        => 'string',
506
-		'context'     => array( 'view', 'edit', 'embed' ),
507
-	),
508
-
509
-	'last_name'       => array(
510
-		'description' => __( "The customer's last name.", 'invoicing' ),
511
-		'type'        => 'string',
512
-		'context'     => array( 'view', 'edit', 'embed' ),
513
-	),
353
+    'disable_taxes'   => array(
354
+        'description' => __( 'Whether or not taxes should be disabled for this invoice.', 'invoicing' ),
355
+        'type'        => 'boolean ',
356
+        'context'     => array( 'view', 'edit', 'embed' ),
357
+    ),
358
+
359
+    'is_viewed'       => array(
360
+        'description' => __( 'Whether or not this invoice has been viewed by the user.', 'invoicing' ),
361
+        'type'        => 'boolean ',
362
+        'context'     => array( 'view', 'edit', 'embed' ),
363
+        'readonly'    => true,
364
+    ),
365
+
366
+    'email_cc'        => array(
367
+        'description' => __( 'A comma separated list of other emails that should receive communications for this invoice.', 'invoicing' ),
368
+        'type'        => 'string ',
369
+        'context'     => array( 'view', 'edit' ),
370
+    ),
371
+
372
+    'subscription_id' => array(
373
+        'description' => __( 'The ID of the subscription associated with this invoice.', 'invoicing' ),
374
+        'type'        => 'string ',
375
+        'context'     => array( 'view', 'edit', 'embed' ),
376
+        'readonly'    => true,
377
+    ),
378
+
379
+    'subscription_name' => array(
380
+        'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ),
381
+        'type'        => 'string ',
382
+        'context'     => array( 'view', 'edit', 'embed' ),
383
+        'readonly'    => true,
384
+    ),
385
+
386
+    'subscription_name' => array(
387
+        'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ),
388
+        'type'        => 'string ',
389
+        'context'     => array( 'view', 'edit', 'embed' ),
390
+        'readonly'    => true,
391
+    ),
392
+
393
+    'is_parent'		  => array(
394
+        'description' => __( 'Whether or not this is a parent invoice.', 'invoicing' ),
395
+        'type'        => 'boolean',
396
+        'context'     => array( 'view', 'edit', 'embed' ),
397
+        'readonly'    => true,
398
+    ),
399
+
400
+    'is_renewal'      => array(
401
+        'description' => __( 'Whether or not this is a renewal invoice.', 'invoicing' ),
402
+        'type'        => 'boolean',
403
+        'context'     => array( 'view', 'edit', 'embed' ),
404
+        'readonly'    => true,
405
+    ),
406
+
407
+    'is_recurring'    => array(
408
+        'description' => __( 'Whether or not this is a recurring invoice.', 'invoicing' ),
409
+        'type'        => 'boolean',
410
+        'context'     => array( 'view', 'edit', 'embed' ),
411
+        'readonly'    => true,
412
+    ),
413
+
414
+    'is_free'         => array(
415
+        'description' => __( 'Whether or not this invoice is free.', 'invoicing' ),
416
+        'type'        => 'boolean',
417
+        'context'     => array( 'view', 'edit', 'embed' ),
418
+        'readonly'    => true,
419
+    ),
420
+
421
+    'is_paid'         => array(
422
+        'description' => __( 'Whether or not this invoice has been paid.', 'invoicing' ),
423
+        'type'        => 'boolean',
424
+        'context'     => array( 'view', 'edit', 'embed' ),
425
+        'readonly'    => true,
426
+    ),
427
+
428
+    'needs_payment'   => array(
429
+        'description' => __( 'Whether or not this invoice needs payment.', 'invoicing' ),
430
+        'type'        => 'boolean',
431
+        'context'     => array( 'view', 'edit', 'embed' ),
432
+        'readonly'    => true,
433
+    ),
434
+
435
+    'is_refunded'     => array(
436
+        'description' => __( 'Whether or not this invoice was refunded.', 'invoicing' ),
437
+        'type'        => 'boolean',
438
+        'context'     => array( 'view', 'edit', 'embed' ),
439
+        'readonly'    => true,
440
+    ),
441
+
442
+    'is_due'          => array(
443
+        'description' => __( 'Whether or not this invoice is due.', 'invoicing' ),
444
+        'type'        => 'boolean',
445
+        'context'     => array( 'view', 'edit', 'embed' ),
446
+        'readonly'    => true,
447
+    ),
448
+
449
+    'is_held'         => array(
450
+        'description' => __( 'Whether or not this invoice has been held for payment confirmation.', 'invoicing' ),
451
+        'type'        => 'boolean',
452
+        'context'     => array( 'view', 'edit', 'embed' ),
453
+        'readonly'    => true,
454
+    ),
455
+
456
+    'is_draft'        => array(
457
+        'description' => __( 'Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing' ),
458
+        'type'        => 'boolean',
459
+        'context'     => array( 'view', 'edit', 'embed' ),
460
+        'readonly'    => true,
461
+    ),
462
+
463
+    'path'			  => array(
464
+        'description' => __( 'The invoice path/slug/name.', 'invoicing' ),
465
+        'type'        => 'string',
466
+        'context'     => array( 'view', 'edit', 'embed' ),
467
+        'readonly'    => true,
468
+    ),
469
+
470
+    'description'     => array(
471
+        'description' => __( 'The invoice description.', 'invoicing' ),
472
+        'type'        => 'string',
473
+        'context'     => array( 'view', 'edit', 'embed' ),
474
+    ),
475
+
476
+    'payment_form'    => array(
477
+        'description' => __( 'The id of the payment form used to pay for this invoice.', 'invoicing' ),
478
+        'type'        => 'integer',
479
+        'context'     => array( 'view', 'edit' ),
480
+        'readonly'    => true,
481
+    ),
482
+
483
+    'submission_id'   => array(
484
+        'description' => __( 'A uniques ID of the submission details used to pay for this invoice.', 'invoicing' ),
485
+        'type'        => 'string',
486
+        'context'     => array( 'view', 'edit' ),
487
+        'readonly'    => true,
488
+    ),
489
+
490
+    'customer_id'     => array(
491
+        'description' => __( 'The customer id.', 'invoicing' ),
492
+        'type'        => 'integer',
493
+        'context'     => array( 'view', 'edit', 'embed' ),
494
+    ),
495
+
496
+    'customer_ip'     => array(
497
+        'description' => __( "The customer's ip address.", 'invoicing' ),
498
+        'type'        => 'string',
499
+        'format'      => 'ip',
500
+        'context'     => array( 'view', 'edit', 'embed' ),
501
+    ),
502
+
503
+    'first_name'     => array(
504
+        'description' => __( "The customer's first name.", 'invoicing' ),
505
+        'type'        => 'string',
506
+        'context'     => array( 'view', 'edit', 'embed' ),
507
+    ),
508
+
509
+    'last_name'       => array(
510
+        'description' => __( "The customer's last name.", 'invoicing' ),
511
+        'type'        => 'string',
512
+        'context'     => array( 'view', 'edit', 'embed' ),
513
+    ),
514 514
 	
515
-	'full_name'       => array(
516
-		'description' => __( "The customer's full name.", 'invoicing' ),
517
-		'type'        => 'string',
518
-		'context'     => array( 'view', 'edit', 'embed' ),
519
-		'readonly'    => true,
520
-	),
521
-
522
-	'phone_number'    => array(
523
-		'description' => __( "The customer's phone number.", 'invoicing' ),
524
-		'type'        => 'string',
525
-		'context'     => array( 'view', 'edit', 'embed' ),
526
-	),
527
-
528
-	'email_address'   => array(
529
-		'description' => __( "The customer's email address.", 'invoicing' ),
530
-		'type'        => 'string',
531
-		'context'     => array( 'view', 'edit', 'embed' ),
532
-		'readonly'    => true,
533
-	),
534
-
535
-	'customer_country'   => array(
536
-		'description'    => __( "The customer's country.", 'invoicing' ),
537
-		'type'           => 'string',
538
-		'context'        => array( 'view', 'edit', 'embed' ),
539
-		'default'        => wpinv_get_default_country(),
540
-	),
541
-
542
-	'customer_state'     => array(
543
-		'description'    => __( "The customer's state.", 'invoicing' ),
544
-		'type'           => 'string',
545
-		'context'        => array( 'view', 'edit', 'embed' ),
546
-	),
547
-
548
-	'customer_city'      => array(
549
-		'description'    => __( "The customer's city.", 'invoicing' ),
550
-		'type'           => 'string',
551
-		'context'        => array( 'view', 'edit', 'embed' ),
552
-	),
553
-
554
-	'customer_zip'       => array(
555
-		'description'    => __( "The customer's zip/postal code.", 'invoicing' ),
556
-		'type'           => 'string',
557
-		'context'        => array( 'view', 'edit', 'embed' ),
558
-	),
559
-
560
-	'customer_company'   => array(
561
-		'description'    => __( "The customer's company name.", 'invoicing' ),
562
-		'type'           => 'string',
563
-		'context'        => array( 'view', 'edit', 'embed' ),
564
-	),
565
-
566
-	'vat_number'         => array(
567
-		'description'    => __( "The customer's VAT number.", 'invoicing' ),
568
-		'type'           => 'string',
569
-		'context'        => array( 'view', 'edit', 'embed' ),
570
-	),
571
-
572
-	'vat_rate'           => array(
573
-		'description'    => __( "The customer's VAT rate.", 'invoicing' ),
574
-		'type'           => 'number',
575
-		'context'        => array( 'view', 'edit', 'embed' ),
576
-		'readonly'       => true,
577
-	),
578
-
579
-	'customer_address'   => array(
580
-		'description'    => __( "The customer's address.", 'invoicing' ),
581
-		'type'           => 'string',
582
-		'context'        => array( 'view', 'edit', 'embed' ),
583
-	),
584
-
585
-	'address_confirmed'  => array(
586
-		'description'    => __( "Whether or not the customer's address is confirmed.", 'invoicing' ),
587
-		'type'           => 'boolean',
588
-		'context'        => array( 'view', 'edit', 'embed' ),
589
-	),
590
-
591
-	'meta_data'       => array(
592
-		'description' => __( 'Invoice meta data.', 'invoicing' ),
593
-		'type'        => 'array',
594
-		'context'     => array( 'view', 'edit', 'embed' ),
595
-		'items'       => array(
596
-			'type'                => 'object',
597
-			'properties'          => array(
598
-				'id'              => array(
599
-					'description' => __( 'Meta ID.', 'invoicing' ),
600
-					'type'        => 'string',
601
-					'context'     => array( 'view', 'edit', 'embed' ),
602
-				),
603
-				'key'             => array(
604
-					'description' => __( 'Meta key.', 'invoicing' ),
605
-					'type'        => 'string',
606
-					'context'     => array( 'view', 'edit', 'embed' ),
607
-				),
608
-				'value'           => array(
609
-					'description' => __( 'Meta Value.', 'invoicing' ),
610
-					'type'        => array( 'string', 'array', 'object', 'integer', 'null' ),
611
-					'context'     => array( 'view', 'edit', 'embed' ),
612
-				),
613
-			),
614
-		),
615
-	),
616
-
617
-	'view_url'        => array(
618
-		'description' => __( 'URL to the invoice.', 'invoicing' ),
619
-		'type'        => 'string',
620
-		'format'      => 'uri',
621
-		'context'     => array( 'view', 'edit', 'embed' ),
622
-		'readonly'    => true,
623
-	),
624
-
625
-	'checkout_payment_url'         => array(
626
-		'description' => __( 'URL to the invoice checkout page.', 'invoicing' ),
627
-		'type'        => 'string',
628
-		'format'      => 'uri',
629
-		'context'     => array( 'view', 'edit', 'embed' ),
630
-		'readonly'    => true,
631
-	),
632
-
633
-	'receipt_url'     => array(
634
-		'description' => __( 'URL to the invoice receipt page.', 'invoicing' ),
635
-		'type'        => 'string',
636
-		'format'      => 'uri',
637
-		'context'     => array( 'view', 'edit', 'embed' ),
638
-		'readonly'    => true,
639
-	),
515
+    'full_name'       => array(
516
+        'description' => __( "The customer's full name.", 'invoicing' ),
517
+        'type'        => 'string',
518
+        'context'     => array( 'view', 'edit', 'embed' ),
519
+        'readonly'    => true,
520
+    ),
521
+
522
+    'phone_number'    => array(
523
+        'description' => __( "The customer's phone number.", 'invoicing' ),
524
+        'type'        => 'string',
525
+        'context'     => array( 'view', 'edit', 'embed' ),
526
+    ),
527
+
528
+    'email_address'   => array(
529
+        'description' => __( "The customer's email address.", 'invoicing' ),
530
+        'type'        => 'string',
531
+        'context'     => array( 'view', 'edit', 'embed' ),
532
+        'readonly'    => true,
533
+    ),
534
+
535
+    'customer_country'   => array(
536
+        'description'    => __( "The customer's country.", 'invoicing' ),
537
+        'type'           => 'string',
538
+        'context'        => array( 'view', 'edit', 'embed' ),
539
+        'default'        => wpinv_get_default_country(),
540
+    ),
541
+
542
+    'customer_state'     => array(
543
+        'description'    => __( "The customer's state.", 'invoicing' ),
544
+        'type'           => 'string',
545
+        'context'        => array( 'view', 'edit', 'embed' ),
546
+    ),
547
+
548
+    'customer_city'      => array(
549
+        'description'    => __( "The customer's city.", 'invoicing' ),
550
+        'type'           => 'string',
551
+        'context'        => array( 'view', 'edit', 'embed' ),
552
+    ),
553
+
554
+    'customer_zip'       => array(
555
+        'description'    => __( "The customer's zip/postal code.", 'invoicing' ),
556
+        'type'           => 'string',
557
+        'context'        => array( 'view', 'edit', 'embed' ),
558
+    ),
559
+
560
+    'customer_company'   => array(
561
+        'description'    => __( "The customer's company name.", 'invoicing' ),
562
+        'type'           => 'string',
563
+        'context'        => array( 'view', 'edit', 'embed' ),
564
+    ),
565
+
566
+    'vat_number'         => array(
567
+        'description'    => __( "The customer's VAT number.", 'invoicing' ),
568
+        'type'           => 'string',
569
+        'context'        => array( 'view', 'edit', 'embed' ),
570
+    ),
571
+
572
+    'vat_rate'           => array(
573
+        'description'    => __( "The customer's VAT rate.", 'invoicing' ),
574
+        'type'           => 'number',
575
+        'context'        => array( 'view', 'edit', 'embed' ),
576
+        'readonly'       => true,
577
+    ),
578
+
579
+    'customer_address'   => array(
580
+        'description'    => __( "The customer's address.", 'invoicing' ),
581
+        'type'           => 'string',
582
+        'context'        => array( 'view', 'edit', 'embed' ),
583
+    ),
584
+
585
+    'address_confirmed'  => array(
586
+        'description'    => __( "Whether or not the customer's address is confirmed.", 'invoicing' ),
587
+        'type'           => 'boolean',
588
+        'context'        => array( 'view', 'edit', 'embed' ),
589
+    ),
590
+
591
+    'meta_data'       => array(
592
+        'description' => __( 'Invoice meta data.', 'invoicing' ),
593
+        'type'        => 'array',
594
+        'context'     => array( 'view', 'edit', 'embed' ),
595
+        'items'       => array(
596
+            'type'                => 'object',
597
+            'properties'          => array(
598
+                'id'              => array(
599
+                    'description' => __( 'Meta ID.', 'invoicing' ),
600
+                    'type'        => 'string',
601
+                    'context'     => array( 'view', 'edit', 'embed' ),
602
+                ),
603
+                'key'             => array(
604
+                    'description' => __( 'Meta key.', 'invoicing' ),
605
+                    'type'        => 'string',
606
+                    'context'     => array( 'view', 'edit', 'embed' ),
607
+                ),
608
+                'value'           => array(
609
+                    'description' => __( 'Meta Value.', 'invoicing' ),
610
+                    'type'        => array( 'string', 'array', 'object', 'integer', 'null' ),
611
+                    'context'     => array( 'view', 'edit', 'embed' ),
612
+                ),
613
+            ),
614
+        ),
615
+    ),
616
+
617
+    'view_url'        => array(
618
+        'description' => __( 'URL to the invoice.', 'invoicing' ),
619
+        'type'        => 'string',
620
+        'format'      => 'uri',
621
+        'context'     => array( 'view', 'edit', 'embed' ),
622
+        'readonly'    => true,
623
+    ),
624
+
625
+    'checkout_payment_url'         => array(
626
+        'description' => __( 'URL to the invoice checkout page.', 'invoicing' ),
627
+        'type'        => 'string',
628
+        'format'      => 'uri',
629
+        'context'     => array( 'view', 'edit', 'embed' ),
630
+        'readonly'    => true,
631
+    ),
632
+
633
+    'receipt_url'     => array(
634
+        'description' => __( 'URL to the invoice receipt page.', 'invoicing' ),
635
+        'type'        => 'string',
636
+        'format'      => 'uri',
637
+        'context'     => array( 'view', 'edit', 'embed' ),
638
+        'readonly'    => true,
639
+    ),
640 640
 
641 641
 );
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -9,632 +9,632 @@
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
 	'id'              => array(
17
-		'description' => __( 'Unique identifier for the invoice.', 'invoicing' ),
17
+		'description' => __('Unique identifier for the invoice.', 'invoicing'),
18 18
 		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
19
+		'context'     => array('view', 'edit', 'embed'),
20 20
 		'readonly'    => true,
21 21
 	),
22 22
 
23 23
 	'parent_id'       => array(
24
-		'description' => __( 'Parent invoice ID.', 'invoicing' ),
24
+		'description' => __('Parent invoice ID.', 'invoicing'),
25 25
 		'type'        => 'integer',
26 26
 		'minimum'     => 0,
27 27
 		'default'     => 0,
28
-		'context'     => array( 'view', 'edit' ),
28
+		'context'     => array('view', 'edit'),
29 29
 	),
30 30
 
31 31
 	'key'			  => array(
32
-		'description' => __( 'A unique key for the invoice.', 'invoicing' ),
32
+		'description' => __('A unique key for the invoice.', 'invoicing'),
33 33
 		'type'        => 'string',
34
-		'context'     => array( 'view', 'edit' ),
34
+		'context'     => array('view', 'edit'),
35 35
 		'readonly'    => true,
36 36
 	),
37 37
 
38 38
 	'number'		  => array(
39
-		'description' => __( 'A unique number for the invoice.', 'invoicing' ),
39
+		'description' => __('A unique number for the invoice.', 'invoicing'),
40 40
 		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit', 'embed' ),
41
+		'context'     => array('view', 'edit', 'embed'),
42 42
 	),
43 43
 
44 44
 	'type'			  => array(
45
-		'description' => __( 'Get the invoice type (e.g invoice, quote etc).', 'invoicing' ),
45
+		'description' => __('Get the invoice type (e.g invoice, quote etc).', 'invoicing'),
46 46
 		'type'        => 'string',
47
-		'context'     => array( 'view', 'edit', 'embed' ),
47
+		'context'     => array('view', 'edit', 'embed'),
48 48
 		'readonly'    => true,
49 49
 	),
50 50
 
51 51
 	'post_type'		  => array(
52
-		'description' => __( 'Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing' ),
52
+		'description' => __('Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing'),
53 53
 		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
54
+		'context'     => array('view', 'edit', 'embed'),
55 55
 		'readonly'    => true,
56 56
 	),
57 57
 
58 58
 	'version'         => array(
59
-		'description' => __( 'Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing' ),
59
+		'description' => __('Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing'),
60 60
 		'type'        => 'integer',
61
-		'context'     => array( 'view', 'edit' ),
61
+		'context'     => array('view', 'edit'),
62 62
 		'readonly'    => true,
63 63
 	),
64 64
 
65 65
 	'template'        => array(
66
-		'description' => __( 'The invoice template.', 'invoicing' ),
66
+		'description' => __('The invoice template.', 'invoicing'),
67 67
 		'type'        => 'string',
68 68
 		'default'     => 'quantity',
69
-		'enum'        => array( 'quantity', 'hours', 'amount' ),
70
-		'context'     => array( 'view', 'edit', 'embed' ),
69
+		'enum'        => array('quantity', 'hours', 'amount'),
70
+		'context'     => array('view', 'edit', 'embed'),
71 71
 	),
72 72
 
73 73
 	'status'          => array(
74
-		'description' => __( 'Invoice status.', 'invoicing' ),
74
+		'description' => __('Invoice status.', 'invoicing'),
75 75
 		'type'        => 'string',
76 76
 		'default'     => 'wpi-pending',
77
-		'enum'        => array_keys( wpinv_get_invoice_statuses( true ) ),
78
-		'context'     => array( 'view', 'edit', 'embed' ),
77
+		'enum'        => array_keys(wpinv_get_invoice_statuses(true)),
78
+		'context'     => array('view', 'edit', 'embed'),
79 79
 	),
80 80
 
81 81
 	'status_nicename' => array(
82
-		'description' => __( 'A human readable name for the invoice status.', 'invoicing' ),
82
+		'description' => __('A human readable name for the invoice status.', 'invoicing'),
83 83
 		'type'        => 'string',
84
-		'context'     => array( 'view', 'edit', 'embed' ),
84
+		'context'     => array('view', 'edit', 'embed'),
85 85
 		'readonly'    => true,
86 86
 	),
87 87
 
88 88
 	'currency'        => array(
89
-		'description' => __( 'The invoice currency in ISO format.', 'invoicing' ),
89
+		'description' => __('The invoice currency in ISO format.', 'invoicing'),
90 90
 		'type'        => 'string',
91 91
 		'default'     => wpinv_get_currency(),
92
-		'enum'        => array_keys( wpinv_get_currencies() ),
93
-		'context'     => array( 'view', 'edit', 'embed' ),
92
+		'enum'        => array_keys(wpinv_get_currencies()),
93
+		'context'     => array('view', 'edit', 'embed'),
94 94
 	),
95 95
 
96 96
 	'date_created'    => array(
97
-		'description' => __( "The date the invoice was created, in the site's timezone.", 'invoicing' ),
97
+		'description' => __("The date the invoice was created, in the site's timezone.", 'invoicing'),
98 98
 		'type'        => 'string',
99
-		'context'     => array( 'view', 'edit', 'embed' ),
99
+		'context'     => array('view', 'edit', 'embed'),
100 100
 	),
101 101
 
102 102
 	'date_created_gmt'    => array(
103
-		'description' => __( 'The GMT date the invoice was created.', 'invoicing' ),
103
+		'description' => __('The GMT date the invoice was created.', 'invoicing'),
104 104
 		'type'        => 'string',
105
-		'context'     => array( 'view', 'edit', 'embed' ),
105
+		'context'     => array('view', 'edit', 'embed'),
106 106
 		'readonly'    => true,
107 107
 	),
108 108
 
109 109
 	'date_modified'   => array(
110
-		'description' => __( "The date the invoice was last modified, in the site's timezone.", 'invoicing' ),
110
+		'description' => __("The date the invoice was last modified, in the site's timezone.", 'invoicing'),
111 111
 		'type'        => 'string',
112
-		'context'     => array( 'view', 'edit', 'embed' ),
112
+		'context'     => array('view', 'edit', 'embed'),
113 113
 		'readonly'    => true,
114 114
 	),
115 115
 
116 116
 	'date_modified_gmt'    => array(
117
-		'description' => __( 'The GMT date the invoice was last modified.', 'invoicing' ),
117
+		'description' => __('The GMT date the invoice was last modified.', 'invoicing'),
118 118
 		'type'        => 'string',
119
-		'context'     => array( 'view', 'edit', 'embed' ),
119
+		'context'     => array('view', 'edit', 'embed'),
120 120
 		'readonly'    => true,
121 121
 	),
122 122
 
123 123
 	'due_date'        => array(
124
-		'description' => __( "The invoice's due date, in the site's timezone.", 'invoicing' ),
124
+		'description' => __("The invoice's due date, in the site's timezone.", 'invoicing'),
125 125
 		'type'        => 'string',
126
-		'context'     => array( 'view', 'edit', 'embed' ),
126
+		'context'     => array('view', 'edit', 'embed'),
127 127
 	),
128 128
 
129 129
 	'due_date_gmt'    => array(
130
-		'description' => __( 'The GMT date the invoice is/was due.', 'invoicing' ),
130
+		'description' => __('The GMT date the invoice is/was due.', 'invoicing'),
131 131
 		'type'        => 'string',
132
-		'context'     => array( 'view', 'edit', 'embed' ),
132
+		'context'     => array('view', 'edit', 'embed'),
133 133
 		'readonly'    => true,
134 134
 	),
135 135
 
136 136
 	'completed_date'  => array(
137
-		'description' => __( "The date the invoice was paid, in the site's timezone.", 'invoicing' ),
137
+		'description' => __("The date the invoice was paid, in the site's timezone.", 'invoicing'),
138 138
 		'type'        => 'string',
139
-		'context'     => array( 'view', 'edit', 'embed' ),
139
+		'context'     => array('view', 'edit', 'embed'),
140 140
 		'readonly'    => true,
141 141
 	),
142 142
 
143 143
 	'completed_date_gmt'    => array(
144
-		'description' => __( 'The GMT date the invoice was paid.', 'invoicing' ),
144
+		'description' => __('The GMT date the invoice was paid.', 'invoicing'),
145 145
 		'type'        => 'string',
146
-		'context'     => array( 'view', 'edit', 'embed' ),
146
+		'context'     => array('view', 'edit', 'embed'),
147 147
 		'readonly'    => true,
148 148
 	),
149 149
 
150 150
 	'total_discount'   => array(
151
-		'description' => __( 'Total discount amount for the invoice.', 'invoicing' ),
151
+		'description' => __('Total discount amount for the invoice.', 'invoicing'),
152 152
 		'type'        => 'number',
153
-		'context'     => array( 'view', 'edit', 'embed' ),
153
+		'context'     => array('view', 'edit', 'embed'),
154 154
 		'readonly'    => true,
155 155
 	),
156 156
 
157 157
 	'total_tax'       => array(
158
-		'description' => __( 'Total tax amount for the invoice.', 'invoicing' ),
158
+		'description' => __('Total tax amount for the invoice.', 'invoicing'),
159 159
 		'type'        => 'number',
160
-		'context'     => array( 'view', 'edit', 'embed' ),
160
+		'context'     => array('view', 'edit', 'embed'),
161 161
 		'readonly'    => true,
162 162
 	),
163 163
 
164 164
 	'total_fees'      => array(
165
-		'description' => __( 'Total fees amount for the invoice.', 'invoicing' ),
165
+		'description' => __('Total fees amount for the invoice.', 'invoicing'),
166 166
 		'type'        => 'number',
167
-		'context'     => array( 'view', 'edit', 'embed' ),
167
+		'context'     => array('view', 'edit', 'embed'),
168 168
 		'readonly'    => true,
169 169
 	),
170 170
 
171 171
 	'subtotal'        => array(
172
-		'description' => __( 'Invoice subtotal.', 'invoicing' ),
172
+		'description' => __('Invoice subtotal.', 'invoicing'),
173 173
 		'type'        => 'number',
174
-		'context'     => array( 'view', 'edit', 'embed' ),
174
+		'context'     => array('view', 'edit', 'embed'),
175 175
 		'readonly'    => true,
176 176
 	),
177 177
 
178 178
 	'total'           => array(
179
-		'description' => __( 'Grand total.', 'invoicing' ),
179
+		'description' => __('Grand total.', 'invoicing'),
180 180
 		'type'        => 'number',
181
-		'context'     => array( 'view', 'edit', 'embed' ),
181
+		'context'     => array('view', 'edit', 'embed'),
182 182
 		'readonly'    => true,
183 183
 	),
184 184
 
185 185
 	'initial_total'   => array(
186
-		'description' => __( 'Initial total (for recurring invoices).', 'invoicing' ),
186
+		'description' => __('Initial total (for recurring invoices).', 'invoicing'),
187 187
 		'type'        => 'number',
188
-		'context'     => array( 'view', 'edit', 'embed' ),
188
+		'context'     => array('view', 'edit', 'embed'),
189 189
 		'readonly'    => true,
190 190
 	),
191 191
 
192 192
 	'recurring_total'  => array(
193
-		'description' => __( 'Recurring total (for recurring invoices).', 'invoicing' ),
193
+		'description' => __('Recurring total (for recurring invoices).', 'invoicing'),
194 194
 		'type'        => 'number',
195
-		'context'     => array( 'view', 'edit', 'embed' ),
195
+		'context'     => array('view', 'edit', 'embed'),
196 196
 		'readonly'    => true,
197 197
 	),
198 198
 
199 199
 	'totals'          => array(
200
-		'description' => __( 'Invoice totals.', 'invoicing' ),
200
+		'description' => __('Invoice totals.', 'invoicing'),
201 201
 		'type'        => 'object',
202
-		'context'     => array( 'view', 'edit', 'embed' ),
202
+		'context'     => array('view', 'edit', 'embed'),
203 203
 		'readonly'    => true,
204 204
 	),
205 205
 
206 206
 	'fees'            => array(
207
-		'description' => __( 'Invoice fees (Name => properties).', 'invoicing' ),
207
+		'description' => __('Invoice fees (Name => properties).', 'invoicing'),
208 208
 		'type'        => 'object',
209
-		'context'     => array( 'view', 'edit', 'embed' ),
209
+		'context'     => array('view', 'edit', 'embed'),
210 210
 		'items'       => array(
211 211
 			'type'                => 'object',
212
-			'required'            => array( 'amount' ),
212
+			'required'            => array('amount'),
213 213
 			'properties'          => array(
214 214
 				'amount'          => array(
215
-					'description' => __( 'Fee amount.', 'invoicing' ),
215
+					'description' => __('Fee amount.', 'invoicing'),
216 216
 					'type'        => 'string',
217
-					'context'     => array( 'view', 'edit', 'embed' ),
217
+					'context'     => array('view', 'edit', 'embed'),
218 218
 				),
219 219
 				'recurring'       => array(
220
-					'description' => __( 'Whether this is a recurring or one-time fee.', 'invoicing' ),
221
-					'type'        => array( 'boolean', 'integer' ),
222
-					'context'     => array( 'view', 'edit', 'embed' ),
220
+					'description' => __('Whether this is a recurring or one-time fee.', 'invoicing'),
221
+					'type'        => array('boolean', 'integer'),
222
+					'context'     => array('view', 'edit', 'embed'),
223 223
 				),
224 224
 			),
225 225
 		),
226 226
 	),
227 227
 
228 228
 	'discounts'       => array(
229
-		'description' => __( 'Invoice discounts (Name => properties).', 'invoicing' ),
229
+		'description' => __('Invoice discounts (Name => properties).', 'invoicing'),
230 230
 		'type'        => 'object',
231
-		'context'     => array( 'view', 'edit', 'embed' ),
231
+		'context'     => array('view', 'edit', 'embed'),
232 232
 		'items'       => array(
233 233
 			'type'                => 'object',
234
-			'required'            => array( 'amount' ),
234
+			'required'            => array('amount'),
235 235
 			'properties'          => array(
236 236
 				'amount'          => array(
237
-					'description' => __( 'Fee amount.', 'invoicing' ),
237
+					'description' => __('Fee amount.', 'invoicing'),
238 238
 					'type'        => 'string',
239
-					'context'     => array( 'view', 'edit', 'embed' ),
239
+					'context'     => array('view', 'edit', 'embed'),
240 240
 				),
241 241
 				'recurring'       => array(
242
-					'description' => __( 'Whether this is a recurring or one-time discount.', 'invoicing' ),
243
-					'type'        => array( 'boolean', 'integer' ),
244
-					'context'     => array( 'view', 'edit', 'embed' ),
242
+					'description' => __('Whether this is a recurring or one-time discount.', 'invoicing'),
243
+					'type'        => array('boolean', 'integer'),
244
+					'context'     => array('view', 'edit', 'embed'),
245 245
 				),
246 246
 			),
247 247
 		),
248 248
 	),
249 249
 
250 250
 	'taxes'           => array(
251
-		'description' => __( 'Invoice taxes (Name => properties).', 'invoicing' ),
251
+		'description' => __('Invoice taxes (Name => properties).', 'invoicing'),
252 252
 		'type'        => 'object',
253
-		'context'     => array( 'view', 'edit', 'embed' ),
253
+		'context'     => array('view', 'edit', 'embed'),
254 254
 		'items'       => array(
255 255
 			'type'                => 'object',
256
-			'required'            => array( 'amount' ),
256
+			'required'            => array('amount'),
257 257
 			'properties'          => array(
258 258
 				'amount'          => array(
259
-					'description' => __( 'Fee amount.', 'invoicing' ),
259
+					'description' => __('Fee amount.', 'invoicing'),
260 260
 					'type'        => 'string',
261
-					'context'     => array( 'view', 'edit', 'embed' ),
261
+					'context'     => array('view', 'edit', 'embed'),
262 262
 				),
263 263
 				'recurring'       => array(
264
-					'description' => __( 'Whether this is a recurring or one-time tax.', 'invoicing' ),
265
-					'type'        => array( 'boolean', 'integer' ),
266
-					'context'     => array( 'view', 'edit', 'embed' ),
264
+					'description' => __('Whether this is a recurring or one-time tax.', 'invoicing'),
265
+					'type'        => array('boolean', 'integer'),
266
+					'context'     => array('view', 'edit', 'embed'),
267 267
 				),
268 268
 			),
269 269
 		),
270 270
 	),
271 271
 
272 272
 	'items'           => array(
273
-		'description' => __( 'Invoice items.', 'invoicing' ),
273
+		'description' => __('Invoice items.', 'invoicing'),
274 274
 		'type'        => 'array',
275
-		'context'     => array( 'view', 'edit', 'embed' ),
275
+		'context'     => array('view', 'edit', 'embed'),
276 276
 		'items'       => array(
277 277
 			'type'                => 'object',
278
-			'required'            => array( 'item_id' ),
278
+			'required'            => array('item_id'),
279 279
 			'properties'          => array(
280 280
 				'item_id'         => array(
281
-					'description' => __( 'Item ID.', 'invoicing' ),
281
+					'description' => __('Item ID.', 'invoicing'),
282 282
 					'type'        => 'integer',
283
-					'context'     => array( 'view', 'edit', 'embed' ),
283
+					'context'     => array('view', 'edit', 'embed'),
284 284
 				),
285 285
 				'item_name'       => array(
286
-					'description' => __( 'Item Name.', 'invoicing' ),
286
+					'description' => __('Item Name.', 'invoicing'),
287 287
 					'type'        => 'string',
288
-					'context'     => array( 'view', 'edit', 'embed' ),
288
+					'context'     => array('view', 'edit', 'embed'),
289 289
 				),
290 290
 				'item_description' => array(
291
-					'description'  => __( 'Item Description.', 'invoicing' ),
291
+					'description'  => __('Item Description.', 'invoicing'),
292 292
 					'type'         => 'string',
293
-					'context'      => array( 'view', 'edit', 'embed' ),
293
+					'context'      => array('view', 'edit', 'embed'),
294 294
 				),
295 295
 				'item_price'      => array(
296
-					'description' => __( 'Item Price.', 'invoicing' ),
296
+					'description' => __('Item Price.', 'invoicing'),
297 297
 					'type'        => 'number',
298
-					'context'     => array( 'view', 'edit', 'embed' ),
298
+					'context'     => array('view', 'edit', 'embed'),
299 299
 				),
300 300
 				'quantity'        => array(
301
-					'description' => __( 'Item Quantity.', 'invoicing' ),
301
+					'description' => __('Item Quantity.', 'invoicing'),
302 302
 					'type'        => 'number',
303
-					'context'     => array( 'view', 'edit', 'embed' ),
303
+					'context'     => array('view', 'edit', 'embed'),
304 304
 				),
305 305
 				'subtotal'        => array(
306
-					'description' => __( 'Item Subtotal.', 'invoicing' ),
306
+					'description' => __('Item Subtotal.', 'invoicing'),
307 307
 					'type'        => 'number',
308
-					'context'     => array( 'view', 'edit', 'embed' ),
308
+					'context'     => array('view', 'edit', 'embed'),
309 309
 					'readonly'    => true,
310 310
 				),
311 311
 				'meta'            => array(
312
-					'description' => __( 'Item Meta.', 'invoicing' ),
312
+					'description' => __('Item Meta.', 'invoicing'),
313 313
 					'type'        => 'object',
314
-					'context'     => array( 'view', 'edit', 'embed' ),
314
+					'context'     => array('view', 'edit', 'embed'),
315 315
 				),
316 316
 			),
317 317
 		),
318 318
 	),
319 319
 
320 320
 	'mode'			  => array(
321
-		'description' => __( 'The invoice transaction mode.', 'invoicing' ),
321
+		'description' => __('The invoice transaction mode.', 'invoicing'),
322 322
 		'type'        => 'string',
323
-		'context'     => array( 'view', 'edit', 'embed' ),
324
-		'enum'        => array( 'live', 'test' ),
323
+		'context'     => array('view', 'edit', 'embed'),
324
+		'enum'        => array('live', 'test'),
325 325
 		'readonly'    => true,
326 326
 	),
327 327
 	
328 328
 	'discount_code'   => array(
329
-		'description' => __( 'The discount code used on this invoice.', 'invoicing' ),
329
+		'description' => __('The discount code used on this invoice.', 'invoicing'),
330 330
 		'type'        => 'string',
331
-		'context'     => array( 'view', 'edit', 'embed' ),
331
+		'context'     => array('view', 'edit', 'embed'),
332 332
 	),
333 333
 
334 334
 	'gateway'         => array(
335
-		'description' => __( 'The gateway used to pay this invoice.', 'invoicing' ),
335
+		'description' => __('The gateway used to pay this invoice.', 'invoicing'),
336 336
 		'type'        => 'string',
337
-		'context'     => array( 'view', 'edit', 'embed' ),
337
+		'context'     => array('view', 'edit', 'embed'),
338 338
 	),
339 339
 
340 340
 	'gateway_title'   => array(
341
-		'description' => __( 'The title of the gateway used to pay this invoice.', 'invoicing' ),
341
+		'description' => __('The title of the gateway used to pay this invoice.', 'invoicing'),
342 342
 		'type'        => 'string',
343
-		'context'     => array( 'view', 'edit', 'embed' ),
343
+		'context'     => array('view', 'edit', 'embed'),
344 344
 		'readonly'    => true,
345 345
 	),
346 346
 
347 347
 	'transaction_id'  => array(
348
-		'description' => __( 'The transaction id for this invoice.', 'invoicing' ),
348
+		'description' => __('The transaction id for this invoice.', 'invoicing'),
349 349
 		'type'        => 'string',
350
-		'context'     => array( 'view', 'edit', 'embed' ),
350
+		'context'     => array('view', 'edit', 'embed'),
351 351
 	),
352 352
 	
353 353
 	'disable_taxes'   => array(
354
-		'description' => __( 'Whether or not taxes should be disabled for this invoice.', 'invoicing' ),
354
+		'description' => __('Whether or not taxes should be disabled for this invoice.', 'invoicing'),
355 355
 		'type'        => 'boolean ',
356
-		'context'     => array( 'view', 'edit', 'embed' ),
356
+		'context'     => array('view', 'edit', 'embed'),
357 357
 	),
358 358
 
359 359
 	'is_viewed'       => array(
360
-		'description' => __( 'Whether or not this invoice has been viewed by the user.', 'invoicing' ),
360
+		'description' => __('Whether or not this invoice has been viewed by the user.', 'invoicing'),
361 361
 		'type'        => 'boolean ',
362
-		'context'     => array( 'view', 'edit', 'embed' ),
362
+		'context'     => array('view', 'edit', 'embed'),
363 363
 		'readonly'    => true,
364 364
 	),
365 365
 
366 366
 	'email_cc'        => array(
367
-		'description' => __( 'A comma separated list of other emails that should receive communications for this invoice.', 'invoicing' ),
367
+		'description' => __('A comma separated list of other emails that should receive communications for this invoice.', 'invoicing'),
368 368
 		'type'        => 'string ',
369
-		'context'     => array( 'view', 'edit' ),
369
+		'context'     => array('view', 'edit'),
370 370
 	),
371 371
 
372 372
 	'subscription_id' => array(
373
-		'description' => __( 'The ID of the subscription associated with this invoice.', 'invoicing' ),
373
+		'description' => __('The ID of the subscription associated with this invoice.', 'invoicing'),
374 374
 		'type'        => 'string ',
375
-		'context'     => array( 'view', 'edit', 'embed' ),
375
+		'context'     => array('view', 'edit', 'embed'),
376 376
 		'readonly'    => true,
377 377
 	),
378 378
 
379 379
 	'subscription_name' => array(
380
-		'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ),
380
+		'description' => __('The name of the subscription associated with this invoice.', 'invoicing'),
381 381
 		'type'        => 'string ',
382
-		'context'     => array( 'view', 'edit', 'embed' ),
382
+		'context'     => array('view', 'edit', 'embed'),
383 383
 		'readonly'    => true,
384 384
 	),
385 385
 
386 386
 	'subscription_name' => array(
387
-		'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ),
387
+		'description' => __('The name of the subscription associated with this invoice.', 'invoicing'),
388 388
 		'type'        => 'string ',
389
-		'context'     => array( 'view', 'edit', 'embed' ),
389
+		'context'     => array('view', 'edit', 'embed'),
390 390
 		'readonly'    => true,
391 391
 	),
392 392
 
393 393
 	'is_parent'		  => array(
394
-		'description' => __( 'Whether or not this is a parent invoice.', 'invoicing' ),
394
+		'description' => __('Whether or not this is a parent invoice.', 'invoicing'),
395 395
 		'type'        => 'boolean',
396
-		'context'     => array( 'view', 'edit', 'embed' ),
396
+		'context'     => array('view', 'edit', 'embed'),
397 397
 		'readonly'    => true,
398 398
 	),
399 399
 
400 400
 	'is_renewal'      => array(
401
-		'description' => __( 'Whether or not this is a renewal invoice.', 'invoicing' ),
401
+		'description' => __('Whether or not this is a renewal invoice.', 'invoicing'),
402 402
 		'type'        => 'boolean',
403
-		'context'     => array( 'view', 'edit', 'embed' ),
403
+		'context'     => array('view', 'edit', 'embed'),
404 404
 		'readonly'    => true,
405 405
 	),
406 406
 
407 407
 	'is_recurring'    => array(
408
-		'description' => __( 'Whether or not this is a recurring invoice.', 'invoicing' ),
408
+		'description' => __('Whether or not this is a recurring invoice.', 'invoicing'),
409 409
 		'type'        => 'boolean',
410
-		'context'     => array( 'view', 'edit', 'embed' ),
410
+		'context'     => array('view', 'edit', 'embed'),
411 411
 		'readonly'    => true,
412 412
 	),
413 413
 
414 414
 	'is_free'         => array(
415
-		'description' => __( 'Whether or not this invoice is free.', 'invoicing' ),
415
+		'description' => __('Whether or not this invoice is free.', 'invoicing'),
416 416
 		'type'        => 'boolean',
417
-		'context'     => array( 'view', 'edit', 'embed' ),
417
+		'context'     => array('view', 'edit', 'embed'),
418 418
 		'readonly'    => true,
419 419
 	),
420 420
 
421 421
 	'is_paid'         => array(
422
-		'description' => __( 'Whether or not this invoice has been paid.', 'invoicing' ),
422
+		'description' => __('Whether or not this invoice has been paid.', 'invoicing'),
423 423
 		'type'        => 'boolean',
424
-		'context'     => array( 'view', 'edit', 'embed' ),
424
+		'context'     => array('view', 'edit', 'embed'),
425 425
 		'readonly'    => true,
426 426
 	),
427 427
 
428 428
 	'needs_payment'   => array(
429
-		'description' => __( 'Whether or not this invoice needs payment.', 'invoicing' ),
429
+		'description' => __('Whether or not this invoice needs payment.', 'invoicing'),
430 430
 		'type'        => 'boolean',
431
-		'context'     => array( 'view', 'edit', 'embed' ),
431
+		'context'     => array('view', 'edit', 'embed'),
432 432
 		'readonly'    => true,
433 433
 	),
434 434
 
435 435
 	'is_refunded'     => array(
436
-		'description' => __( 'Whether or not this invoice was refunded.', 'invoicing' ),
436
+		'description' => __('Whether or not this invoice was refunded.', 'invoicing'),
437 437
 		'type'        => 'boolean',
438
-		'context'     => array( 'view', 'edit', 'embed' ),
438
+		'context'     => array('view', 'edit', 'embed'),
439 439
 		'readonly'    => true,
440 440
 	),
441 441
 
442 442
 	'is_due'          => array(
443
-		'description' => __( 'Whether or not this invoice is due.', 'invoicing' ),
443
+		'description' => __('Whether or not this invoice is due.', 'invoicing'),
444 444
 		'type'        => 'boolean',
445
-		'context'     => array( 'view', 'edit', 'embed' ),
445
+		'context'     => array('view', 'edit', 'embed'),
446 446
 		'readonly'    => true,
447 447
 	),
448 448
 
449 449
 	'is_held'         => array(
450
-		'description' => __( 'Whether or not this invoice has been held for payment confirmation.', 'invoicing' ),
450
+		'description' => __('Whether or not this invoice has been held for payment confirmation.', 'invoicing'),
451 451
 		'type'        => 'boolean',
452
-		'context'     => array( 'view', 'edit', 'embed' ),
452
+		'context'     => array('view', 'edit', 'embed'),
453 453
 		'readonly'    => true,
454 454
 	),
455 455
 
456 456
 	'is_draft'        => array(
457
-		'description' => __( 'Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing' ),
457
+		'description' => __('Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing'),
458 458
 		'type'        => 'boolean',
459
-		'context'     => array( 'view', 'edit', 'embed' ),
459
+		'context'     => array('view', 'edit', 'embed'),
460 460
 		'readonly'    => true,
461 461
 	),
462 462
 
463 463
 	'path'			  => array(
464
-		'description' => __( 'The invoice path/slug/name.', 'invoicing' ),
464
+		'description' => __('The invoice path/slug/name.', 'invoicing'),
465 465
 		'type'        => 'string',
466
-		'context'     => array( 'view', 'edit', 'embed' ),
466
+		'context'     => array('view', 'edit', 'embed'),
467 467
 		'readonly'    => true,
468 468
 	),
469 469
 
470 470
 	'description'     => array(
471
-		'description' => __( 'The invoice description.', 'invoicing' ),
471
+		'description' => __('The invoice description.', 'invoicing'),
472 472
 		'type'        => 'string',
473
-		'context'     => array( 'view', 'edit', 'embed' ),
473
+		'context'     => array('view', 'edit', 'embed'),
474 474
 	),
475 475
 
476 476
 	'payment_form'    => array(
477
-		'description' => __( 'The id of the payment form used to pay for this invoice.', 'invoicing' ),
477
+		'description' => __('The id of the payment form used to pay for this invoice.', 'invoicing'),
478 478
 		'type'        => 'integer',
479
-		'context'     => array( 'view', 'edit' ),
479
+		'context'     => array('view', 'edit'),
480 480
 		'readonly'    => true,
481 481
 	),
482 482
 
483 483
 	'submission_id'   => array(
484
-		'description' => __( 'A uniques ID of the submission details used to pay for this invoice.', 'invoicing' ),
484
+		'description' => __('A uniques ID of the submission details used to pay for this invoice.', 'invoicing'),
485 485
 		'type'        => 'string',
486
-		'context'     => array( 'view', 'edit' ),
486
+		'context'     => array('view', 'edit'),
487 487
 		'readonly'    => true,
488 488
 	),
489 489
 
490 490
 	'customer_id'     => array(
491
-		'description' => __( 'The customer id.', 'invoicing' ),
491
+		'description' => __('The customer id.', 'invoicing'),
492 492
 		'type'        => 'integer',
493
-		'context'     => array( 'view', 'edit', 'embed' ),
493
+		'context'     => array('view', 'edit', 'embed'),
494 494
 	),
495 495
 
496 496
 	'customer_ip'     => array(
497
-		'description' => __( "The customer's ip address.", 'invoicing' ),
497
+		'description' => __("The customer's ip address.", 'invoicing'),
498 498
 		'type'        => 'string',
499 499
 		'format'      => 'ip',
500
-		'context'     => array( 'view', 'edit', 'embed' ),
500
+		'context'     => array('view', 'edit', 'embed'),
501 501
 	),
502 502
 
503 503
 	'first_name'     => array(
504
-		'description' => __( "The customer's first name.", 'invoicing' ),
504
+		'description' => __("The customer's first name.", 'invoicing'),
505 505
 		'type'        => 'string',
506
-		'context'     => array( 'view', 'edit', 'embed' ),
506
+		'context'     => array('view', 'edit', 'embed'),
507 507
 	),
508 508
 
509 509
 	'last_name'       => array(
510
-		'description' => __( "The customer's last name.", 'invoicing' ),
510
+		'description' => __("The customer's last name.", 'invoicing'),
511 511
 		'type'        => 'string',
512
-		'context'     => array( 'view', 'edit', 'embed' ),
512
+		'context'     => array('view', 'edit', 'embed'),
513 513
 	),
514 514
 	
515 515
 	'full_name'       => array(
516
-		'description' => __( "The customer's full name.", 'invoicing' ),
516
+		'description' => __("The customer's full name.", 'invoicing'),
517 517
 		'type'        => 'string',
518
-		'context'     => array( 'view', 'edit', 'embed' ),
518
+		'context'     => array('view', 'edit', 'embed'),
519 519
 		'readonly'    => true,
520 520
 	),
521 521
 
522 522
 	'phone_number'    => array(
523
-		'description' => __( "The customer's phone number.", 'invoicing' ),
523
+		'description' => __("The customer's phone number.", 'invoicing'),
524 524
 		'type'        => 'string',
525
-		'context'     => array( 'view', 'edit', 'embed' ),
525
+		'context'     => array('view', 'edit', 'embed'),
526 526
 	),
527 527
 
528 528
 	'email_address'   => array(
529
-		'description' => __( "The customer's email address.", 'invoicing' ),
529
+		'description' => __("The customer's email address.", 'invoicing'),
530 530
 		'type'        => 'string',
531
-		'context'     => array( 'view', 'edit', 'embed' ),
531
+		'context'     => array('view', 'edit', 'embed'),
532 532
 		'readonly'    => true,
533 533
 	),
534 534
 
535 535
 	'customer_country'   => array(
536
-		'description'    => __( "The customer's country.", 'invoicing' ),
536
+		'description'    => __("The customer's country.", 'invoicing'),
537 537
 		'type'           => 'string',
538
-		'context'        => array( 'view', 'edit', 'embed' ),
538
+		'context'        => array('view', 'edit', 'embed'),
539 539
 		'default'        => wpinv_get_default_country(),
540 540
 	),
541 541
 
542 542
 	'customer_state'     => array(
543
-		'description'    => __( "The customer's state.", 'invoicing' ),
543
+		'description'    => __("The customer's state.", 'invoicing'),
544 544
 		'type'           => 'string',
545
-		'context'        => array( 'view', 'edit', 'embed' ),
545
+		'context'        => array('view', 'edit', 'embed'),
546 546
 	),
547 547
 
548 548
 	'customer_city'      => array(
549
-		'description'    => __( "The customer's city.", 'invoicing' ),
549
+		'description'    => __("The customer's city.", 'invoicing'),
550 550
 		'type'           => 'string',
551
-		'context'        => array( 'view', 'edit', 'embed' ),
551
+		'context'        => array('view', 'edit', 'embed'),
552 552
 	),
553 553
 
554 554
 	'customer_zip'       => array(
555
-		'description'    => __( "The customer's zip/postal code.", 'invoicing' ),
555
+		'description'    => __("The customer's zip/postal code.", 'invoicing'),
556 556
 		'type'           => 'string',
557
-		'context'        => array( 'view', 'edit', 'embed' ),
557
+		'context'        => array('view', 'edit', 'embed'),
558 558
 	),
559 559
 
560 560
 	'customer_company'   => array(
561
-		'description'    => __( "The customer's company name.", 'invoicing' ),
561
+		'description'    => __("The customer's company name.", 'invoicing'),
562 562
 		'type'           => 'string',
563
-		'context'        => array( 'view', 'edit', 'embed' ),
563
+		'context'        => array('view', 'edit', 'embed'),
564 564
 	),
565 565
 
566 566
 	'vat_number'         => array(
567
-		'description'    => __( "The customer's VAT number.", 'invoicing' ),
567
+		'description'    => __("The customer's VAT number.", 'invoicing'),
568 568
 		'type'           => 'string',
569
-		'context'        => array( 'view', 'edit', 'embed' ),
569
+		'context'        => array('view', 'edit', 'embed'),
570 570
 	),
571 571
 
572 572
 	'vat_rate'           => array(
573
-		'description'    => __( "The customer's VAT rate.", 'invoicing' ),
573
+		'description'    => __("The customer's VAT rate.", 'invoicing'),
574 574
 		'type'           => 'number',
575
-		'context'        => array( 'view', 'edit', 'embed' ),
575
+		'context'        => array('view', 'edit', 'embed'),
576 576
 		'readonly'       => true,
577 577
 	),
578 578
 
579 579
 	'customer_address'   => array(
580
-		'description'    => __( "The customer's address.", 'invoicing' ),
580
+		'description'    => __("The customer's address.", 'invoicing'),
581 581
 		'type'           => 'string',
582
-		'context'        => array( 'view', 'edit', 'embed' ),
582
+		'context'        => array('view', 'edit', 'embed'),
583 583
 	),
584 584
 
585 585
 	'address_confirmed'  => array(
586
-		'description'    => __( "Whether or not the customer's address is confirmed.", 'invoicing' ),
586
+		'description'    => __("Whether or not the customer's address is confirmed.", 'invoicing'),
587 587
 		'type'           => 'boolean',
588
-		'context'        => array( 'view', 'edit', 'embed' ),
588
+		'context'        => array('view', 'edit', 'embed'),
589 589
 	),
590 590
 
591 591
 	'meta_data'       => array(
592
-		'description' => __( 'Invoice meta data.', 'invoicing' ),
592
+		'description' => __('Invoice meta data.', 'invoicing'),
593 593
 		'type'        => 'array',
594
-		'context'     => array( 'view', 'edit', 'embed' ),
594
+		'context'     => array('view', 'edit', 'embed'),
595 595
 		'items'       => array(
596 596
 			'type'                => 'object',
597 597
 			'properties'          => array(
598 598
 				'id'              => array(
599
-					'description' => __( 'Meta ID.', 'invoicing' ),
599
+					'description' => __('Meta ID.', 'invoicing'),
600 600
 					'type'        => 'string',
601
-					'context'     => array( 'view', 'edit', 'embed' ),
601
+					'context'     => array('view', 'edit', 'embed'),
602 602
 				),
603 603
 				'key'             => array(
604
-					'description' => __( 'Meta key.', 'invoicing' ),
604
+					'description' => __('Meta key.', 'invoicing'),
605 605
 					'type'        => 'string',
606
-					'context'     => array( 'view', 'edit', 'embed' ),
606
+					'context'     => array('view', 'edit', 'embed'),
607 607
 				),
608 608
 				'value'           => array(
609
-					'description' => __( 'Meta Value.', 'invoicing' ),
610
-					'type'        => array( 'string', 'array', 'object', 'integer', 'null' ),
611
-					'context'     => array( 'view', 'edit', 'embed' ),
609
+					'description' => __('Meta Value.', 'invoicing'),
610
+					'type'        => array('string', 'array', 'object', 'integer', 'null'),
611
+					'context'     => array('view', 'edit', 'embed'),
612 612
 				),
613 613
 			),
614 614
 		),
615 615
 	),
616 616
 
617 617
 	'view_url'        => array(
618
-		'description' => __( 'URL to the invoice.', 'invoicing' ),
618
+		'description' => __('URL to the invoice.', 'invoicing'),
619 619
 		'type'        => 'string',
620 620
 		'format'      => 'uri',
621
-		'context'     => array( 'view', 'edit', 'embed' ),
621
+		'context'     => array('view', 'edit', 'embed'),
622 622
 		'readonly'    => true,
623 623
 	),
624 624
 
625 625
 	'checkout_payment_url'         => array(
626
-		'description' => __( 'URL to the invoice checkout page.', 'invoicing' ),
626
+		'description' => __('URL to the invoice checkout page.', 'invoicing'),
627 627
 		'type'        => 'string',
628 628
 		'format'      => 'uri',
629
-		'context'     => array( 'view', 'edit', 'embed' ),
629
+		'context'     => array('view', 'edit', 'embed'),
630 630
 		'readonly'    => true,
631 631
 	),
632 632
 
633 633
 	'receipt_url'     => array(
634
-		'description' => __( 'URL to the invoice receipt page.', 'invoicing' ),
634
+		'description' => __('URL to the invoice receipt page.', 'invoicing'),
635 635
 		'type'        => 'string',
636 636
 		'format'      => 'uri',
637
-		'context'     => array( 'view', 'edit', 'embed' ),
637
+		'context'     => array('view', 'edit', 'embed'),
638 638
 		'readonly'    => true,
639 639
 	),
640 640
 
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +734 added lines, -734 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
94
-		} else {
95
-			$this->set_object_read( true );
96
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
+            $this->set_id( $item_id );
92
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
+            $this->set_id( $item_id );
94
+        } else {
95
+            $this->set_object_read( true );
96
+        }
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
100 100
 
101
-		if ( $this->get_id() > 0 ) {
101
+        if ( $this->get_id() > 0 ) {
102 102
             $this->post = get_post( $this->get_id() );
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+            $this->data_store->read( $this );
105 105
         }
106 106
 
107
-	}
107
+    }
108 108
 
109 109
     /*
110 110
 	|--------------------------------------------------------------------------
@@ -122,401 +122,401 @@  discard block
 block discarded – undo
122 122
     */
123 123
 
124 124
     /**
125
-	 * Get parent item ID.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @param  string $context View or edit context.
129
-	 * @return int
130
-	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
125
+     * Get parent item ID.
126
+     *
127
+     * @since 1.0.19
128
+     * @param  string $context View or edit context.
129
+     * @return int
130
+     */
131
+    public function get_parent_id( $context = 'view' ) {
132
+        return (int) $this->get_prop( 'parent_id', $context );
133 133
     }
134 134
 
135 135
     /**
136
-	 * Get item status.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @param  string $context View or edit context.
140
-	 * @return string
141
-	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
136
+     * Get item status.
137
+     *
138
+     * @since 1.0.19
139
+     * @param  string $context View or edit context.
140
+     * @return string
141
+     */
142
+    public function get_status( $context = 'view' ) {
143
+        return $this->get_prop( 'status', $context );
144 144
     }
145 145
 
146 146
     /**
147
-	 * Get plugin version when the item was created.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param  string $context View or edit context.
151
-	 * @return string
152
-	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
147
+     * Get plugin version when the item was created.
148
+     *
149
+     * @since 1.0.19
150
+     * @param  string $context View or edit context.
151
+     * @return string
152
+     */
153
+    public function get_version( $context = 'view' ) {
154
+        return $this->get_prop( 'version', $context );
155 155
     }
156 156
 
157 157
     /**
158
-	 * Get date when the item was created.
159
-	 *
160
-	 * @since 1.0.19
161
-	 * @param  string $context View or edit context.
162
-	 * @return string
163
-	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
158
+     * Get date when the item was created.
159
+     *
160
+     * @since 1.0.19
161
+     * @param  string $context View or edit context.
162
+     * @return string
163
+     */
164
+    public function get_date_created( $context = 'view' ) {
165
+        return $this->get_prop( 'date_created', $context );
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get GMT date when the item was created.
170
-	 *
171
-	 * @since 1.0.19
172
-	 * @param  string $context View or edit context.
173
-	 * @return string
174
-	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
169
+     * Get GMT date when the item was created.
170
+     *
171
+     * @since 1.0.19
172
+     * @param  string $context View or edit context.
173
+     * @return string
174
+     */
175
+    public function get_date_created_gmt( $context = 'view' ) {
176 176
         $date = $this->get_date_created( $context );
177 177
 
178 178
         if ( $date ) {
179 179
             $date = get_gmt_from_date( $date );
180 180
         }
181
-		return $date;
181
+        return $date;
182 182
     }
183 183
 
184 184
     /**
185
-	 * Get date when the item was last modified.
186
-	 *
187
-	 * @since 1.0.19
188
-	 * @param  string $context View or edit context.
189
-	 * @return string
190
-	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
185
+     * Get date when the item was last modified.
186
+     *
187
+     * @since 1.0.19
188
+     * @param  string $context View or edit context.
189
+     * @return string
190
+     */
191
+    public function get_date_modified( $context = 'view' ) {
192
+        return $this->get_prop( 'date_modified', $context );
193 193
     }
194 194
 
195 195
     /**
196
-	 * Get GMT date when the item was last modified.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
196
+     * Get GMT date when the item was last modified.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_date_modified_gmt( $context = 'view' ) {
203 203
         $date = $this->get_date_modified( $context );
204 204
 
205 205
         if ( $date ) {
206 206
             $date = get_gmt_from_date( $date );
207 207
         }
208
-		return $date;
208
+        return $date;
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get the item name.
213
-	 *
214
-	 * @since 1.0.19
215
-	 * @param  string $context View or edit context.
216
-	 * @return string
217
-	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
212
+     * Get the item name.
213
+     *
214
+     * @since 1.0.19
215
+     * @param  string $context View or edit context.
216
+     * @return string
217
+     */
218
+    public function get_name( $context = 'view' ) {
219
+        return $this->get_prop( 'name', $context );
220 220
     }
221 221
 
222 222
     /**
223
-	 * Alias of self::get_name().
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return string
228
-	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
223
+     * Alias of self::get_name().
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return string
228
+     */
229
+    public function get_title( $context = 'view' ) {
230
+        return $this->get_name( $context );
231 231
     }
232 232
 
233 233
     /**
234
-	 * Get the item description.
235
-	 *
236
-	 * @since 1.0.19
237
-	 * @param  string $context View or edit context.
238
-	 * @return string
239
-	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
234
+     * Get the item description.
235
+     *
236
+     * @since 1.0.19
237
+     * @param  string $context View or edit context.
238
+     * @return string
239
+     */
240
+    public function get_description( $context = 'view' ) {
241
+        return $this->get_prop( 'description', $context );
242 242
     }
243 243
 
244 244
     /**
245
-	 * Alias of self::get_description().
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return string
250
-	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
245
+     * Alias of self::get_description().
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return string
250
+     */
251
+    public function get_excerpt( $context = 'view' ) {
252
+        return $this->get_description( $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Alias of self::get_description().
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return string
261
-	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
256
+     * Alias of self::get_description().
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return string
261
+     */
262
+    public function get_summary( $context = 'view' ) {
263
+        return $this->get_description( $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get the owner of the item.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @param  string $context View or edit context.
271
-	 * @return int
272
-	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
275
-	}
267
+     * Get the owner of the item.
268
+     *
269
+     * @since 1.0.19
270
+     * @param  string $context View or edit context.
271
+     * @return int
272
+     */
273
+    public function get_author( $context = 'view' ) {
274
+        return (int) $this->get_prop( 'author', $context );
275
+    }
276 276
 	
277
-	/**
278
-	 * Alias of self::get_author().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return int
283
-	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
286
-    }
287
-
288
-    /**
289
-	 * Get the price of the item.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return float
294
-	 */
295
-	public function get_price( $context = 'view' ) {
277
+    /**
278
+     * Alias of self::get_author().
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return int
283
+     */
284
+    public function get_owner( $context = 'view' ) {
285
+        return $this->get_author( $context );
286
+    }
287
+
288
+    /**
289
+     * Get the price of the item.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return float
294
+     */
295
+    public function get_price( $context = 'view' ) {
296 296
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
297
-	}
297
+    }
298 298
 	
299
-	/**
300
-	 * Get the inital price of the item.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return float
305
-	 */
306
-	public function get_initial_price( $context = 'view' ) {
299
+    /**
300
+     * Get the inital price of the item.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return float
305
+     */
306
+    public function get_initial_price( $context = 'view' ) {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+        $price = (float) $this->get_price( $context );
309 309
 
310
-		if ( $this->has_free_trial() ) {
311
-			$price = 0;
312
-		}
310
+        if ( $this->has_free_trial() ) {
311
+            $price = 0;
312
+        }
313 313
 
314 314
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
315 315
     }
316 316
 
317 317
     /**
318
-	 * Returns a formated price.
319
-	 *
320
-	 * @since 1.0.19
321
-	 * @param  string $context View or edit context.
322
-	 * @return string
323
-	 */
318
+     * Returns a formated price.
319
+     *
320
+     * @since 1.0.19
321
+     * @param  string $context View or edit context.
322
+     * @return string
323
+     */
324 324
     public function get_the_price() {
325 325
         return wpinv_price( $this->get_price() );
326
-	}
327
-
328
-	/**
329
-	 * Returns the formated initial price.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param  string $context View or edit context.
333
-	 * @return string
334
-	 */
326
+    }
327
+
328
+    /**
329
+     * Returns the formated initial price.
330
+     *
331
+     * @since 1.0.19
332
+     * @param  string $context View or edit context.
333
+     * @return string
334
+     */
335 335
     public function get_the_initial_price() {
336 336
         return wpinv_price( $this->get_initial_price() );
337 337
     }
338 338
 
339 339
     /**
340
-	 * Get the VAT rule of the item.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  string $context View or edit context.
344
-	 * @return string
345
-	 */
346
-	public function get_vat_rule( $context = 'view' ) {
340
+     * Get the VAT rule of the item.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  string $context View or edit context.
344
+     * @return string
345
+     */
346
+    public function get_vat_rule( $context = 'view' ) {
347 347
         return $this->get_prop( 'vat_rule', $context );
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get the VAT class of the item.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_vat_class( $context = 'view' ) {
351
+     * Get the VAT class of the item.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_vat_class( $context = 'view' ) {
358 358
         return $this->get_prop( 'vat_class', $context );
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get the type of the item.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_type( $context = 'view' ) {
362
+     * Get the type of the item.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_type( $context = 'view' ) {
369 369
         return $this->get_prop( 'type', $context );
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get the custom id of the item.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_custom_id( $context = 'view' ) {
373
+     * Get the custom id of the item.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_custom_id( $context = 'view' ) {
380 380
         return $this->get_prop( 'custom_id', $context );
381 381
     }
382 382
 
383 383
     /**
384
-	 * Get the custom name of the item.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_custom_name( $context = 'view' ) {
384
+     * Get the custom name of the item.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_custom_name( $context = 'view' ) {
391 391
         return $this->get_prop( 'custom_name', $context );
392 392
     }
393 393
 
394 394
     /**
395
-	 * Get the custom singular name of the item.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
395
+     * Get the custom singular name of the item.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_custom_singular_name( $context = 'view' ) {
402 402
         return $this->get_prop( 'custom_singular_name', $context );
403 403
     }
404 404
 
405 405
     /**
406
-	 * Checks if an item is editable..
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return int
411
-	 */
412
-	public function get_is_editable( $context = 'view' ) {
406
+     * Checks if an item is editable..
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return int
411
+     */
412
+    public function get_is_editable( $context = 'view' ) {
413 413
         return (int) $this->get_prop( 'is_editable', $context );
414 414
     }
415 415
 
416 416
     /**
417
-	 * Alias of self::get_is_editable().
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return int
422
-	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
417
+     * Alias of self::get_is_editable().
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return int
422
+     */
423
+    public function get_editable( $context = 'view' ) {
424
+        return $this->get_is_editable( $context );
425 425
     }
426 426
 
427 427
     /**
428
-	 * Checks if dynamic pricing is enabled.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return int
433
-	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
428
+     * Checks if dynamic pricing is enabled.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return int
433
+     */
434
+    public function get_is_dynamic_pricing( $context = 'view' ) {
435 435
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Returns the minimum price if dynamic pricing is enabled.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return float
444
-	 */
445
-	public function get_minimum_price( $context = 'view' ) {
439
+     * Returns the minimum price if dynamic pricing is enabled.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return float
444
+     */
445
+    public function get_minimum_price( $context = 'view' ) {
446 446
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Checks if this is a recurring item.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return int
455
-	 */
456
-	public function get_is_recurring( $context = 'view' ) {
450
+     * Checks if this is a recurring item.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return int
455
+     */
456
+    public function get_is_recurring( $context = 'view' ) {
457 457
         return (int) $this->get_prop( 'is_recurring', $context );
458
-	}
458
+    }
459 459
 	
460
-	/**
461
-	 * Get the recurring price of the item.
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return float
466
-	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
460
+    /**
461
+     * Get the recurring price of the item.
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return float
466
+     */
467
+    public function get_recurring_price( $context = 'view' ) {
468
+        $price = $this->get_price( $context );
469 469
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
470
-	}
471
-
472
-	/**
473
-	 * Get the formatted recurring price of the item.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
470
+    }
471
+
472
+    /**
473
+     * Get the formatted recurring price of the item.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479 479
     public function get_the_recurring_price() {
480 480
         return wpinv_price( $this->get_recurring_price() );
481
-	}
482
-
483
-	/**
484
-	 * Get the first renewal date (in timestamps) of the item.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @return int
488
-	 */
489
-	public function get_first_renewal_date() {
490
-
491
-		$periods = array(
492
-			'D' => 'days',
493
-			'W' => 'weeks',
494
-			'M' => 'months',
495
-			'Y' => 'years',
496
-		);
497
-
498
-		$period   = $this->get_recurring_period();
499
-		$interval = $this->get_recurring_interval();
500
-
501
-		if ( $this->has_free_trial() ) {
502
-			$period   = $this->get_trial_period();
503
-			$interval = $this->get_trial_interval();
504
-		}
505
-
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
481
+    }
482
+
483
+    /**
484
+     * Get the first renewal date (in timestamps) of the item.
485
+     *
486
+     * @since 1.0.19
487
+     * @return int
488
+     */
489
+    public function get_first_renewal_date() {
490
+
491
+        $periods = array(
492
+            'D' => 'days',
493
+            'W' => 'weeks',
494
+            'M' => 'months',
495
+            'Y' => 'years',
496
+        );
497
+
498
+        $period   = $this->get_recurring_period();
499
+        $interval = $this->get_recurring_interval();
500
+
501
+        if ( $this->has_free_trial() ) {
502
+            $period   = $this->get_trial_period();
503
+            $interval = $this->get_trial_interval();
504
+        }
505
+
506
+        $period       = $periods[ $period ];
507
+        $interval     = empty( $interval ) ? 1 : $interval;
508
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509 509
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
510 510
     }
511 511
 
512 512
     /**
513
-	 * Get the recurring period.
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  bool $full Return abbreviation or in full.
517
-	 * @return string
518
-	 */
519
-	public function get_recurring_period( $full = false ) {
513
+     * Get the recurring period.
514
+     *
515
+     * @since 1.0.19
516
+     * @param  bool $full Return abbreviation or in full.
517
+     * @return string
518
+     */
519
+    public function get_recurring_period( $full = false ) {
520 520
         $period = $this->get_prop( 'recurring_period', 'view' );
521 521
 
522 522
         if ( $full && ! is_bool( $full ) ) {
@@ -527,63 +527,63 @@  discard block
 block discarded – undo
527 527
     }
528 528
 
529 529
     /**
530
-	 * Get the recurring interval.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param  string $context View or edit context.
534
-	 * @return int
535
-	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
530
+     * Get the recurring interval.
531
+     *
532
+     * @since 1.0.19
533
+     * @param  string $context View or edit context.
534
+     * @return int
535
+     */
536
+    public function get_recurring_interval( $context = 'view' ) {
537
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538 538
 
539
-		if ( $interval < 1 ) {
540
-			$interval = 1;
541
-		}
539
+        if ( $interval < 1 ) {
540
+            $interval = 1;
541
+        }
542 542
 
543 543
         return $interval;
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the recurring limit.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return int
552
-	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
547
+     * Get the recurring limit.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return int
552
+     */
553
+    public function get_recurring_limit( $context = 'view' ) {
554 554
         return (int) $this->get_prop( 'recurring_limit', $context );
555 555
     }
556 556
 
557 557
     /**
558
-	 * Checks if we have a free trial.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  string $context View or edit context.
562
-	 * @return int
563
-	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
558
+     * Checks if we have a free trial.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  string $context View or edit context.
562
+     * @return int
563
+     */
564
+    public function get_is_free_trial( $context = 'view' ) {
565 565
         return (int) $this->get_prop( 'is_free_trial', $context );
566 566
     }
567 567
 
568 568
     /**
569
-	 * Alias for self::get_is_free_trial().
570
-	 *
571
-	 * @since 1.0.19
572
-	 * @param  string $context View or edit context.
573
-	 * @return int
574
-	 */
575
-	public function get_free_trial( $context = 'view' ) {
569
+     * Alias for self::get_is_free_trial().
570
+     *
571
+     * @since 1.0.19
572
+     * @param  string $context View or edit context.
573
+     * @return int
574
+     */
575
+    public function get_free_trial( $context = 'view' ) {
576 576
         return $this->get_is_free_trial( $context );
577 577
     }
578 578
 
579 579
     /**
580
-	 * Get the trial period.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  bool $full Return abbreviation or in full.
584
-	 * @return string
585
-	 */
586
-	public function get_trial_period( $full = false ) {
580
+     * Get the trial period.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  bool $full Return abbreviation or in full.
584
+     * @return string
585
+     */
586
+    public function get_trial_period( $full = false ) {
587 587
         $period = $this->get_prop( 'trial_period', 'view' );
588 588
 
589 589
         if ( $full && ! is_bool( $full ) ) {
@@ -594,104 +594,104 @@  discard block
 block discarded – undo
594 594
     }
595 595
 
596 596
     /**
597
-	 * Get the trial interval.
598
-	 *
599
-	 * @since 1.0.19
600
-	 * @param  string $context View or edit context.
601
-	 * @return int
602
-	 */
603
-	public function get_trial_interval( $context = 'view' ) {
597
+     * Get the trial interval.
598
+     *
599
+     * @since 1.0.19
600
+     * @param  string $context View or edit context.
601
+     * @return int
602
+     */
603
+    public function get_trial_interval( $context = 'view' ) {
604 604
         return (int) $this->get_prop( 'trial_interval', $context );
605
-	}
605
+    }
606 606
 	
607
-	/**
608
-	 * Get the item's edit url.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @return string
612
-	 */
613
-	public function get_edit_url() {
607
+    /**
608
+     * Get the item's edit url.
609
+     *
610
+     * @since 1.0.19
611
+     * @return string
612
+     */
613
+    public function get_edit_url() {
614 614
         return get_edit_post_link( $this->get_id() );
615
-	}
616
-
617
-	/**
618
-	 * Given an item's name/custom id, it returns its id.
619
-	 *
620
-	 *
621
-	 * @static
622
-	 * @param string $value The item name or custom id.
623
-	 * @param string $field Either name or custom_id.
624
-	 * @param string $type in case you need to search for a given type.
625
-	 * @since 1.0.15
626
-	 * @return int
627
-	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
-
630
-		// Trim the value.
631
-		$value = sanitize_text_field( $value );
632
-		if ( empty( $value ) ) {
633
-			return 0;
634
-		}
615
+    }
616
+
617
+    /**
618
+     * Given an item's name/custom id, it returns its id.
619
+     *
620
+     *
621
+     * @static
622
+     * @param string $value The item name or custom id.
623
+     * @param string $field Either name or custom_id.
624
+     * @param string $type in case you need to search for a given type.
625
+     * @since 1.0.15
626
+     * @return int
627
+     */
628
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
+
630
+        // Trim the value.
631
+        $value = sanitize_text_field( $value );
632
+        if ( empty( $value ) ) {
633
+            return 0;
634
+        }
635 635
 
636 636
         // Valid fields.
637 637
         $fields = array( 'custom_id', 'name', 'slug' );
638 638
 
639
-		// Ensure a field has been passed.
640
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
-			return 0;
642
-		}
643
-
644
-		if ( $field == 'name' ) {
645
-			$field = 'slug';
646
-		}
647
-
648
-		// Maybe retrieve from the cache.
649
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
650
-		if ( ! empty( $item_id ) ) {
651
-			return $item_id;
652
-		}
653
-
654
-		// Fetch from the db.
655
-		$items = array();
656
-		if ( $field == 'slug' ) {
657
-			$items = get_posts(
658
-				array(
659
-					'post_type'      => 'wpi_item',
660
-					'name'           => $value,
661
-					'posts_per_page' => 1,
662
-					'post_status'    => 'any',
663
-				)
664
-			);
665
-		}
666
-
667
-		if ( $field =='custom_id' ) {
668
-			$items = get_posts(
669
-				array(
670
-					'post_type'      => 'wpi_item',
671
-					'posts_per_page' => 1,
672
-					'post_status'    => 'any',
673
-					'meta_query'     => array(
674
-						array(
675
-							'key'   => '_wpinv_type',
676
-                			'value' => $type,
677
-						),
678
-						array(
679
-							'key'   => '_wpinv_custom_id',
680
-                			'value' => $value,
681
-						)
682
-					)
683
-				)
684
-			);
685
-		}
686
-
687
-		if ( empty( $items ) ) {
688
-			return 0;
689
-		}
690
-
691
-		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
-
694
-		return $items[0]->ID;
639
+        // Ensure a field has been passed.
640
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
+            return 0;
642
+        }
643
+
644
+        if ( $field == 'name' ) {
645
+            $field = 'slug';
646
+        }
647
+
648
+        // Maybe retrieve from the cache.
649
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
650
+        if ( ! empty( $item_id ) ) {
651
+            return $item_id;
652
+        }
653
+
654
+        // Fetch from the db.
655
+        $items = array();
656
+        if ( $field == 'slug' ) {
657
+            $items = get_posts(
658
+                array(
659
+                    'post_type'      => 'wpi_item',
660
+                    'name'           => $value,
661
+                    'posts_per_page' => 1,
662
+                    'post_status'    => 'any',
663
+                )
664
+            );
665
+        }
666
+
667
+        if ( $field =='custom_id' ) {
668
+            $items = get_posts(
669
+                array(
670
+                    'post_type'      => 'wpi_item',
671
+                    'posts_per_page' => 1,
672
+                    'post_status'    => 'any',
673
+                    'meta_query'     => array(
674
+                        array(
675
+                            'key'   => '_wpinv_type',
676
+                            'value' => $type,
677
+                        ),
678
+                        array(
679
+                            'key'   => '_wpinv_custom_id',
680
+                            'value' => $value,
681
+                        )
682
+                    )
683
+                )
684
+            );
685
+        }
686
+
687
+        if ( empty( $items ) ) {
688
+            return 0;
689
+        }
690
+
691
+        // Update the cache with our data
692
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
+
694
+        return $items[0]->ID;
695 695
     }
696 696
 
697 697
     /**
@@ -724,52 +724,52 @@  discard block
 block discarded – undo
724 724
     */
725 725
 
726 726
     /**
727
-	 * Set parent order ID.
728
-	 *
729
-	 * @since 1.0.19
730
-	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
733
-			return;
734
-		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
736
-	}
737
-
738
-    /**
739
-	 * Sets item status.
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $status New status.
743
-	 * @return array details of change.
744
-	 */
745
-	public function set_status( $status ) {
727
+     * Set parent order ID.
728
+     *
729
+     * @since 1.0.19
730
+     */
731
+    public function set_parent_id( $value ) {
732
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
733
+            return;
734
+        }
735
+        $this->set_prop( 'parent_id', absint( $value ) );
736
+    }
737
+
738
+    /**
739
+     * Sets item status.
740
+     *
741
+     * @since 1.0.19
742
+     * @param  string $status New status.
743
+     * @return array details of change.
744
+     */
745
+    public function set_status( $status ) {
746 746
         $old_status = $this->get_status();
747 747
 
748 748
         $this->set_prop( 'status', $status );
749 749
 
750
-		return array(
751
-			'from' => $old_status,
752
-			'to'   => $status,
753
-		);
750
+        return array(
751
+            'from' => $old_status,
752
+            'to'   => $status,
753
+        );
754 754
     }
755 755
 
756 756
     /**
757
-	 * Set plugin version when the item was created.
758
-	 *
759
-	 * @since 1.0.19
760
-	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
757
+     * Set plugin version when the item was created.
758
+     *
759
+     * @since 1.0.19
760
+     */
761
+    public function set_version( $value ) {
762
+        $this->set_prop( 'version', $value );
763 763
     }
764 764
 
765 765
     /**
766
-	 * Set date when the item was created.
767
-	 *
768
-	 * @since 1.0.19
769
-	 * @param string $value Value to set.
766
+     * Set date when the item was created.
767
+     *
768
+     * @since 1.0.19
769
+     * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771
-	 */
772
-	public function set_date_created( $value ) {
771
+     */
772
+    public function set_date_created( $value ) {
773 773
         $date = strtotime( $value );
774 774
 
775 775
         if ( $date ) {
@@ -782,13 +782,13 @@  discard block
 block discarded – undo
782 782
     }
783 783
 
784 784
     /**
785
-	 * Set date when the item was last modified.
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param string $value Value to set.
785
+     * Set date when the item was last modified.
786
+     *
787
+     * @since 1.0.19
788
+     * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790
-	 */
791
-	public function set_date_modified( $value ) {
790
+     */
791
+    public function set_date_modified( $value ) {
792 792
         $date = strtotime( $value );
793 793
 
794 794
         if ( $date ) {
@@ -801,115 +801,115 @@  discard block
 block discarded – undo
801 801
     }
802 802
 
803 803
     /**
804
-	 * Set the item name.
805
-	 *
806
-	 * @since 1.0.19
807
-	 * @param  string $value New name.
808
-	 */
809
-	public function set_name( $value ) {
804
+     * Set the item name.
805
+     *
806
+     * @since 1.0.19
807
+     * @param  string $value New name.
808
+     */
809
+    public function set_name( $value ) {
810 810
         $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
811
+        $this->set_prop( 'name', $name );
812 812
     }
813 813
 
814 814
     /**
815
-	 * Alias of self::set_name().
816
-	 *
817
-	 * @since 1.0.19
818
-	 * @param  string $value New name.
819
-	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
815
+     * Alias of self::set_name().
816
+     *
817
+     * @since 1.0.19
818
+     * @param  string $value New name.
819
+     */
820
+    public function set_title( $value ) {
821
+        $this->set_name( $value );
822 822
     }
823 823
 
824 824
     /**
825
-	 * Set the item description.
826
-	 *
827
-	 * @since 1.0.19
828
-	 * @param  string $value New description.
829
-	 */
830
-	public function set_description( $value ) {
831
-		$description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
825
+     * Set the item description.
826
+     *
827
+     * @since 1.0.19
828
+     * @param  string $value New description.
829
+     */
830
+    public function set_description( $value ) {
831
+        $description = wp_kses_post( $value );
832
+        return $this->set_prop( 'description', $description );
833 833
     }
834 834
 
835 835
     /**
836
-	 * Alias of self::set_description().
837
-	 *
838
-	 * @since 1.0.19
839
-	 * @param  string $value New description.
840
-	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
836
+     * Alias of self::set_description().
837
+     *
838
+     * @since 1.0.19
839
+     * @param  string $value New description.
840
+     */
841
+    public function set_excerpt( $value ) {
842
+        $this->set_description( $value );
843 843
     }
844 844
 
845 845
     /**
846
-	 * Alias of self::set_description().
847
-	 *
848
-	 * @since 1.0.19
849
-	 * @param  string $value New description.
850
-	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
846
+     * Alias of self::set_description().
847
+     *
848
+     * @since 1.0.19
849
+     * @param  string $value New description.
850
+     */
851
+    public function set_summary( $value ) {
852
+        $this->set_description( $value );
853 853
     }
854 854
 
855 855
     /**
856
-	 * Set the owner of the item.
857
-	 *
858
-	 * @since 1.0.19
859
-	 * @param  int $value New author.
860
-	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
863
-	}
856
+     * Set the owner of the item.
857
+     *
858
+     * @since 1.0.19
859
+     * @param  int $value New author.
860
+     */
861
+    public function set_author( $value ) {
862
+        $this->set_prop( 'author', (int) $value );
863
+    }
864 864
 	
865
-	/**
866
-	 * Alias of self::set_author().
867
-	 *
868
-	 * @since 1.0.19
869
-	 * @param  int $value New author.
870
-	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
873
-    }
874
-
875
-    /**
876
-	 * Set the price of the item.
877
-	 *
878
-	 * @since 1.0.19
879
-	 * @param  float $value New price.
880
-	 */
881
-	public function set_price( $value ) {
865
+    /**
866
+     * Alias of self::set_author().
867
+     *
868
+     * @since 1.0.19
869
+     * @param  int $value New author.
870
+     */
871
+    public function set_owner( $value ) {
872
+        $this->set_author( $value );
873
+    }
874
+
875
+    /**
876
+     * Set the price of the item.
877
+     *
878
+     * @since 1.0.19
879
+     * @param  float $value New price.
880
+     */
881
+    public function set_price( $value ) {
882 882
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
883 883
     }
884 884
 
885 885
     /**
886
-	 * Set the VAT rule of the item.
887
-	 *
888
-	 * @since 1.0.19
889
-	 * @param  string $value new rule.
890
-	 */
891
-	public function set_vat_rule( $value ) {
886
+     * Set the VAT rule of the item.
887
+     *
888
+     * @since 1.0.19
889
+     * @param  string $value new rule.
890
+     */
891
+    public function set_vat_rule( $value ) {
892 892
         $this->set_prop( 'vat_rule', $value );
893 893
     }
894 894
 
895 895
     /**
896
-	 * Set the VAT class of the item.
897
-	 *
898
-	 * @since 1.0.19
899
-	 * @param  string $value new class.
900
-	 */
901
-	public function set_vat_class( $value ) {
896
+     * Set the VAT class of the item.
897
+     *
898
+     * @since 1.0.19
899
+     * @param  string $value new class.
900
+     */
901
+    public function set_vat_class( $value ) {
902 902
         $this->set_prop( 'vat_class', $value );
903 903
     }
904 904
 
905 905
     /**
906
-	 * Set the type of the item.
907
-	 *
908
-	 * @since 1.0.19
909
-	 * @param  string $value new item type.
910
-	 * @return string
911
-	 */
912
-	public function set_type( $value ) {
906
+     * Set the type of the item.
907
+     *
908
+     * @since 1.0.19
909
+     * @param  string $value new item type.
910
+     * @return string
911
+     */
912
+    public function set_type( $value ) {
913 913
 
914 914
         if ( empty( $value ) ) {
915 915
             $value = 'custom';
@@ -919,132 +919,132 @@  discard block
 block discarded – undo
919 919
     }
920 920
 
921 921
     /**
922
-	 * Set the custom id of the item.
923
-	 *
924
-	 * @since 1.0.19
925
-	 * @param  string $value new custom id.
926
-	 */
927
-	public function set_custom_id( $value ) {
922
+     * Set the custom id of the item.
923
+     *
924
+     * @since 1.0.19
925
+     * @param  string $value new custom id.
926
+     */
927
+    public function set_custom_id( $value ) {
928 928
         $this->set_prop( 'custom_id', $value );
929 929
     }
930 930
 
931 931
     /**
932
-	 * Set the custom name of the item.
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $value new custom name.
936
-	 */
937
-	public function set_custom_name( $value ) {
932
+     * Set the custom name of the item.
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $value new custom name.
936
+     */
937
+    public function set_custom_name( $value ) {
938 938
         $this->set_prop( 'custom_name', $value );
939 939
     }
940 940
 
941 941
     /**
942
-	 * Set the custom singular name of the item.
943
-	 *
944
-	 * @since 1.0.19
945
-	 * @param  string $value new custom singular name.
946
-	 */
947
-	public function set_custom_singular_name( $value ) {
942
+     * Set the custom singular name of the item.
943
+     *
944
+     * @since 1.0.19
945
+     * @param  string $value new custom singular name.
946
+     */
947
+    public function set_custom_singular_name( $value ) {
948 948
         $this->set_prop( 'custom_singular_name', $value );
949 949
     }
950 950
 
951 951
     /**
952
-	 * Sets if an item is editable..
953
-	 *
954
-	 * @since 1.0.19
955
-	 * @param  int|bool $value whether or not the item is editable.
956
-	 */
957
-	public function set_is_editable( $value ) {
958
-		$this->set_prop( 'is_editable', (int) $value );
952
+     * Sets if an item is editable..
953
+     *
954
+     * @since 1.0.19
955
+     * @param  int|bool $value whether or not the item is editable.
956
+     */
957
+    public function set_is_editable( $value ) {
958
+        $this->set_prop( 'is_editable', (int) $value );
959 959
     }
960 960
 
961 961
     /**
962
-	 * Sets if dynamic pricing is enabled.
963
-	 *
964
-	 * @since 1.0.19
965
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
966
-	 */
967
-	public function set_is_dynamic_pricing( $value ) {
962
+     * Sets if dynamic pricing is enabled.
963
+     *
964
+     * @since 1.0.19
965
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
966
+     */
967
+    public function set_is_dynamic_pricing( $value ) {
968 968
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
969 969
     }
970 970
 
971 971
     /**
972
-	 * Sets the minimum price if dynamic pricing is enabled.
973
-	 *
974
-	 * @since 1.0.19
975
-	 * @param  float $value minimum price.
976
-	 */
977
-	public function set_minimum_price( $value ) {
972
+     * Sets the minimum price if dynamic pricing is enabled.
973
+     *
974
+     * @since 1.0.19
975
+     * @param  float $value minimum price.
976
+     */
977
+    public function set_minimum_price( $value ) {
978 978
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
979 979
     }
980 980
 
981 981
     /**
982
-	 * Sets if this is a recurring item.
983
-	 *
984
-	 * @since 1.0.19
985
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
986
-	 */
987
-	public function set_is_recurring( $value ) {
982
+     * Sets if this is a recurring item.
983
+     *
984
+     * @since 1.0.19
985
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
986
+     */
987
+    public function set_is_recurring( $value ) {
988 988
         $this->set_prop( 'is_recurring', (int) $value );
989 989
     }
990 990
 
991 991
     /**
992
-	 * Set the recurring period.
993
-	 *
994
-	 * @since 1.0.19
995
-	 * @param  string $value new period.
996
-	 */
997
-	public function set_recurring_period( $value ) {
992
+     * Set the recurring period.
993
+     *
994
+     * @since 1.0.19
995
+     * @param  string $value new period.
996
+     */
997
+    public function set_recurring_period( $value ) {
998 998
         $this->set_prop( 'recurring_period', $value );
999 999
     }
1000 1000
 
1001 1001
     /**
1002
-	 * Set the recurring interval.
1003
-	 *
1004
-	 * @since 1.0.19
1005
-	 * @param  int $value recurring interval.
1006
-	 */
1007
-	public function set_recurring_interval( $value ) {
1002
+     * Set the recurring interval.
1003
+     *
1004
+     * @since 1.0.19
1005
+     * @param  int $value recurring interval.
1006
+     */
1007
+    public function set_recurring_interval( $value ) {
1008 1008
         return $this->set_prop( 'recurring_interval', (int) $value );
1009 1009
     }
1010 1010
 
1011 1011
     /**
1012
-	 * Get the recurring limit.
1013
-	 * @since 1.0.19
1014
-	 * @param  int $value The recurring limit.
1015
-	 * @return int
1016
-	 */
1017
-	public function set_recurring_limit( $value ) {
1012
+     * Get the recurring limit.
1013
+     * @since 1.0.19
1014
+     * @param  int $value The recurring limit.
1015
+     * @return int
1016
+     */
1017
+    public function set_recurring_limit( $value ) {
1018 1018
         $this->set_prop( 'recurring_limit', (int) $value );
1019 1019
     }
1020 1020
 
1021 1021
     /**
1022
-	 * Checks if we have a free trial.
1023
-	 *
1024
-	 * @since 1.0.19
1025
-	 * @param  int|bool $value whether or not it has a free trial.
1026
-	 */
1027
-	public function set_is_free_trial( $value ) {
1022
+     * Checks if we have a free trial.
1023
+     *
1024
+     * @since 1.0.19
1025
+     * @param  int|bool $value whether or not it has a free trial.
1026
+     */
1027
+    public function set_is_free_trial( $value ) {
1028 1028
         $this->set_prop( 'is_free_trial', (int) $value );
1029 1029
     }
1030 1030
 
1031 1031
     /**
1032
-	 * Set the trial period.
1033
-	 *
1034
-	 * @since 1.0.19
1035
-	 * @param  string $value trial period.
1036
-	 */
1037
-	public function set_trial_period( $value ) {
1032
+     * Set the trial period.
1033
+     *
1034
+     * @since 1.0.19
1035
+     * @param  string $value trial period.
1036
+     */
1037
+    public function set_trial_period( $value ) {
1038 1038
         $this->set_prop( 'trial_period', $value );
1039 1039
     }
1040 1040
 
1041 1041
     /**
1042
-	 * Set the trial interval.
1043
-	 *
1044
-	 * @since 1.0.19
1045
-	 * @param  int $value trial interval.
1046
-	 */
1047
-	public function set_trial_interval( $value ) {
1042
+     * Set the trial interval.
1043
+     *
1044
+     * @since 1.0.19
1045
+     * @param  int $value trial interval.
1046
+     */
1047
+    public function set_trial_interval( $value ) {
1048 1048
         $this->set_prop( 'trial_interval', $value );
1049 1049
     }
1050 1050
 
@@ -1052,17 +1052,17 @@  discard block
 block discarded – undo
1052 1052
      * Create an item. For backwards compatibilty.
1053 1053
      * 
1054 1054
      * @deprecated
1055
-	 * @return int item id
1055
+     * @return int item id
1056 1056
      */
1057 1057
     public function create( $data = array() ) {
1058 1058
 
1059
-		// Set the properties.
1060
-		if ( is_array( $data ) ) {
1061
-			$this->set_props( $data );
1062
-		}
1059
+        // Set the properties.
1060
+        if ( is_array( $data ) ) {
1061
+            $this->set_props( $data );
1062
+        }
1063 1063
 
1064
-		// Save the item.
1065
-		return $this->save();
1064
+        // Save the item.
1065
+        return $this->save();
1066 1066
 
1067 1067
     }
1068 1068
 
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
      * Updates an item. For backwards compatibilty.
1071 1071
      * 
1072 1072
      * @deprecated
1073
-	 * @return int item id
1073
+     * @return int item id
1074 1074
      */
1075 1075
     public function update( $data = array() ) {
1076 1076
         return $this->create( $data );
@@ -1086,93 +1086,93 @@  discard block
 block discarded – undo
1086 1086
 	*/
1087 1087
 
1088 1088
     /**
1089
-	 * Checks whether the item has enabled dynamic pricing.
1090
-	 *
1091
-	 * @since 1.0.19
1092
-	 * @return bool
1093
-	 */
1094
-	public function user_can_set_their_price() {
1089
+     * Checks whether the item has enabled dynamic pricing.
1090
+     *
1091
+     * @since 1.0.19
1092
+     * @return bool
1093
+     */
1094
+    public function user_can_set_their_price() {
1095 1095
         return (bool) $this->get_is_dynamic_pricing();
1096
-	}
1096
+    }
1097 1097
 	
1098
-	/**
1099
-	 * Checks whether the item is recurring.
1100
-	 *
1101
-	 * @since 1.0.19
1102
-	 * @return bool
1103
-	 */
1104
-	public function is_recurring() {
1098
+    /**
1099
+     * Checks whether the item is recurring.
1100
+     *
1101
+     * @since 1.0.19
1102
+     * @return bool
1103
+     */
1104
+    public function is_recurring() {
1105 1105
         return (bool) $this->get_is_recurring();
1106 1106
     }
1107 1107
 
1108 1108
     /**
1109
-	 * Checks whether the item has a free trial.
1110
-	 *
1111
-	 * @since 1.0.19
1112
-	 * @return bool
1113
-	 */
1109
+     * Checks whether the item has a free trial.
1110
+     *
1111
+     * @since 1.0.19
1112
+     * @return bool
1113
+     */
1114 1114
     public function has_free_trial() {
1115 1115
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1116 1116
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1117 1117
     }
1118 1118
 
1119 1119
     /**
1120
-	 * Checks whether the item is free.
1121
-	 *
1122
-	 * @since 1.0.19
1123
-	 * @return bool
1124
-	 */
1120
+     * Checks whether the item is free.
1121
+     *
1122
+     * @since 1.0.19
1123
+     * @return bool
1124
+     */
1125 1125
     public function is_free() {
1126 1126
         $is_free   = $this->get_price() == 0;
1127 1127
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1128 1128
     }
1129 1129
 
1130 1130
     /**
1131
-	 * Checks the item status against a passed in status.
1132
-	 *
1133
-	 * @param array|string $status Status to check.
1134
-	 * @return bool
1135
-	 */
1136
-	public function has_status( $status ) {
1137
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1138
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1131
+     * Checks the item status against a passed in status.
1132
+     *
1133
+     * @param array|string $status Status to check.
1134
+     * @return bool
1135
+     */
1136
+    public function has_status( $status ) {
1137
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1138
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1139 1139
     }
1140 1140
 
1141 1141
     /**
1142
-	 * Checks the item type against a passed in types.
1143
-	 *
1144
-	 * @param array|string $type Type to check.
1145
-	 * @return bool
1146
-	 */
1147
-	public function is_type( $type ) {
1148
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1149
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1150
-	}
1142
+     * Checks the item type against a passed in types.
1143
+     *
1144
+     * @param array|string $type Type to check.
1145
+     * @return bool
1146
+     */
1147
+    public function is_type( $type ) {
1148
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1149
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1150
+    }
1151 1151
 
1152 1152
     /**
1153
-	 * Checks whether the item is editable.
1154
-	 *
1155
-	 * @since 1.0.19
1156
-	 * @return bool
1157
-	 */
1153
+     * Checks whether the item is editable.
1154
+     *
1155
+     * @since 1.0.19
1156
+     * @return bool
1157
+     */
1158 1158
     public function is_editable() {
1159 1159
         $is_editable = $this->get_is_editable();
1160 1160
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1161
-	}
1161
+    }
1162 1162
 
1163
-	/**
1164
-	 * Returns an array of cart fees.
1165
-	 */
1166
-	public function get_fees() {
1163
+    /**
1164
+     * Returns an array of cart fees.
1165
+     */
1166
+    public function get_fees() {
1167 1167
         return array();
1168 1168
     }
1169 1169
 
1170 1170
     /**
1171
-	 * Checks whether the item is purchasable.
1172
-	 *
1173
-	 * @since 1.0.19
1174
-	 * @return bool
1175
-	 */
1171
+     * Checks whether the item is purchasable.
1172
+     *
1173
+     * @since 1.0.19
1174
+     * @return bool
1175
+     */
1176 1176
     public function can_purchase() {
1177 1177
         $can_purchase = $this->exists();
1178 1178
 
@@ -1184,11 +1184,11 @@  discard block
 block discarded – undo
1184 1184
     }
1185 1185
 
1186 1186
     /**
1187
-	 * Checks whether the item supports dynamic pricing.
1188
-	 *
1189
-	 * @since 1.0.19
1190
-	 * @return bool
1191
-	 */
1187
+     * Checks whether the item supports dynamic pricing.
1188
+     *
1189
+     * @since 1.0.19
1190
+     * @return bool
1191
+     */
1192 1192
     public function supports_dynamic_pricing() {
1193 1193
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1194 1194
     }
Please login to merge, or discard this patch.
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 	
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( $this->get_price() );
325
+        return wpinv_price($this->get_price());
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( $this->get_initial_price() );
336
+        return wpinv_price($this->get_initial_price());
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( $this->get_recurring_price() );
480
+        return wpinv_price($this->get_recurring_price());
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538 538
 
539
-		if ( $interval < 1 ) {
539
+		if ($interval < 1) {
540 540
 			$interval = 1;
541 541
 		}
542 542
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return int
552 552
 	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
554
-        return (int) $this->get_prop( 'recurring_limit', $context );
553
+	public function get_recurring_limit($context = 'view') {
554
+        return (int) $this->get_prop('recurring_limit', $context);
555 555
     }
556 556
 
557 557
     /**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return int
563 563
 	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
565
-        return (int) $this->get_prop( 'is_free_trial', $context );
564
+	public function get_is_free_trial($context = 'view') {
565
+        return (int) $this->get_prop('is_free_trial', $context);
566 566
     }
567 567
 
568 568
     /**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $context View or edit context.
573 573
 	 * @return int
574 574
 	 */
575
-	public function get_free_trial( $context = 'view' ) {
576
-        return $this->get_is_free_trial( $context );
575
+	public function get_free_trial($context = 'view') {
576
+        return $this->get_is_free_trial($context);
577 577
     }
578 578
 
579 579
     /**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param  bool $full Return abbreviation or in full.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_trial_period( $full = false ) {
587
-        $period = $this->get_prop( 'trial_period', 'view' );
586
+	public function get_trial_period($full = false) {
587
+        $period = $this->get_prop('trial_period', 'view');
588 588
 
589
-        if ( $full && ! is_bool( $full ) ) {
589
+        if ($full && !is_bool($full)) {
590 590
             $full = false;
591 591
         }
592 592
 
593
-        return getpaid_sanitize_recurring_period( $period, $full );
593
+        return getpaid_sanitize_recurring_period($period, $full);
594 594
     }
595 595
 
596 596
     /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $context View or edit context.
601 601
 	 * @return int
602 602
 	 */
603
-	public function get_trial_interval( $context = 'view' ) {
604
-        return (int) $this->get_prop( 'trial_interval', $context );
603
+	public function get_trial_interval($context = 'view') {
604
+        return (int) $this->get_prop('trial_interval', $context);
605 605
 	}
606 606
 	
607 607
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_edit_url() {
614
-        return get_edit_post_link( $this->get_id() );
614
+        return get_edit_post_link($this->get_id());
615 615
 	}
616 616
 
617 617
 	/**
@@ -625,35 +625,35 @@  discard block
 block discarded – undo
625 625
 	 * @since 1.0.15
626 626
 	 * @return int
627 627
 	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
628
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
629 629
 
630 630
 		// Trim the value.
631
-		$value = sanitize_text_field( $value );
632
-		if ( empty( $value ) ) {
631
+		$value = sanitize_text_field($value);
632
+		if (empty($value)) {
633 633
 			return 0;
634 634
 		}
635 635
 
636 636
         // Valid fields.
637
-        $fields = array( 'custom_id', 'name', 'slug' );
637
+        $fields = array('custom_id', 'name', 'slug');
638 638
 
639 639
 		// Ensure a field has been passed.
640
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
640
+		if (empty($field) || !in_array($field, $fields)) {
641 641
 			return 0;
642 642
 		}
643 643
 
644
-		if ( $field == 'name' ) {
644
+		if ($field == 'name') {
645 645
 			$field = 'slug';
646 646
 		}
647 647
 
648 648
 		// Maybe retrieve from the cache.
649
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
650
-		if ( ! empty( $item_id ) ) {
649
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
650
+		if (!empty($item_id)) {
651 651
 			return $item_id;
652 652
 		}
653 653
 
654 654
 		// Fetch from the db.
655 655
 		$items = array();
656
-		if ( $field == 'slug' ) {
656
+		if ($field == 'slug') {
657 657
 			$items = get_posts(
658 658
 				array(
659 659
 					'post_type'      => 'wpi_item',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			);
665 665
 		}
666 666
 
667
-		if ( $field =='custom_id' ) {
667
+		if ($field == 'custom_id') {
668 668
 			$items = get_posts(
669 669
 				array(
670 670
 					'post_type'      => 'wpi_item',
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 			);
685 685
 		}
686 686
 
687
-		if ( empty( $items ) ) {
687
+		if (empty($items)) {
688 688
 			return 0;
689 689
 		}
690 690
 
691 691
 		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
692
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
693 693
 
694 694
 		return $items[0]->ID;
695 695
     }
@@ -697,19 +697,19 @@  discard block
 block discarded – undo
697 697
     /**
698 698
      * Margic method for retrieving a property.
699 699
      */
700
-    public function __get( $key ) {
700
+    public function __get($key) {
701 701
 
702 702
         // Check if we have a helper method for that.
703
-        if ( method_exists( $this, 'get_' . $key ) ) {
704
-            return call_user_func( array( $this, 'get_' . $key ) );
703
+        if (method_exists($this, 'get_' . $key)) {
704
+            return call_user_func(array($this, 'get_' . $key));
705 705
         }
706 706
 
707 707
         // Check if the key is in the associated $post object.
708
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
708
+        if (!empty($this->post) && isset($this->post->$key)) {
709 709
             return $this->post->$key;
710 710
         }
711 711
 
712
-        return $this->get_prop( $key );
712
+        return $this->get_prop($key);
713 713
 
714 714
     }
715 715
 
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
 	 *
729 729
 	 * @since 1.0.19
730 730
 	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
731
+	public function set_parent_id($value) {
732
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
733 733
 			return;
734 734
 		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
735
+		$this->set_prop('parent_id', absint($value));
736 736
 	}
737 737
 
738 738
     /**
@@ -742,10 +742,10 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $status New status.
743 743
 	 * @return array details of change.
744 744
 	 */
745
-	public function set_status( $status ) {
745
+	public function set_status($status) {
746 746
         $old_status = $this->get_status();
747 747
 
748
-        $this->set_prop( 'status', $status );
748
+        $this->set_prop('status', $status);
749 749
 
750 750
 		return array(
751 751
 			'from' => $old_status,
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @since 1.0.19
760 760
 	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
761
+	public function set_version($value) {
762
+		$this->set_prop('version', $value);
763 763
     }
764 764
 
765 765
     /**
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 	 * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771 771
 	 */
772
-	public function set_date_created( $value ) {
773
-        $date = strtotime( $value );
772
+	public function set_date_created($value) {
773
+        $date = strtotime($value);
774 774
 
775
-        if ( $date ) {
776
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
775
+        if ($date) {
776
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
777 777
             return true;
778 778
         }
779 779
 
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	 * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790 790
 	 */
791
-	public function set_date_modified( $value ) {
792
-        $date = strtotime( $value );
791
+	public function set_date_modified($value) {
792
+        $date = strtotime($value);
793 793
 
794
-        if ( $date ) {
795
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
794
+        if ($date) {
795
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
796 796
             return true;
797 797
         }
798 798
 
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
 	 * @since 1.0.19
807 807
 	 * @param  string $value New name.
808 808
 	 */
809
-	public function set_name( $value ) {
810
-        $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
809
+	public function set_name($value) {
810
+        $name = sanitize_text_field($value);
811
+		$this->set_prop('name', $name);
812 812
     }
813 813
 
814 814
     /**
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	 * @since 1.0.19
818 818
 	 * @param  string $value New name.
819 819
 	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
820
+	public function set_title($value) {
821
+		$this->set_name($value);
822 822
     }
823 823
 
824 824
     /**
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
 	 * @since 1.0.19
828 828
 	 * @param  string $value New description.
829 829
 	 */
830
-	public function set_description( $value ) {
831
-		$description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
830
+	public function set_description($value) {
831
+		$description = wp_kses_post($value);
832
+		return $this->set_prop('description', $description);
833 833
     }
834 834
 
835 835
     /**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @since 1.0.19
839 839
 	 * @param  string $value New description.
840 840
 	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
841
+	public function set_excerpt($value) {
842
+		$this->set_description($value);
843 843
     }
844 844
 
845 845
     /**
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	 * @since 1.0.19
849 849
 	 * @param  string $value New description.
850 850
 	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
851
+	public function set_summary($value) {
852
+		$this->set_description($value);
853 853
     }
854 854
 
855 855
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @since 1.0.19
859 859
 	 * @param  int $value New author.
860 860
 	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
861
+	public function set_author($value) {
862
+		$this->set_prop('author', (int) $value);
863 863
 	}
864 864
 	
865 865
 	/**
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	 * @since 1.0.19
869 869
 	 * @param  int $value New author.
870 870
 	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
871
+	public function set_owner($value) {
872
+		$this->set_author($value);
873 873
     }
874 874
 
875 875
     /**
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @since 1.0.19
879 879
 	 * @param  float $value New price.
880 880
 	 */
881
-	public function set_price( $value ) {
882
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
881
+	public function set_price($value) {
882
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
883 883
     }
884 884
 
885 885
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @since 1.0.19
889 889
 	 * @param  string $value new rule.
890 890
 	 */
891
-	public function set_vat_rule( $value ) {
892
-        $this->set_prop( 'vat_rule', $value );
891
+	public function set_vat_rule($value) {
892
+        $this->set_prop('vat_rule', $value);
893 893
     }
894 894
 
895 895
     /**
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 * @since 1.0.19
899 899
 	 * @param  string $value new class.
900 900
 	 */
901
-	public function set_vat_class( $value ) {
902
-        $this->set_prop( 'vat_class', $value );
901
+	public function set_vat_class($value) {
902
+        $this->set_prop('vat_class', $value);
903 903
     }
904 904
 
905 905
     /**
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
 	 * @param  string $value new item type.
910 910
 	 * @return string
911 911
 	 */
912
-	public function set_type( $value ) {
912
+	public function set_type($value) {
913 913
 
914
-        if ( empty( $value ) ) {
914
+        if (empty($value)) {
915 915
             $value = 'custom';
916 916
         }
917 917
 
918
-        $this->set_prop( 'type', $value );
918
+        $this->set_prop('type', $value);
919 919
     }
920 920
 
921 921
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @since 1.0.19
925 925
 	 * @param  string $value new custom id.
926 926
 	 */
927
-	public function set_custom_id( $value ) {
928
-        $this->set_prop( 'custom_id', $value );
927
+	public function set_custom_id($value) {
928
+        $this->set_prop('custom_id', $value);
929 929
     }
930 930
 
931 931
     /**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 	 * @since 1.0.19
935 935
 	 * @param  string $value new custom name.
936 936
 	 */
937
-	public function set_custom_name( $value ) {
938
-        $this->set_prop( 'custom_name', $value );
937
+	public function set_custom_name($value) {
938
+        $this->set_prop('custom_name', $value);
939 939
     }
940 940
 
941 941
     /**
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 	 * @since 1.0.19
945 945
 	 * @param  string $value new custom singular name.
946 946
 	 */
947
-	public function set_custom_singular_name( $value ) {
948
-        $this->set_prop( 'custom_singular_name', $value );
947
+	public function set_custom_singular_name($value) {
948
+        $this->set_prop('custom_singular_name', $value);
949 949
     }
950 950
 
951 951
     /**
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
 	 * @since 1.0.19
955 955
 	 * @param  int|bool $value whether or not the item is editable.
956 956
 	 */
957
-	public function set_is_editable( $value ) {
958
-		$this->set_prop( 'is_editable', (int) $value );
957
+	public function set_is_editable($value) {
958
+		$this->set_prop('is_editable', (int) $value);
959 959
     }
960 960
 
961 961
     /**
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
 	 * @since 1.0.19
965 965
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
966 966
 	 */
967
-	public function set_is_dynamic_pricing( $value ) {
968
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
967
+	public function set_is_dynamic_pricing($value) {
968
+        $this->set_prop('is_dynamic_pricing', (int) $value);
969 969
     }
970 970
 
971 971
     /**
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
 	 * @since 1.0.19
975 975
 	 * @param  float $value minimum price.
976 976
 	 */
977
-	public function set_minimum_price( $value ) {
978
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
977
+	public function set_minimum_price($value) {
978
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
979 979
     }
980 980
 
981 981
     /**
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
 	 * @since 1.0.19
985 985
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
986 986
 	 */
987
-	public function set_is_recurring( $value ) {
988
-        $this->set_prop( 'is_recurring', (int) $value );
987
+	public function set_is_recurring($value) {
988
+        $this->set_prop('is_recurring', (int) $value);
989 989
     }
990 990
 
991 991
     /**
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
 	 * @since 1.0.19
995 995
 	 * @param  string $value new period.
996 996
 	 */
997
-	public function set_recurring_period( $value ) {
998
-        $this->set_prop( 'recurring_period', $value );
997
+	public function set_recurring_period($value) {
998
+        $this->set_prop('recurring_period', $value);
999 999
     }
1000 1000
 
1001 1001
     /**
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 	 * @since 1.0.19
1005 1005
 	 * @param  int $value recurring interval.
1006 1006
 	 */
1007
-	public function set_recurring_interval( $value ) {
1008
-        return $this->set_prop( 'recurring_interval', (int) $value );
1007
+	public function set_recurring_interval($value) {
1008
+        return $this->set_prop('recurring_interval', (int) $value);
1009 1009
     }
1010 1010
 
1011 1011
     /**
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
 	 * @param  int $value The recurring limit.
1015 1015
 	 * @return int
1016 1016
 	 */
1017
-	public function set_recurring_limit( $value ) {
1018
-        $this->set_prop( 'recurring_limit', (int) $value );
1017
+	public function set_recurring_limit($value) {
1018
+        $this->set_prop('recurring_limit', (int) $value);
1019 1019
     }
1020 1020
 
1021 1021
     /**
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
 	 * @since 1.0.19
1025 1025
 	 * @param  int|bool $value whether or not it has a free trial.
1026 1026
 	 */
1027
-	public function set_is_free_trial( $value ) {
1028
-        $this->set_prop( 'is_free_trial', (int) $value );
1027
+	public function set_is_free_trial($value) {
1028
+        $this->set_prop('is_free_trial', (int) $value);
1029 1029
     }
1030 1030
 
1031 1031
     /**
@@ -1034,8 +1034,8 @@  discard block
 block discarded – undo
1034 1034
 	 * @since 1.0.19
1035 1035
 	 * @param  string $value trial period.
1036 1036
 	 */
1037
-	public function set_trial_period( $value ) {
1038
-        $this->set_prop( 'trial_period', $value );
1037
+	public function set_trial_period($value) {
1038
+        $this->set_prop('trial_period', $value);
1039 1039
     }
1040 1040
 
1041 1041
     /**
@@ -1044,8 +1044,8 @@  discard block
 block discarded – undo
1044 1044
 	 * @since 1.0.19
1045 1045
 	 * @param  int $value trial interval.
1046 1046
 	 */
1047
-	public function set_trial_interval( $value ) {
1048
-        $this->set_prop( 'trial_interval', $value );
1047
+	public function set_trial_interval($value) {
1048
+        $this->set_prop('trial_interval', $value);
1049 1049
     }
1050 1050
 
1051 1051
     /**
@@ -1054,11 +1054,11 @@  discard block
 block discarded – undo
1054 1054
      * @deprecated
1055 1055
 	 * @return int item id
1056 1056
      */
1057
-    public function create( $data = array() ) {
1057
+    public function create($data = array()) {
1058 1058
 
1059 1059
 		// Set the properties.
1060
-		if ( is_array( $data ) ) {
1061
-			$this->set_props( $data );
1060
+		if (is_array($data)) {
1061
+			$this->set_props($data);
1062 1062
 		}
1063 1063
 
1064 1064
 		// Save the item.
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
      * @deprecated
1073 1073
 	 * @return int item id
1074 1074
      */
1075
-    public function update( $data = array() ) {
1076
-        return $this->create( $data );
1075
+    public function update($data = array()) {
1076
+        return $this->create($data);
1077 1077
     }
1078 1078
 
1079 1079
     /*
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	 */
1114 1114
     public function has_free_trial() {
1115 1115
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1116
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1116
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1117 1117
     }
1118 1118
 
1119 1119
     /**
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 	 * @return bool
1124 1124
 	 */
1125 1125
     public function is_free() {
1126
-        $is_free   = $this->get_price() == 0;
1127
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1126
+        $is_free = $this->get_price() == 0;
1127
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1128 1128
     }
1129 1129
 
1130 1130
     /**
@@ -1133,9 +1133,9 @@  discard block
 block discarded – undo
1133 1133
 	 * @param array|string $status Status to check.
1134 1134
 	 * @return bool
1135 1135
 	 */
1136
-	public function has_status( $status ) {
1137
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1138
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1136
+	public function has_status($status) {
1137
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1138
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1139 1139
     }
1140 1140
 
1141 1141
     /**
@@ -1144,9 +1144,9 @@  discard block
 block discarded – undo
1144 1144
 	 * @param array|string $type Type to check.
1145 1145
 	 * @return bool
1146 1146
 	 */
1147
-	public function is_type( $type ) {
1148
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1149
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1147
+	public function is_type($type) {
1148
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1149
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1150 1150
 	}
1151 1151
 
1152 1152
     /**
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
     public function is_editable() {
1159 1159
         $is_editable = $this->get_is_editable();
1160
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1160
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1161 1161
 	}
1162 1162
 
1163 1163
 	/**
@@ -1176,11 +1176,11 @@  discard block
 block discarded – undo
1176 1176
     public function can_purchase() {
1177 1177
         $can_purchase = $this->exists();
1178 1178
 
1179
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1179
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1180 1180
             $can_purchase = false;
1181 1181
         }
1182 1182
 
1183
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1183
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1184 1184
     }
1185 1185
 
1186 1186
     /**
@@ -1190,6 +1190,6 @@  discard block
 block discarded – undo
1190 1190
 	 * @return bool
1191 1191
 	 */
1192 1192
     public function supports_dynamic_pricing() {
1193
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1193
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1194 1194
     }
1195 1195
 }
Please login to merge, or discard this patch.