@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
|
7 | -$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
|
6 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text')); |
|
7 | +$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : ''; |
|
8 | 8 | ?> |
9 | 9 | </div> |
10 | 10 | </td> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
7 | 8 | $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -if ( !isset( $email_heading ) ) { |
|
6 | +if (!isset($email_heading)) { |
|
7 | 7 | global $email_heading; |
8 | 8 | } |
9 | 9 | ?> |
10 | 10 | <!DOCTYPE html> |
11 | 11 | <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>"> |
12 | 12 | <head> |
13 | - <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> |
|
13 | + <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> |
|
14 | 14 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
15 | 15 | <meta name="robots" content="noindex,nofollow"> |
16 | 16 | <title><?php echo wpinv_get_blogname(); ?></title> |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | <td align="center" valign="top"> |
23 | 23 | <div id="template_header_image"> |
24 | 24 | <?php |
25 | - if ( $img = wpinv_get_option( 'email_header_image' ) ) { |
|
26 | - echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>'; |
|
25 | + if ($img = wpinv_get_option('email_header_image')) { |
|
26 | + echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>'; |
|
27 | 27 | } |
28 | 28 | ?> |
29 | 29 | </div> |
30 | 30 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container"> |
31 | - <?php if ( !empty( $email_heading ) ) { ?> |
|
31 | + <?php if (!empty($email_heading)) { ?> |
|
32 | 32 | <tr> |
33 | 33 | <td align="center" valign="top"> |
34 | 34 | <!-- Header --> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | if ( !isset( $email_heading ) ) { |
7 | 8 | global $email_heading; |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
7 | 8 | <div id="wpinv-email-billing"> |
@@ -1,41 +1,41 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
|
6 | +do_action('wpinv_email_before_billing_details', $invoice); ?> |
|
7 | 7 | <div id="wpinv-email-billing"> |
8 | - <h3 class="wpinv-address-t"><?php echo apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ); ?></h3> |
|
8 | + <h3 class="wpinv-address-t"><?php echo apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing')); ?></h3> |
|
9 | 9 | |
10 | 10 | <table class="table table-bordered table-sm wpi-billing-details"> |
11 | 11 | <tbody> |
12 | - <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?> |
|
12 | + <?php do_action('wpinv_email_billing_fields_first', $invoice); ?> |
|
13 | 13 | <tr class="wpi-receipt-name"> |
14 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
15 | - <td><?php if ( $sent_to_admin && $invoice->get_user_id() ) { ?><a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ) ;?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a><?php } else { echo esc_html( $invoice->get_user_full_name() ); } ?></td> |
|
14 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
15 | + <td><?php if ($sent_to_admin && $invoice->get_user_id()) { ?><a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a><?php } else { echo esc_html($invoice->get_user_full_name()); } ?></td> |
|
16 | 16 | </tr> |
17 | 17 | <tr class="wpi-receipt-email"> |
18 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
19 | - <td><?php echo $invoice->get_email() ;?></td> |
|
18 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
19 | + <td><?php echo $invoice->get_email(); ?></td> |
|
20 | 20 | </tr> |
21 | - <?php if ( $invoice->get_company() ) { ?> |
|
21 | + <?php if ($invoice->get_company()) { ?> |
|
22 | 22 | <tr class="wpi-receipt-company"> |
23 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
24 | - <td><?php echo esc_html( $invoice->get_company() ) ;?></td> |
|
23 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
24 | + <td><?php echo esc_html($invoice->get_company()); ?></td> |
|
25 | 25 | </tr> |
26 | 26 | <?php } ?> |
27 | 27 | <tr class="wpi-receipt-address"> |
28 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
29 | - <td><?php echo wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ;?></td> |
|
28 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
29 | + <td><?php echo wpinv_get_invoice_address_markup($invoice->get_user_info()); ?></td> |
|
30 | 30 | </tr> |
31 | - <?php if ( $invoice->get_phone() ) { ?> |
|
31 | + <?php if ($invoice->get_phone()) { ?> |
|
32 | 32 | <tr class="wpi-receipt-phone"> |
33 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
34 | - <td><?php echo esc_html( $invoice->get_phone() ) ;?></td> |
|
33 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
34 | + <td><?php echo esc_html($invoice->get_phone()); ?></td> |
|
35 | 35 | </tr> |
36 | 36 | <?php } ?> |
37 | - <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?> |
|
37 | + <?php do_action('wpinv_email_billing_fields_last', $invoice); ?> |
|
38 | 38 | </tbody> |
39 | 39 | </table> |
40 | 40 | </div> |
41 | -<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?> |
|
42 | 41 | \ No newline at end of file |
42 | +<?php do_action('wpinv_email_after_billing_details', $invoice); ?> |
|
43 | 43 | \ No newline at end of file |
@@ -196,8 +196,9 @@ |
||
196 | 196 | foreach ( $types as $name => $type ) { |
197 | 197 | echo '<option value="' . esc_attr( $name ) . '"'; |
198 | 198 | |
199 | - if ( isset( $_GET['discount_type'] ) ) |
|
200 | - selected( $name, $_GET['discount_type'] ); |
|
199 | + if ( isset( $_GET['discount_type'] ) ) { |
|
200 | + selected( $name, $_GET['discount_type'] ); |
|
201 | + } |
|
201 | 202 | |
202 | 203 | echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
203 | 204 | } |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code' : |
15 | 15 | echo $discount->get_code(); |
16 | 16 | break; |
@@ -21,37 +21,37 @@ discard block |
||
21 | 21 | echo $discount->get_usage(); |
22 | 22 | break; |
23 | 23 | case 'start_date' : |
24 | - echo getpaid_format_date_value( $discount->get_start_date() ); |
|
24 | + echo getpaid_format_date_value($discount->get_start_date()); |
|
25 | 25 | break; |
26 | 26 | case 'expiry_date' : |
27 | - echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ); |
|
27 | + echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
34 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
33 | +function wpinv_post_row_actions($actions, $post) { |
|
34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
35 | 35 | |
36 | - if ( $post_type == 'wpi_invoice' ) { |
|
36 | + if ($post_type == 'wpi_invoice') { |
|
37 | 37 | $actions = array(); |
38 | 38 | } |
39 | 39 | |
40 | - if ( $post_type == 'wpi_discount' ) { |
|
41 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
40 | + if ($post_type == 'wpi_discount') { |
|
41 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return $actions; |
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
48 | - $row_actions = array(); |
|
49 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
50 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
47 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
48 | + $row_actions = array(); |
|
49 | + $edit_link = get_edit_post_link($discount->ID); |
|
50 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
51 | 51 | |
52 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
52 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
53 | 53 | |
54 | - $url = esc_url( |
|
54 | + $url = esc_url( |
|
55 | 55 | wp_nonce_url( |
56 | 56 | add_query_arg( |
57 | 57 | array( |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | 'getpaid-nonce' |
64 | 64 | ) |
65 | 65 | ); |
66 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
67 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
66 | + $anchor = __('Deactivate', 'invoicing'); |
|
67 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
68 | 68 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
69 | 69 | |
70 | - } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
70 | + } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
71 | 71 | |
72 | - $url = esc_url( |
|
72 | + $url = esc_url( |
|
73 | 73 | wp_nonce_url( |
74 | 74 | add_query_arg( |
75 | 75 | array( |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | 'getpaid-nonce' |
82 | 82 | ) |
83 | 83 | ); |
84 | - $anchor = __( 'Activate', 'invoicing' ); |
|
85 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
84 | + $anchor = __('Activate', 'invoicing'); |
|
85 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
86 | 86 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
87 | 87 | |
88 | 88 | } |
89 | 89 | |
90 | - $url = esc_url( |
|
90 | + $url = esc_url( |
|
91 | 91 | wp_nonce_url( |
92 | 92 | add_query_arg( |
93 | 93 | array( |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | 'getpaid-nonce' |
100 | 100 | ) |
101 | 101 | ); |
102 | - $anchor = __( 'Delete', 'invoicing' ); |
|
103 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
102 | + $anchor = __('Delete', 'invoicing'); |
|
103 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
104 | 104 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
105 | 105 | |
106 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
106 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
107 | 107 | |
108 | 108 | return $row_actions; |
109 | 109 | } |
@@ -111,68 +111,68 @@ discard block |
||
111 | 111 | function wpinv_restrict_manage_posts() { |
112 | 112 | global $typenow; |
113 | 113 | |
114 | - if( 'wpi_discount' == $typenow ) { |
|
114 | + if ('wpi_discount' == $typenow) { |
|
115 | 115 | wpinv_discount_filters(); |
116 | 116 | } |
117 | 117 | } |
118 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
118 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
119 | 119 | |
120 | 120 | function wpinv_discount_filters() { |
121 | 121 | |
122 | 122 | ?> |
123 | 123 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
124 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
124 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
125 | 125 | <?php |
126 | 126 | $types = wpinv_get_discount_types(); |
127 | 127 | |
128 | - foreach ( $types as $name => $type ) { |
|
129 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
128 | + foreach ($types as $name => $type) { |
|
129 | + echo '<option value="' . esc_attr($name) . '"'; |
|
130 | 130 | |
131 | - if ( isset( $_GET['discount_type'] ) ) |
|
132 | - selected( $name, $_GET['discount_type'] ); |
|
131 | + if (isset($_GET['discount_type'])) |
|
132 | + selected($name, $_GET['discount_type']); |
|
133 | 133 | |
134 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
134 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
135 | 135 | } |
136 | 136 | ?> |
137 | 137 | </select> |
138 | 138 | <?php |
139 | 139 | } |
140 | 140 | |
141 | -function wpinv_request( $vars ) { |
|
141 | +function wpinv_request($vars) { |
|
142 | 142 | global $typenow, $wp_post_statuses; |
143 | 143 | |
144 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
145 | - if ( ! isset( $vars['post_status'] ) ) { |
|
146 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
144 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
145 | + if (!isset($vars['post_status'])) { |
|
146 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
147 | 147 | |
148 | - foreach ( $post_statuses as $status => $value ) { |
|
149 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
150 | - unset( $post_statuses[ $status ] ); |
|
148 | + foreach ($post_statuses as $status => $value) { |
|
149 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
150 | + unset($post_statuses[$status]); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
154 | + $vars['post_status'] = array_keys($post_statuses); |
|
155 | 155 | } |
156 | 156 | |
157 | - } else if ( 'wpi_discount' == $typenow ) { |
|
158 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
157 | + } else if ('wpi_discount' == $typenow) { |
|
158 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
159 | 159 | // Filter vat rule type |
160 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
160 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
161 | 161 | $meta_query[] = array( |
162 | 162 | 'key' => '_wpi_discount_type', |
163 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
163 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
164 | 164 | 'compare' => '=' |
165 | 165 | ); |
166 | 166 | } |
167 | 167 | |
168 | - if ( !empty( $meta_query ) ) { |
|
168 | + if (!empty($meta_query)) { |
|
169 | 169 | $vars['meta_query'] = $meta_query; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | 173 | return $vars; |
174 | 174 | } |
175 | -add_filter( 'request', 'wpinv_request' ); |
|
175 | +add_filter('request', 'wpinv_request'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Create a page and store the ID in an option. |
@@ -184,19 +184,19 @@ discard block |
||
184 | 184 | * @param int $post_parent (default: 0) Parent for the new page |
185 | 185 | * @return int page ID |
186 | 186 | */ |
187 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
187 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
188 | 188 | global $wpdb; |
189 | 189 | |
190 | - $option_value = wpinv_get_option( $option ); |
|
190 | + $option_value = wpinv_get_option($option); |
|
191 | 191 | |
192 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
193 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
192 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
193 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
194 | 194 | // Valid page is already in place |
195 | 195 | return $page_object->ID; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - if(!empty($post_parent)){ |
|
199 | + if (!empty($post_parent)) { |
|
200 | 200 | $page = get_page_by_path($post_parent); |
201 | 201 | if ($page) { |
202 | 202 | $post_parent = $page->ID; |
@@ -205,40 +205,40 @@ discard block |
||
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - if ( strlen( $page_content ) > 0 ) { |
|
208 | + if (strlen($page_content) > 0) { |
|
209 | 209 | // Search for an existing page with the specified page content (typically a shortcode) |
210 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
210 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
211 | 211 | } else { |
212 | 212 | // Search for an existing page with the specified page slug |
213 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
213 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
214 | 214 | } |
215 | 215 | |
216 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
216 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
217 | 217 | |
218 | - if ( $valid_page_found ) { |
|
219 | - if ( $option ) { |
|
220 | - wpinv_update_option( $option, $valid_page_found ); |
|
218 | + if ($valid_page_found) { |
|
219 | + if ($option) { |
|
220 | + wpinv_update_option($option, $valid_page_found); |
|
221 | 221 | } |
222 | 222 | return $valid_page_found; |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Search for a matching valid trashed page |
226 | - if ( strlen( $page_content ) > 0 ) { |
|
226 | + if (strlen($page_content) > 0) { |
|
227 | 227 | // Search for an existing page with the specified page content (typically a shortcode) |
228 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
228 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
229 | 229 | } else { |
230 | 230 | // Search for an existing page with the specified page slug |
231 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
231 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( $trashed_page_found ) { |
|
234 | + if ($trashed_page_found) { |
|
235 | 235 | $page_id = $trashed_page_found; |
236 | 236 | $page_data = array( |
237 | 237 | 'ID' => $page_id, |
238 | 238 | 'post_status' => 'publish', |
239 | 239 | 'post_parent' => $post_parent, |
240 | 240 | ); |
241 | - wp_update_post( $page_data ); |
|
241 | + wp_update_post($page_data); |
|
242 | 242 | } else { |
243 | 243 | $page_data = array( |
244 | 244 | 'post_status' => 'publish', |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | 'post_parent' => $post_parent, |
251 | 251 | 'comment_status' => 'closed', |
252 | 252 | ); |
253 | - $page_id = wp_insert_post( $page_data ); |
|
253 | + $page_id = wp_insert_post($page_data); |
|
254 | 254 | } |
255 | 255 | |
256 | - if ( $option ) { |
|
257 | - wpinv_update_option( $option, (int)$page_id ); |
|
256 | + if ($option) { |
|
257 | + wpinv_update_option($option, (int) $page_id); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return $page_id; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
311 | 311 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
312 | 312 | $enabled_gateway = wpinv_get_default_gateway(); |
313 | - }else{ |
|
313 | + } else{ |
|
314 | 314 | $enabled_gateway = $gateways[0]; |
315 | 315 | } |
316 | 316 | |
@@ -336,8 +336,9 @@ discard block |
||
336 | 336 | |
337 | 337 | $payments = new WP_Query( $args ); |
338 | 338 | |
339 | - if( $payments ) |
|
340 | - $ret = $payments->post_count; |
|
339 | + if( $payments ) { |
|
340 | + $ret = $payments->post_count; |
|
341 | + } |
|
341 | 342 | return $ret; |
342 | 343 | } |
343 | 344 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains gateway functions. |
4 | 4 | * |
5 | 5 | */ |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Returns an array of payment gateways. |
@@ -11,82 +11,82 @@ discard block |
||
11 | 11 | * @return array |
12 | 12 | */ |
13 | 13 | function wpinv_get_payment_gateways() { |
14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
15 | 15 | } |
16 | 16 | |
17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
18 | 18 | global $wpinv_options; |
19 | 19 | |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
23 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - asort( $gateways ); |
|
29 | + asort($gateways); |
|
30 | 30 | |
31 | - foreach ( $gateways as $gateway => $key ) { |
|
31 | + foreach ($gateways as $gateway => $key) { |
|
32 | 32 | $gateways[$gateway] = $all_gateways[$gateway]; |
33 | 33 | } |
34 | 34 | |
35 | 35 | return $gateways; |
36 | 36 | } |
37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
38 | 38 | |
39 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
39 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
40 | 40 | $gateways = wpinv_get_payment_gateways(); |
41 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
41 | + $enabled = wpinv_get_option('gateways', false); |
|
42 | 42 | |
43 | 43 | $gateway_list = array(); |
44 | 44 | |
45 | - foreach ( $gateways as $key => $gateway ) { |
|
46 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
47 | - $gateway_list[ $key ] = $gateway; |
|
45 | + foreach ($gateways as $key => $gateway) { |
|
46 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
47 | + $gateway_list[$key] = $gateway; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - if ( true === $sort ) { |
|
52 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
51 | + if (true === $sort) { |
|
52 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
53 | 53 | |
54 | 54 | // Reorder our gateways so the default is first |
55 | 55 | $default_gateway_id = wpinv_get_default_gateway(); |
56 | 56 | |
57 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
58 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
59 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
57 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
58 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
59 | + unset($gateway_list[$default_gateway_id]); |
|
60 | 60 | |
61 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
61 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
65 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
66 | 66 | } |
67 | 67 | |
68 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
68 | +function wpinv_sort_gateway_order($a, $b) { |
|
69 | 69 | return $a['ordering'] - $b['ordering']; |
70 | 70 | } |
71 | 71 | |
72 | -function wpinv_is_gateway_active( $gateway ) { |
|
72 | +function wpinv_is_gateway_active($gateway) { |
|
73 | 73 | $gateways = wpinv_get_enabled_payment_gateways(); |
74 | 74 | |
75 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
75 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
76 | 76 | |
77 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
77 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | function wpinv_get_default_gateway() { |
81 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
81 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
82 | 82 | |
83 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
83 | + if (!wpinv_is_gateway_active($default)) { |
|
84 | 84 | $gateways = wpinv_get_enabled_payment_gateways(); |
85 | - $gateways = array_keys( $gateways ); |
|
86 | - $default = reset( $gateways ); |
|
85 | + $gateways = array_keys($gateways); |
|
86 | + $default = reset($gateways); |
|
87 | 87 | } |
88 | 88 | |
89 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
89 | + return apply_filters('wpinv_default_gateway', $default); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | * @param string $gateway The gateway to key. |
96 | 96 | * @return string |
97 | 97 | */ |
98 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
98 | +function wpinv_get_gateway_admin_label($gateway) { |
|
99 | 99 | |
100 | - if ( empty( $gateway ) || 'none' == $gateway ) { |
|
101 | - return esc_html__( 'No Gateway', 'invoicing' ); |
|
100 | + if (empty($gateway) || 'none' == $gateway) { |
|
101 | + return esc_html__('No Gateway', 'invoicing'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $gateways = wpinv_get_payment_gateways(); |
105 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
106 | - $gateway = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
105 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
106 | + $gateway = apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
107 | 107 | |
108 | - return wpinv_clean( $gateway ); |
|
108 | + return wpinv_clean($gateway); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -113,49 +113,49 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @param string $gateway |
115 | 115 | */ |
116 | -function wpinv_get_gateway_description( $gateway ) { |
|
116 | +function wpinv_get_gateway_description($gateway) { |
|
117 | 117 | global $wpinv_options; |
118 | 118 | |
119 | - $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
119 | + $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
120 | 120 | |
121 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
121 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
122 | 122 | } |
123 | 123 | |
124 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
125 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
124 | +function wpinv_get_gateway_button_label($gateway) { |
|
125 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
126 | 126 | } |
127 | 127 | |
128 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
128 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
129 | 129 | $gateways = wpinv_get_payment_gateways(); |
130 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
130 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
131 | 131 | |
132 | - if ( $gateway == 'none' ) { |
|
133 | - $label = __( 'None', 'invoicing' ); |
|
132 | + if ($gateway == 'none') { |
|
133 | + $label = __('None', 'invoicing'); |
|
134 | 134 | } |
135 | 135 | |
136 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
136 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_settings_sections_gateways( $settings ) { |
|
139 | +function wpinv_settings_sections_gateways($settings) { |
|
140 | 140 | $gateways = wpinv_get_payment_gateways(); |
141 | 141 | |
142 | 142 | if (!empty($gateways)) { |
143 | - foreach ($gateways as $key => $gateway) { |
|
143 | + foreach ($gateways as $key => $gateway) { |
|
144 | 144 | $settings[$key] = $gateway['admin_label']; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | return $settings; |
149 | 149 | } |
150 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
150 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Adds GateWay settings. |
154 | 154 | */ |
155 | -function wpinv_settings_gateways( $settings ) { |
|
155 | +function wpinv_settings_gateways($settings) { |
|
156 | 156 | |
157 | 157 | // Loop through each gateway. |
158 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
158 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
159 | 159 | |
160 | 160 | $gateway_settings = array( |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | "{$key}_header" => array( |
164 | 164 | |
165 | 165 | 'id' => "{$key}_gateway_header", |
166 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
166 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
167 | 167 | 'custom' => $key, |
168 | 168 | 'type' => 'gateway_header', |
169 | 169 | |
@@ -172,56 +172,56 @@ discard block |
||
172 | 172 | // Activate/Deactivate a gateway. |
173 | 173 | "{$key}_active" => array( |
174 | 174 | 'id' => $key . '_active', |
175 | - 'name' => __( 'Activate', 'invoicing' ), |
|
176 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
175 | + 'name' => __('Activate', 'invoicing'), |
|
176 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
177 | 177 | 'type' => 'checkbox', |
178 | 178 | ), |
179 | 179 | |
180 | 180 | // Activate/Deactivate sandbox. |
181 | 181 | "{$key}_sandbox" => array( |
182 | 182 | 'id' => $key . '_sandbox', |
183 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
184 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
183 | + 'name' => __('Sandbox', 'invoicing'), |
|
184 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
185 | 185 | 'type' => 'checkbox', |
186 | 186 | ), |
187 | 187 | |
188 | 188 | // Checkout title. |
189 | 189 | "{$key}_title" => array( |
190 | 190 | 'id' => $key . '_title', |
191 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
192 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
191 | + 'name' => __('Checkout Title', 'invoicing'), |
|
192 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
193 | 193 | 'type' => 'text', |
194 | 194 | ), |
195 | 195 | |
196 | 196 | // Checkout description. |
197 | 197 | "{$key}_desc" => array( |
198 | 198 | 'id' => $key . '_desc', |
199 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
200 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
199 | + 'name' => __('Checkout Description', 'invoicing'), |
|
200 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
201 | 201 | 'type' => 'text', |
202 | 202 | ), |
203 | 203 | |
204 | 204 | // Checkout order. |
205 | 205 | "{$key}_ordering" => array( |
206 | 206 | 'id' => $key . '_ordering', |
207 | - 'name' => __( 'Priority', 'invoicing' ), |
|
208 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
207 | + 'name' => __('Priority', 'invoicing'), |
|
208 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
209 | 209 | 'type' => 'number', |
210 | 210 | 'step' => '1', |
211 | 211 | 'min' => '-100000', |
212 | 212 | 'max' => '100000', |
213 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
213 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
214 | 214 | ), |
215 | 215 | |
216 | 216 | ); |
217 | 217 | |
218 | 218 | // Maybe remove the sandbox. |
219 | - if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) { |
|
220 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
219 | + if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) { |
|
220 | + unset($gateway_settings["{$key}_sandbox"]); |
|
221 | 221 | } |
222 | 222 | |
223 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
224 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
223 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
224 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
225 | 225 | |
226 | 226 | $settings[$key] = $gateway_settings; |
227 | 227 | } |
@@ -229,57 +229,57 @@ discard block |
||
229 | 229 | return $settings; |
230 | 230 | |
231 | 231 | } |
232 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
232 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
233 | 233 | |
234 | -function wpinv_gateway_header_callback( $args ) { |
|
235 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
234 | +function wpinv_gateway_header_callback($args) { |
|
235 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
236 | 236 | } |
237 | 237 | |
238 | -function wpinv_get_gateway_supports( $gateway ) { |
|
238 | +function wpinv_get_gateway_supports($gateway) { |
|
239 | 239 | $gateways = wpinv_get_enabled_payment_gateways(); |
240 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
241 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
240 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
241 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
242 | 242 | } |
243 | 243 | |
244 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
245 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
244 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
245 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
246 | 246 | |
247 | 247 | $chosen = false; |
248 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
248 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
249 | 249 | $chosen = $invoice->get_gateway(); |
250 | 250 | } |
251 | 251 | |
252 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
252 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
253 | 253 | |
254 | - if ( false !== $chosen ) { |
|
255 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
254 | + if (false !== $chosen) { |
|
255 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
256 | 256 | } |
257 | 257 | |
258 | - if ( ! empty ( $chosen ) ) { |
|
259 | - $enabled_gateway = urldecode( $chosen ); |
|
260 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
258 | + if (!empty ($chosen)) { |
|
259 | + $enabled_gateway = urldecode($chosen); |
|
260 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
261 | 261 | $enabled_gateway = 'manual'; |
262 | 262 | } else { |
263 | 263 | $enabled_gateway = wpinv_get_default_gateway(); |
264 | 264 | } |
265 | 265 | |
266 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
267 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
266 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
267 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
268 | 268 | $enabled_gateway = wpinv_get_default_gateway(); |
269 | - }else{ |
|
269 | + } else { |
|
270 | 270 | $enabled_gateway = $gateways[0]; |
271 | 271 | } |
272 | 272 | |
273 | 273 | } |
274 | 274 | |
275 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
275 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
276 | 276 | } |
277 | 277 | |
278 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
279 | - return wpinv_error_log( $message, $title ); |
|
278 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
279 | + return wpinv_error_log($message, $title); |
|
280 | 280 | } |
281 | 281 | |
282 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
282 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
283 | 283 | $ret = 0; |
284 | 284 | $args = array( |
285 | 285 | 'meta_key' => '_wpinv_gateway', |
@@ -290,48 +290,48 @@ discard block |
||
290 | 290 | 'fields' => 'ids' |
291 | 291 | ); |
292 | 292 | |
293 | - $payments = new WP_Query( $args ); |
|
293 | + $payments = new WP_Query($args); |
|
294 | 294 | |
295 | - if( $payments ) |
|
295 | + if ($payments) |
|
296 | 296 | $ret = $payments->post_count; |
297 | 297 | return $ret; |
298 | 298 | } |
299 | 299 | |
300 | -function wpinv_settings_update_gateways( $input ) { |
|
300 | +function wpinv_settings_update_gateways($input) { |
|
301 | 301 | global $wpinv_options; |
302 | 302 | |
303 | - if ( !empty( $input['save_gateway'] ) ) { |
|
304 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
303 | + if (!empty($input['save_gateway'])) { |
|
304 | + $gateways = wpinv_get_option('gateways', false); |
|
305 | 305 | $gateways = !empty($gateways) ? $gateways : array(); |
306 | 306 | $gateway = $input['save_gateway']; |
307 | 307 | |
308 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
308 | + if (!empty($input[$gateway . '_active'])) { |
|
309 | 309 | $gateways[$gateway] = 1; |
310 | 310 | } else { |
311 | - if ( isset( $gateways[$gateway] ) ) { |
|
312 | - unset( $gateways[$gateway] ); |
|
311 | + if (isset($gateways[$gateway])) { |
|
312 | + unset($gateways[$gateway]); |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | 316 | $input['gateways'] = $gateways; |
317 | 317 | } |
318 | 318 | |
319 | - if ( !empty( $input['default_gateway'] ) ) { |
|
319 | + if (!empty($input['default_gateway'])) { |
|
320 | 320 | $gateways = wpinv_get_payment_gateways(); |
321 | 321 | |
322 | - foreach ( $gateways as $key => $gateway ) { |
|
323 | - $active = 0; |
|
324 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
322 | + foreach ($gateways as $key => $gateway) { |
|
323 | + $active = 0; |
|
324 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
325 | 325 | $active = 1; |
326 | 326 | } |
327 | 327 | |
328 | 328 | $input[$key . '_active'] = $active; |
329 | 329 | |
330 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
330 | + if (empty($wpinv_options[$key . '_title'])) { |
|
331 | 331 | $input[$key . '_title'] = $gateway['checkout_label']; |
332 | 332 | } |
333 | 333 | |
334 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
334 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
335 | 335 | $input[$key . '_ordering'] = $gateway['ordering']; |
336 | 336 | } |
337 | 337 | } |
@@ -339,27 +339,27 @@ discard block |
||
339 | 339 | |
340 | 340 | return $input; |
341 | 341 | } |
342 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
342 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
343 | 343 | |
344 | 344 | // PayPal Standard settings |
345 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
346 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
347 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
345 | +function wpinv_gateway_settings_paypal($setting) { |
|
346 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
347 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
348 | 348 | |
349 | 349 | $setting['paypal_sandbox'] = array( |
350 | 350 | 'type' => 'checkbox', |
351 | 351 | 'id' => 'paypal_sandbox', |
352 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
353 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
352 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
353 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
354 | 354 | 'std' => 1 |
355 | 355 | ); |
356 | 356 | |
357 | 357 | $setting['paypal_email'] = array( |
358 | 358 | 'type' => 'text', |
359 | 359 | 'id' => 'paypal_email', |
360 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
361 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
362 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
360 | + 'name' => __('PayPal Email', 'invoicing'), |
|
361 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
362 | + 'std' => __('[email protected]', 'invoicing'), |
|
363 | 363 | ); |
364 | 364 | /* |
365 | 365 | $setting['paypal_ipn_url'] = array( |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | |
374 | 374 | return $setting; |
375 | 375 | } |
376 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
376 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Displays the ipn url field. |
380 | 380 | */ |
381 | -function wpinv_ipn_url_callback( $args ) { |
|
382 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
381 | +function wpinv_ipn_url_callback($args) { |
|
382 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
383 | 383 | |
384 | 384 | $attrs = $args['readonly'] ? ' readonly' : ''; |
385 | 385 | |
386 | - $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
387 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
386 | + $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
387 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
388 | 388 | |
389 | 389 | echo $html; |
390 | 390 | } |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return bool |
398 | 398 | */ |
399 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
400 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false ); |
|
401 | - return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway ); |
|
399 | +function wpinv_is_test_mode($gateway = '') { |
|
400 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false); |
|
401 | + return apply_filters('wpinv_is_test_mode', $sandbox, $gateway); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return string |
411 | 411 | */ |
412 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
412 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
413 | 413 | $args = wp_parse_args( |
414 | 414 | array( |
415 | 415 | 'wpi-listener' => 'IPN', |
@@ -418,37 +418,37 @@ discard block |
||
418 | 418 | $args |
419 | 419 | ); |
420 | 420 | |
421 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
421 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
426 | 426 | * Retrieves request data with slashes removed slashes. |
427 | 427 | */ |
428 | -function wpinv_get_post_data( $method = 'request' ) { |
|
428 | +function wpinv_get_post_data($method = 'request') { |
|
429 | 429 | |
430 | - if ( $method == 'post' ) { |
|
431 | - return wp_unslash( $_POST ); |
|
430 | + if ($method == 'post') { |
|
431 | + return wp_unslash($_POST); |
|
432 | 432 | } |
433 | 433 | |
434 | - if ( $method == 'get' ) { |
|
435 | - return wp_unslash( $_GET ); |
|
434 | + if ($method == 'get') { |
|
435 | + return wp_unslash($_GET); |
|
436 | 436 | } |
437 | 437 | |
438 | - return wp_unslash( $_REQUEST ); |
|
438 | + return wp_unslash($_REQUEST); |
|
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
443 | 443 | * Checks if a given gateway supports subscription payments. |
444 | 444 | */ |
445 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
445 | +function wpinv_gateway_support_subscription($gateway) { |
|
446 | 446 | $supports = false; |
447 | 447 | |
448 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
449 | - $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports ); |
|
448 | + if (wpinv_is_gateway_active($gateway)) { |
|
449 | + $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports); |
|
450 | 450 | |
451 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway ); |
|
451 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | return $supports; |
@@ -460,14 +460,14 @@ discard block |
||
460 | 460 | * @param array $gateways an array of gateways. |
461 | 461 | * @param GetPaid_Payment_Form $form payment form. |
462 | 462 | */ |
463 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
463 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
464 | 464 | |
465 | - if ( $form->is_recurring() ) { |
|
465 | + if ($form->is_recurring()) { |
|
466 | 466 | |
467 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
467 | + foreach (array_keys($gateways) as $gateway) { |
|
468 | 468 | |
469 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
470 | - unset( $gateways[$gateway] ); |
|
469 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
470 | + unset($gateways[$gateway]); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | } |
@@ -476,4 +476,4 @@ discard block |
||
476 | 476 | |
477 | 477 | return $gateways; |
478 | 478 | } |
479 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
479 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | if ($nodesWithStyleAttributes !== false) { |
239 | 239 | /** @var $nodeWithStyleAttribute DOMNode */ |
240 | 240 | foreach ($nodesWithStyleAttributes as $node) { |
241 | - $normalizedOriginalStyle = preg_replace_callback( '/[A-z\\-]+(?=\\:)/S', array( $this, 'strtolower' ), $node->getAttribute('style') ); |
|
241 | + $normalizedOriginalStyle = preg_replace_callback('/[A-z\\-]+(?=\\:)/S', array($this, 'strtolower'), $node->getAttribute('style')); |
|
242 | 242 | |
243 | 243 | // in order to not overwrite existing style attributes in the HTML, we have to save the original HTML styles |
244 | 244 | $nodePath = $node->getNodePath(); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | // now sort the selectors by precedence |
292 | - usort($allSelectors, array($this,'sortBySelectorPrecedence')); |
|
292 | + usort($allSelectors, array($this, 'sortBySelectorPrecedence')); |
|
293 | 293 | |
294 | 294 | $this->caches[self::CACHE_KEY_CSS][$cssKey] = $allSelectors; |
295 | 295 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ($nodesWithStyleDisplayNone->length > 0) { |
330 | 330 | /** @var $node \DOMNode */ |
331 | 331 | foreach ($nodesWithStyleDisplayNone as $node) { |
332 | - if ($node->parentNode && is_callable(array($node->parentNode,'removeChild'))) { |
|
332 | + if ($node->parentNode && is_callable(array($node->parentNode, 'removeChild'))) { |
|
333 | 333 | $node->parentNode->removeChild($node); |
334 | 334 | } |
335 | 335 | } |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | $this->copyCssWithMediaToStyleNode($cssParts, $xmlDocument); |
339 | 339 | |
340 | 340 | if ($this->preserveEncoding) { |
341 | - if ( function_exists( 'mb_convert_encoding' ) ) { |
|
342 | - return mb_convert_encoding( $xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES' ); |
|
341 | + if (function_exists('mb_convert_encoding')) { |
|
342 | + return mb_convert_encoding($xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES'); |
|
343 | 343 | } else { |
344 | - return htmlspecialchars_decode( utf8_encode( html_entity_decode( $xmlDocument->saveHTML(), ENT_COMPAT, self::ENCODING ) ) ); |
|
344 | + return htmlspecialchars_decode(utf8_encode(html_entity_decode($xmlDocument->saveHTML(), ENT_COMPAT, self::ENCODING))); |
|
345 | 345 | } |
346 | 346 | } else { |
347 | 347 | return $xmlDocument->saveHTML(); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @return array |
463 | 463 | */ |
464 | 464 | private function splitCssAndMediaQuery($css) { |
465 | - $css = preg_replace_callback( '#@media\\s+(?:only\\s)?(?:[\\s{\(]|screen|all)\\s?[^{]+{.*}\\s*}\\s*#misU', array( $this, '_media_concat' ), $css ); |
|
465 | + $css = preg_replace_callback('#@media\\s+(?:only\\s)?(?:[\\s{\(]|screen|all)\\s?[^{]+{.*}\\s*}\\s*#misU', array($this, '_media_concat'), $css); |
|
466 | 466 | |
467 | 467 | // filter the CSS |
468 | 468 | $search = array( |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | return array('css' => $css, 'media' => self::$_media); |
487 | 487 | } |
488 | 488 | |
489 | - private function _media_concat( $matches ) { |
|
489 | + private function _media_concat($matches) { |
|
490 | 490 | self::$_media .= $matches[0]; |
491 | 491 | } |
492 | 492 | |
@@ -524,10 +524,10 @@ discard block |
||
524 | 524 | $bodyWithoutUnprocessableTags = $this->html; |
525 | 525 | } |
526 | 526 | |
527 | - if ( function_exists( 'mb_convert_encoding' ) ) { |
|
528 | - return mb_convert_encoding( $bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING ); |
|
527 | + if (function_exists('mb_convert_encoding')) { |
|
528 | + return mb_convert_encoding($bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING); |
|
529 | 529 | } else { |
530 | - return htmlspecialchars_decode( utf8_decode( htmlentities( $bodyWithoutUnprocessableTags, ENT_COMPAT, self::ENCODING, false ) ) ); |
|
530 | + return htmlspecialchars_decode(utf8_decode(htmlentities($bodyWithoutUnprocessableTags, ENT_COMPAT, self::ENCODING, false))); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $precedence = 0; |
563 | 563 | $value = 100; |
564 | 564 | // ids: worth 100, classes: worth 10, elements: worth 1 |
565 | - $search = array('\\#','\\.',''); |
|
565 | + $search = array('\\#', '\\.', ''); |
|
566 | 566 | |
567 | 567 | foreach ($search as $s) { |
568 | 568 | if (trim($selector == '')) { |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | */ |
591 | 591 | private function translateCssToXpath($paramCssSelector) { |
592 | 592 | $cssSelector = ' ' . $paramCssSelector . ' '; |
593 | - $cssSelector = preg_replace_callback( '/\s+\w+\s+/', array( $this, 'strtolower' ), $cssSelector ); |
|
593 | + $cssSelector = preg_replace_callback('/\s+\w+\s+/', array($this, 'strtolower'), $cssSelector); |
|
594 | 594 | $cssSelector = trim($cssSelector); |
595 | 595 | $xpathKey = md5($cssSelector); |
596 | 596 | if (!isset($this->caches[self::CACHE_KEY_XPATH][$xpathKey])) { |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * @return array |
714 | 714 | */ |
715 | 715 | private function parseNth(array $match) { |
716 | - if (in_array(strtolower($match[2]), array('even','odd'))) { |
|
716 | + if (in_array(strtolower($match[2]), array('even', 'odd'))) { |
|
717 | 717 | $index = strtolower($match[2]) == 'even' ? 0 : 1; |
718 | 718 | return array(self::MULTIPLIER => 2, self::INDEX => $index); |
719 | 719 | } elseif (stripos($match[2], 'n') === false) { |
@@ -1,56 +1,56 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | -do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html> |
|
5 | +do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html> |
|
6 | 6 | <html <?php language_attributes(); ?>> |
7 | 7 | <head> |
8 | 8 | <meta charset="UTF-8"> |
9 | 9 | <title><?php wp_title() ?></title> |
10 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
10 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
11 | 11 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
12 | 12 | <meta name="robots" content="noindex,nofollow"> |
13 | - <?php do_action( 'wpinv_invalid_invoice_head' ); ?> |
|
13 | + <?php do_action('wpinv_invalid_invoice_head'); ?> |
|
14 | 14 | </head> |
15 | 15 | <body class="body wpinv wpinv-print wpinv-invalid-invoice"> |
16 | - <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?> |
|
16 | + <?php do_action('wpinv_invalid_invoice_body_start'); ?> |
|
17 | 17 | <div class="container wpinv-wrap"> |
18 | 18 | <!-- ///// Start Header --> |
19 | 19 | <htmlpageheader name="wpinv-pdf-header"> |
20 | - <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?> |
|
20 | + <?php do_action('wpinv_invalid_invoice_before_header'); ?> |
|
21 | 21 | <div class="row wpinv-header"> |
22 | 22 | <div class="col-xs-12 wpinv-business"> |
23 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
24 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
25 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
23 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
24 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
25 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
26 | 26 | <?php } else { ?> |
27 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
27 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
28 | 28 | <?php } ?> |
29 | 29 | </a> |
30 | 30 | </div> |
31 | 31 | </div> |
32 | - <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?> |
|
32 | + <?php do_action('wpinv_invalid_invoice_after_header'); ?> |
|
33 | 33 | </htmlpageheader> |
34 | 34 | <!-- End Header ///// --> |
35 | 35 | |
36 | - <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?> |
|
36 | + <?php do_action('wpinv_invalid_invoice_before_content'); ?> |
|
37 | 37 | |
38 | - <?php do_action( 'wpinv_invalid_invoice_content' ); ?> |
|
38 | + <?php do_action('wpinv_invalid_invoice_content'); ?> |
|
39 | 39 | |
40 | - <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?> |
|
40 | + <?php do_action('wpinv_invalid_invoice_after_content'); ?> |
|
41 | 41 | |
42 | 42 | <!-- ///// Start Footer --> |
43 | 43 | <htmlpagefooter name="wpinv-pdf-footer"> |
44 | - <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?> |
|
44 | + <?php do_action('wpinv_invalid_invoice_before_footer'); ?> |
|
45 | 45 | <div class="row wpinv-footer"> |
46 | 46 | <div class="col-sm-12"> |
47 | 47 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | - <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?> |
|
50 | + <?php do_action('wpinv_invalid_invoice_after_footer'); ?> |
|
51 | 51 | </htmlpagefooter> |
52 | 52 | <!-- End Footer ///// --> |
53 | 53 | </div> |
54 | - <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?> |
|
54 | + <?php do_action('wpinv_invalid_invoice_body_end'); ?> |
|
55 | 55 | </body> |
56 | 56 | </html> |
57 | 57 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | /** |
6 | 8 | * The Subscriptions DB Class |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * The Subscriptions DB Class |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | 'transaction_id' => '', |
69 | 69 | 'parent_payment_id' => 0, |
70 | 70 | 'product_id' => 0, |
71 | - 'created' => date( 'Y-m-d H:i:s' ), |
|
72 | - 'expiration' => date( 'Y-m-d H:i:s' ), |
|
71 | + 'created' => date('Y-m-d H:i:s'), |
|
72 | + 'expiration' => date('Y-m-d H:i:s'), |
|
73 | 73 | 'trial_period' => '', |
74 | 74 | 'status' => '', |
75 | 75 | 'profile_id' => '', |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * @access public |
83 | 83 | * @since 1.0.0 |
84 | 84 | */ |
85 | - public function get_subscriptions( $args = array() ) { |
|
85 | + public function get_subscriptions($args = array()) { |
|
86 | 86 | global $wpdb; |
87 | 87 | |
88 | 88 | $defaults = array( |
89 | - 'number' => get_option( 'posts_per_page' ), |
|
89 | + 'number' => get_option('posts_per_page'), |
|
90 | 90 | 'offset' => 0, |
91 | 91 | 'search' => '', |
92 | 92 | 'customer_id' => 0, |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | 'order' => 'DESC' |
95 | 95 | ); |
96 | 96 | |
97 | - $args = wp_parse_args( $args, $defaults ); |
|
97 | + $args = wp_parse_args($args, $defaults); |
|
98 | 98 | |
99 | - if( $args['number'] < 1 ) { |
|
99 | + if ($args['number'] < 1) { |
|
100 | 100 | $args['number'] = 999999999999; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $where = ' WHERE 1=1 '; |
104 | 104 | |
105 | 105 | // specific customers |
106 | - if( ! empty( $args['id'] ) ) { |
|
106 | + if (!empty($args['id'])) { |
|
107 | 107 | |
108 | - if( is_array( $args['id'] ) ) { |
|
109 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
108 | + if (is_array($args['id'])) { |
|
109 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
110 | 110 | } else { |
111 | - $ids = intval( $args['id'] ); |
|
111 | + $ids = intval($args['id']); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | // Specific products |
119 | - if( ! empty( $args['product_id'] ) ) { |
|
119 | + if (!empty($args['product_id'])) { |
|
120 | 120 | |
121 | - if( is_array( $args['product_id'] ) ) { |
|
122 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
121 | + if (is_array($args['product_id'])) { |
|
122 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
123 | 123 | } else { |
124 | - $product_ids = intval( $args['product_id'] ); |
|
124 | + $product_ids = intval($args['product_id']); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | // Specific parent payments |
132 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
132 | + if (!empty($args['parent_payment_id'])) { |
|
133 | 133 | |
134 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
135 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
134 | + if (is_array($args['parent_payment_id'])) { |
|
135 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
136 | 136 | } else { |
137 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
137 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | // Specific transaction IDs |
145 | - if( ! empty( $args['transaction_id'] ) ) { |
|
145 | + if (!empty($args['transaction_id'])) { |
|
146 | 146 | |
147 | - if( is_array( $args['transaction_id'] ) ) { |
|
148 | - $transaction_ids = implode( "','", array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
147 | + if (is_array($args['transaction_id'])) { |
|
148 | + $transaction_ids = implode("','", array_map('sanitize_text_field', $args['transaction_id'])); |
|
149 | 149 | } else { |
150 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
150 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $where .= " AND `transaction_id` IN ( '{$transaction_ids}' ) "; |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Subscriptoins for specific customers |
158 | - if( ! empty( $args['customer_id'] ) ) { |
|
158 | + if (!empty($args['customer_id'])) { |
|
159 | 159 | |
160 | - if( is_array( $args['customer_id'] ) ) { |
|
161 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
160 | + if (is_array($args['customer_id'])) { |
|
161 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
162 | 162 | } else { |
163 | - $customer_ids = intval( $args['customer_id'] ); |
|
163 | + $customer_ids = intval($args['customer_id']); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | // Subscriptions for specific profile IDs |
171 | - if( ! empty( $args['profile_id'] ) ) { |
|
171 | + if (!empty($args['profile_id'])) { |
|
172 | 172 | |
173 | - if( is_array( $args['profile_id'] ) ) { |
|
174 | - $profile_ids = implode( "','", array_map('sanitize_text_field', $args['profile_id'] ) ); |
|
173 | + if (is_array($args['profile_id'])) { |
|
174 | + $profile_ids = implode("','", array_map('sanitize_text_field', $args['profile_id'])); |
|
175 | 175 | } else { |
176 | - $profile_ids = sanitize_text_field( $args['profile_id'] ); |
|
176 | + $profile_ids = sanitize_text_field($args['profile_id']); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $where .= " AND `profile_id` IN( '{$profile_ids}' ) "; |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | // Subscriptions for specific statuses |
184 | - if( ! empty( $args['status'] ) ) { |
|
184 | + if (!empty($args['status'])) { |
|
185 | 185 | |
186 | - if( is_array( $args['status'] ) ) { |
|
187 | - $statuses = implode( "','", array_map( 'sanitize_text_field', $args['status'] ) ); |
|
186 | + if (is_array($args['status'])) { |
|
187 | + $statuses = implode("','", array_map('sanitize_text_field', $args['status'])); |
|
188 | 188 | } else { |
189 | - $statuses = sanitize_text_field( $args['status'] ); |
|
189 | + $statuses = sanitize_text_field($args['status']); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $where .= " AND `status` IN( '{$statuses}' ) "; |
@@ -194,21 +194,21 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | // Subscriptions created for a specific date or in a date range |
197 | - if( ! empty( $args['date'] ) ) { |
|
197 | + if (!empty($args['date'])) { |
|
198 | 198 | |
199 | - if( is_array( $args['date'] ) ) { |
|
199 | + if (is_array($args['date'])) { |
|
200 | 200 | |
201 | - if( ! empty( $args['date']['start'] ) ) { |
|
201 | + if (!empty($args['date']['start'])) { |
|
202 | 202 | |
203 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
203 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
204 | 204 | |
205 | 205 | $where .= " AND `created` >= '{$start}'"; |
206 | 206 | |
207 | 207 | } |
208 | 208 | |
209 | - if( ! empty( $args['date']['end'] ) ) { |
|
209 | + if (!empty($args['date']['end'])) { |
|
210 | 210 | |
211 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
211 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
212 | 212 | |
213 | 213 | $where .= " AND `created` <= '{$end}'"; |
214 | 214 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | } else { |
218 | 218 | |
219 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
220 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
221 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
219 | + $year = date('Y', strtotime($args['date'])); |
|
220 | + $month = date('m', strtotime($args['date'])); |
|
221 | + $day = date('d', strtotime($args['date'])); |
|
222 | 222 | |
223 | 223 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
224 | 224 | } |
@@ -226,21 +226,21 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | // Subscriptions with a specific expiration date or in an expiration date range |
229 | - if( ! empty( $args['expiration'] ) ) { |
|
229 | + if (!empty($args['expiration'])) { |
|
230 | 230 | |
231 | - if( is_array( $args['expiration'] ) ) { |
|
231 | + if (is_array($args['expiration'])) { |
|
232 | 232 | |
233 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
233 | + if (!empty($args['expiration']['start'])) { |
|
234 | 234 | |
235 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
235 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
236 | 236 | |
237 | 237 | $where .= " AND `expiration` >= '{$start}'"; |
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
241 | + if (!empty($args['expiration']['end'])) { |
|
242 | 242 | |
243 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
243 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
244 | 244 | |
245 | 245 | $where .= " AND `expiration` <= '{$end}'"; |
246 | 246 | |
@@ -248,73 +248,73 @@ discard block |
||
248 | 248 | |
249 | 249 | } else { |
250 | 250 | |
251 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
252 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
253 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
251 | + $year = date('Y', strtotime($args['expiration'])); |
|
252 | + $month = date('m', strtotime($args['expiration'])); |
|
253 | + $day = date('d', strtotime($args['expiration'])); |
|
254 | 254 | |
255 | 255 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
256 | 256 | } |
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | - if ( ! empty( $args['search'] ) ) { |
|
260 | + if (!empty($args['search'])) { |
|
261 | 261 | |
262 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
262 | + if (false !== strpos('id:', $args['search'])) { |
|
263 | 263 | |
264 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
265 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
264 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
265 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
266 | 266 | |
267 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
267 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
268 | 268 | |
269 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
270 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
269 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
270 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
271 | 271 | |
272 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
272 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
273 | 273 | |
274 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
275 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
274 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
275 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
276 | 276 | |
277 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
277 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
278 | 278 | |
279 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
280 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
279 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
280 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
281 | 281 | |
282 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
282 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
283 | 283 | |
284 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
285 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
284 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
285 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
286 | 286 | |
287 | 287 | } else { |
288 | 288 | |
289 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
289 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
295 | + $args['orderby'] = !array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
296 | 296 | |
297 | - if( 'amount' == $args['orderby'] ) { |
|
297 | + if ('amount' == $args['orderby']) { |
|
298 | 298 | $args['orderby'] = 'amount+0'; |
299 | 299 | } |
300 | 300 | |
301 | - $cache_key = md5( 'wpinv_subscriptions_' . serialize( $args ) ); |
|
301 | + $cache_key = md5('wpinv_subscriptions_' . serialize($args)); |
|
302 | 302 | |
303 | - $subscriptions = wp_cache_get( $cache_key, 'subscriptions' ); |
|
303 | + $subscriptions = wp_cache_get($cache_key, 'subscriptions'); |
|
304 | 304 | |
305 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
306 | - $args['order'] = esc_sql( $args['order'] ); |
|
305 | + $args['orderby'] = esc_sql($args['orderby']); |
|
306 | + $args['order'] = esc_sql($args['order']); |
|
307 | 307 | |
308 | - if( $subscriptions === false ) { |
|
309 | - $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ), OBJECT ); |
|
308 | + if ($subscriptions === false) { |
|
309 | + $subscriptions = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])), OBJECT); |
|
310 | 310 | |
311 | - if( ! empty( $subscriptions ) ) { |
|
311 | + if (!empty($subscriptions)) { |
|
312 | 312 | |
313 | - foreach( $subscriptions as $key => $subscription ) { |
|
314 | - $subscriptions[ $key ] = new WPInv_Subscription( $subscription ); |
|
313 | + foreach ($subscriptions as $key => $subscription) { |
|
314 | + $subscriptions[$key] = new WPInv_Subscription($subscription); |
|
315 | 315 | } |
316 | 316 | |
317 | - wp_cache_set( $cache_key, $subscriptions, 'subscriptions', 3600 ); |
|
317 | + wp_cache_set($cache_key, $subscriptions, 'subscriptions', 3600); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -329,19 +329,19 @@ discard block |
||
329 | 329 | * @access public |
330 | 330 | * @since 1.0.0 |
331 | 331 | */ |
332 | - public function count( $args = array() ) { |
|
332 | + public function count($args = array()) { |
|
333 | 333 | |
334 | 334 | global $wpdb; |
335 | 335 | |
336 | 336 | $where = ' WHERE 1=1 '; |
337 | 337 | |
338 | 338 | // specific customers |
339 | - if( ! empty( $args['id'] ) ) { |
|
339 | + if (!empty($args['id'])) { |
|
340 | 340 | |
341 | - if( is_array( $args['id'] ) ) { |
|
342 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
341 | + if (is_array($args['id'])) { |
|
342 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
343 | 343 | } else { |
344 | - $ids = intval( $args['id'] ); |
|
344 | + $ids = intval($args['id']); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | } |
350 | 350 | |
351 | 351 | // Specific products |
352 | - if( ! empty( $args['product_id'] ) ) { |
|
352 | + if (!empty($args['product_id'])) { |
|
353 | 353 | |
354 | - if( is_array( $args['product_id'] ) ) { |
|
355 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
354 | + if (is_array($args['product_id'])) { |
|
355 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
356 | 356 | } else { |
357 | - $product_ids = intval( $args['product_id'] ); |
|
357 | + $product_ids = intval($args['product_id']); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | // Specific parent payments |
365 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
365 | + if (!empty($args['parent_payment_id'])) { |
|
366 | 366 | |
367 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
368 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
367 | + if (is_array($args['parent_payment_id'])) { |
|
368 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
369 | 369 | } else { |
370 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
370 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | // Subscriptoins for specific customers |
378 | - if( ! empty( $args['customer_id'] ) ) { |
|
378 | + if (!empty($args['customer_id'])) { |
|
379 | 379 | |
380 | - if( is_array( $args['customer_id'] ) ) { |
|
381 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
380 | + if (is_array($args['customer_id'])) { |
|
381 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
382 | 382 | } else { |
383 | - $customer_ids = intval( $args['customer_id'] ); |
|
383 | + $customer_ids = intval($args['customer_id']); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | // Subscriptions for specific profile IDs |
391 | - if( ! empty( $args['profile_id'] ) ) { |
|
391 | + if (!empty($args['profile_id'])) { |
|
392 | 392 | |
393 | - if( is_array( $args['profile_id'] ) ) { |
|
394 | - $profile_ids = implode( ',', array_map('intval', $args['profile_id'] ) ); |
|
393 | + if (is_array($args['profile_id'])) { |
|
394 | + $profile_ids = implode(',', array_map('intval', $args['profile_id'])); |
|
395 | 395 | } else { |
396 | - $profile_ids = intval( $args['profile_id'] ); |
|
396 | + $profile_ids = intval($args['profile_id']); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | $where .= " AND `profile_id` IN( {$profile_ids} ) "; |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | } |
402 | 402 | |
403 | 403 | // Specific transaction IDs |
404 | - if( ! empty( $args['transaction_id'] ) ) { |
|
404 | + if (!empty($args['transaction_id'])) { |
|
405 | 405 | |
406 | - if( is_array( $args['transaction_id'] ) ) { |
|
407 | - $transaction_ids = implode( ',', array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
406 | + if (is_array($args['transaction_id'])) { |
|
407 | + $transaction_ids = implode(',', array_map('sanitize_text_field', $args['transaction_id'])); |
|
408 | 408 | } else { |
409 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
409 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | $where .= " AND `transaction_id` IN( {$transaction_ids} ) "; |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | // Subscriptions for specific statuses |
417 | - if( ! empty( $args['status'] ) ) { |
|
417 | + if (!empty($args['status'])) { |
|
418 | 418 | |
419 | - if( is_array( $args['status'] ) ) { |
|
420 | - $statuses = implode( ',', $args['status'] ); |
|
419 | + if (is_array($args['status'])) { |
|
420 | + $statuses = implode(',', $args['status']); |
|
421 | 421 | $where .= " AND `status` IN( {$statuses} ) "; |
422 | 422 | } else { |
423 | 423 | $statuses = $args['status']; |
@@ -429,21 +429,21 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | // Subscriptions created for a specific date or in a date range |
432 | - if( ! empty( $args['date'] ) ) { |
|
432 | + if (!empty($args['date'])) { |
|
433 | 433 | |
434 | - if( is_array( $args['date'] ) ) { |
|
434 | + if (is_array($args['date'])) { |
|
435 | 435 | |
436 | - if( ! empty( $args['date']['start'] ) ) { |
|
436 | + if (!empty($args['date']['start'])) { |
|
437 | 437 | |
438 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
438 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
439 | 439 | |
440 | 440 | $where .= " AND `created` >= '{$start}'"; |
441 | 441 | |
442 | 442 | } |
443 | 443 | |
444 | - if( ! empty( $args['date']['end'] ) ) { |
|
444 | + if (!empty($args['date']['end'])) { |
|
445 | 445 | |
446 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
446 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
447 | 447 | |
448 | 448 | $where .= " AND `created` <= '{$end}'"; |
449 | 449 | |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | |
452 | 452 | } else { |
453 | 453 | |
454 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
455 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
456 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
454 | + $year = date('Y', strtotime($args['date'])); |
|
455 | + $month = date('m', strtotime($args['date'])); |
|
456 | + $day = date('d', strtotime($args['date'])); |
|
457 | 457 | |
458 | 458 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
459 | 459 | } |
@@ -461,21 +461,21 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | // Subscriptions with a specific expiration date or in an expiration date range |
464 | - if( ! empty( $args['expiration'] ) ) { |
|
464 | + if (!empty($args['expiration'])) { |
|
465 | 465 | |
466 | - if( is_array( $args['expiration'] ) ) { |
|
466 | + if (is_array($args['expiration'])) { |
|
467 | 467 | |
468 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
468 | + if (!empty($args['expiration']['start'])) { |
|
469 | 469 | |
470 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
470 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
471 | 471 | |
472 | 472 | $where .= " AND `expiration` >= '{$start}'"; |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
476 | + if (!empty($args['expiration']['end'])) { |
|
477 | 477 | |
478 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
478 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
479 | 479 | |
480 | 480 | $where .= " AND `expiration` <= '{$end}'"; |
481 | 481 | |
@@ -483,64 +483,64 @@ discard block |
||
483 | 483 | |
484 | 484 | } else { |
485 | 485 | |
486 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
487 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
488 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
486 | + $year = date('Y', strtotime($args['expiration'])); |
|
487 | + $month = date('m', strtotime($args['expiration'])); |
|
488 | + $day = date('d', strtotime($args['expiration'])); |
|
489 | 489 | |
490 | 490 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
494 | 494 | |
495 | - if ( ! empty( $args['search'] ) ) { |
|
495 | + if (!empty($args['search'])) { |
|
496 | 496 | |
497 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
497 | + if (false !== strpos('id:', $args['search'])) { |
|
498 | 498 | |
499 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
500 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
499 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
500 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
501 | 501 | |
502 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
502 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
503 | 503 | |
504 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
505 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
504 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
505 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
506 | 506 | |
507 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
507 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
508 | 508 | |
509 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
510 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
509 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
510 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
511 | 511 | |
512 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
512 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
513 | 513 | |
514 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
515 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
514 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
515 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
516 | 516 | |
517 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
517 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
518 | 518 | |
519 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
520 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
519 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
520 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
521 | 521 | |
522 | 522 | } else { |
523 | 523 | |
524 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
524 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
525 | 525 | |
526 | 526 | } |
527 | 527 | |
528 | 528 | } |
529 | 529 | |
530 | - $cache_key = md5( 'wpinv_subscriptions_count' . serialize( $args ) ); |
|
530 | + $cache_key = md5('wpinv_subscriptions_count' . serialize($args)); |
|
531 | 531 | |
532 | - $count = wp_cache_get( $cache_key, 'subscriptions' ); |
|
532 | + $count = wp_cache_get($cache_key, 'subscriptions'); |
|
533 | 533 | |
534 | - if( $count === false ) { |
|
534 | + if ($count === false) { |
|
535 | 535 | |
536 | 536 | $sql = "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};"; |
537 | - $count = $wpdb->get_var( $sql ); |
|
537 | + $count = $wpdb->get_var($sql); |
|
538 | 538 | |
539 | - wp_cache_set( $cache_key, $count, 'subscriptions', 3600 ); |
|
539 | + wp_cache_set($cache_key, $count, 'subscriptions', 3600); |
|
540 | 540 | |
541 | 541 | } |
542 | 542 | |
543 | - return absint( $count ); |
|
543 | + return absint($count); |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | public function create_table() { |
554 | 554 | global $wpdb; |
555 | 555 | |
556 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
556 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
557 | 557 | |
558 | 558 | $sql = "CREATE TABLE " . $this->table_name . " ( |
559 | 559 | id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | KEY customer_and_status ( customer_id, status) |
579 | 579 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
580 | 580 | |
581 | - dbDelta( $sql ); |
|
581 | + dbDelta($sql); |
|
582 | 582 | |
583 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
583 | + update_option($this->table_name . '_db_version', $this->version); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | } |
587 | 587 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if (!defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @since 1.0.0 |
67 | 67 | * @return object |
68 | 68 | */ |
69 | - public function get( $row_id ) { |
|
69 | + public function get($row_id) { |
|
70 | 70 | global $wpdb; |
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
71 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @since 1.0.0 |
79 | 79 | * @return object |
80 | 80 | */ |
81 | - public function get_by( $column, $row_id ) { |
|
81 | + public function get_by($column, $row_id) { |
|
82 | 82 | global $wpdb; |
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
83 | + $column = esc_sql($column); |
|
84 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @since 1.0.0 |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - public function get_column( $column, $row_id ) { |
|
94 | + public function get_column($column, $row_id) { |
|
95 | 95 | global $wpdb; |
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
96 | + $column = esc_sql($column); |
|
97 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @since 1.0.0 |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
107 | + public function get_column_by($column, $column_where, $column_value) { |
|
108 | 108 | global $wpdb; |
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
109 | + $column_where = esc_sql($column_where); |
|
110 | + $column = esc_sql($column); |
|
111 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,31 +118,31 @@ discard block |
||
118 | 118 | * @since 1.0.0 |
119 | 119 | * @return int |
120 | 120 | */ |
121 | - public function insert( $data, $type = '' ) { |
|
121 | + public function insert($data, $type = '') { |
|
122 | 122 | global $wpdb; |
123 | 123 | |
124 | 124 | // Set default values |
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
125 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
126 | 126 | |
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
127 | + do_action('wpinv_pre_insert_' . $type, $data); |
|
128 | 128 | |
129 | 129 | // Initialise column format array |
130 | 130 | $column_formats = $this->get_columns(); |
131 | 131 | |
132 | 132 | // Force fields to lower case |
133 | - $data = array_change_key_case( $data ); |
|
133 | + $data = array_change_key_case($data); |
|
134 | 134 | |
135 | 135 | // White list columns |
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
136 | + $data = array_intersect_key($data, $column_formats); |
|
137 | 137 | |
138 | 138 | // Reorder $column_formats to match the order of columns given in $data |
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
139 | + $data_keys = array_keys($data); |
|
140 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
141 | 141 | |
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
142 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
143 | 143 | $wpdb_insert_id = $wpdb->insert_id; |
144 | 144 | |
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
145 | + do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data); |
|
146 | 146 | |
147 | 147 | return $wpdb_insert_id; |
148 | 148 | } |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | * @since 1.0.0 |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
157 | + public function update($row_id, $data = array(), $where = '') { |
|
158 | 158 | |
159 | 159 | global $wpdb; |
160 | 160 | |
161 | 161 | // Row ID must be positive integer |
162 | - $row_id = absint( $row_id ); |
|
162 | + $row_id = absint($row_id); |
|
163 | 163 | |
164 | - if( empty( $row_id ) ) { |
|
164 | + if (empty($row_id)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if( empty( $where ) ) { |
|
168 | + if (empty($where)) { |
|
169 | 169 | $where = $this->primary_key; |
170 | 170 | } |
171 | 171 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $column_formats = $this->get_columns(); |
174 | 174 | |
175 | 175 | // Force fields to lower case |
176 | - $data = array_change_key_case( $data ); |
|
176 | + $data = array_change_key_case($data); |
|
177 | 177 | |
178 | 178 | // White list columns |
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
179 | + $data = array_intersect_key($data, $column_formats); |
|
180 | 180 | |
181 | 181 | // Reorder $column_formats to match the order of columns given in $data |
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
182 | + $data_keys = array_keys($data); |
|
183 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
184 | 184 | |
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
185 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @since 1.0.0 |
197 | 197 | * @return bool |
198 | 198 | */ |
199 | - public function delete( $row_id = 0 ) { |
|
199 | + public function delete($row_id = 0) { |
|
200 | 200 | |
201 | 201 | global $wpdb; |
202 | 202 | |
203 | 203 | // Row ID must be positive integer |
204 | - $row_id = absint( $row_id ); |
|
204 | + $row_id = absint($row_id); |
|
205 | 205 | |
206 | - if( empty( $row_id ) ) { |
|
206 | + if (empty($row_id)) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
210 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @param string $table The table name |
222 | 222 | * @return bool If the table name exists |
223 | 223 | */ |
224 | - public function table_exists( $table ) { |
|
224 | + public function table_exists($table) { |
|
225 | 225 | global $wpdb; |
226 | - $table = sanitize_text_field( $table ); |
|
226 | + $table = sanitize_text_field($table); |
|
227 | 227 | |
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
228 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return bool Returns if the customers table was installed and upgrade routine run |
236 | 236 | */ |
237 | 237 | public function installed() { |
238 | - return $this->table_exists( $this->table_name ); |
|
238 | + return $this->table_exists($this->table_name); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | abstract class Wpinv_DB { |
7 | 9 |