@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | |
29 | - $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' ); |
|
30 | - $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' ); |
|
29 | + $this->templates_dir = apply_filters('getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates'); |
|
30 | + $this->templates_url = apply_filters('getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return bool |
55 | 55 | */ |
56 | 56 | public function is_elementor_preview() { |
57 | - return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
57 | + return isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return bool |
65 | 65 | */ |
66 | 66 | public function is_divi_preview() { |
67 | - return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
67 | + return isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'et_pb'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return bool |
75 | 75 | */ |
76 | 76 | public function is_beaver_preview() { |
77 | - return isset( $_REQUEST['fl_builder'] ); |
|
77 | + return isset($_REQUEST['fl_builder']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return bool |
85 | 85 | */ |
86 | 86 | public function is_siteorigin_preview() { |
87 | - return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
87 | + return !empty($_REQUEST['siteorigin_panels_live_editor']); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | public function is_cornerstone_preview() { |
97 | - return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
97 | + return !empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | public function is_fusion_preview() { |
107 | - return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
107 | + return !empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce']); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | public function is_oxygen_preview() { |
117 | - return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
117 | + return !empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_")); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
125 | 125 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
126 | 126 | */ |
127 | - public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
127 | + public function locate_template($template_name, $template_path = '', $default_path = '') { |
|
128 | 128 | |
129 | 129 | // Load the defaults for the template path and default path. |
130 | - $template_path = empty( $template_path ) ? 'invoicing' : $template_path; |
|
131 | - $default_path = empty( $default_path ) ? $this->templates_dir : $default_path; |
|
132 | - $default_path = apply_filters( 'getpaid_template_default_template_path', $default_path, $template_name ); |
|
130 | + $template_path = empty($template_path) ? 'invoicing' : $template_path; |
|
131 | + $default_path = empty($default_path) ? $this->templates_dir : $default_path; |
|
132 | + $default_path = apply_filters('getpaid_template_default_template_path', $default_path, $template_name); |
|
133 | 133 | |
134 | 134 | // Is it overidden? |
135 | 135 | $template = locate_template( |
136 | - array( trailingslashit( $template_path ) . $template_name ), |
|
137 | - array( 'wpinv-' . $template_name ) |
|
136 | + array(trailingslashit($template_path) . $template_name), |
|
137 | + array('wpinv-' . $template_name) |
|
138 | 138 | ); |
139 | 139 | |
140 | 140 | // If not, load the default template. |
141 | - if ( empty( $template ) ) { |
|
142 | - $template = trailingslashit( $default_path ) . $template_name; |
|
141 | + if (empty($template)) { |
|
142 | + $template = trailingslashit($default_path) . $template_name; |
|
143 | 143 | } |
144 | 144 | |
145 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path ); |
|
145 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path, $default_path); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,20 +151,20 @@ discard block |
||
151 | 151 | * @since 1.0.19 |
152 | 152 | * @return bool |
153 | 153 | */ |
154 | - protected function load_template( $template_name, $template_path, $args ) { |
|
154 | + protected function load_template($template_name, $template_path, $args) { |
|
155 | 155 | |
156 | - if ( is_array( $args ) ){ |
|
157 | - extract( $args ); |
|
156 | + if (is_array($args)) { |
|
157 | + extract($args); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // Fires before loading a template. |
161 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
161 | + do_action('wpinv_before_template_part', $template_name, $template_path, $args); |
|
162 | 162 | |
163 | 163 | // Load the template. |
164 | - include( $template_path ); |
|
164 | + include($template_path); |
|
165 | 165 | |
166 | 166 | // Fires after loading a template. |
167 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $args ); |
|
167 | + do_action('wpinv_after_template_part', $template_name, $template_path, $args); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
@@ -178,18 +178,18 @@ discard block |
||
178 | 178 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
179 | 179 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
180 | 180 | */ |
181 | - public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
181 | + public function display_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
182 | 182 | |
183 | 183 | // Locate the template. |
184 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
184 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
185 | 185 | |
186 | 186 | // Abort if the file does not exist. |
187 | - if ( ! file_exists( $located ) ) { |
|
188 | - getpaid_doing_it_wrong( __CLASS__ . '::' .__METHOD__, sprintf( '<code>%s</code> does not exist.', $located ), '1.0.19' ); |
|
187 | + if (!file_exists($located)) { |
|
188 | + getpaid_doing_it_wrong(__CLASS__ . '::' . __METHOD__, sprintf('<code>%s</code> does not exist.', $located), '1.0.19'); |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | - $this->load_template( $template_name, $located, $args ); |
|
192 | + $this->load_template($template_name, $located, $args); |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
204 | 204 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
205 | 205 | */ |
206 | - public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
206 | + public function get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
207 | 207 | ob_start(); |
208 | - $this->display_template( $template_name, $args, $template_path, $default_path ); |
|
208 | + $this->display_template($template_name, $args, $template_path, $default_path); |
|
209 | 209 | return ob_get_clean(); |
210 | 210 | } |
211 | 211 |
@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,136 +49,136 @@ discard block |
||
49 | 49 | * @param string $post_type The post type or invoice type. |
50 | 50 | * @return string The history page URL. |
51 | 51 | */ |
52 | -function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
|
53 | - $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
|
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
52 | +function wpinv_get_history_page_uri($post_type = 'wpi_invoice') { |
|
53 | + $post_type = sanitize_key(str_replace('wpi_', '', $post_type)); |
|
54 | + $page_id = wpinv_get_option("{$post_type}_history_page", 0); |
|
55 | + $page_id = absint($page_id); |
|
56 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option('success_page', false); |
|
61 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
73 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
74 | - $ret = $ret ? is_page( $ret ) : false; |
|
75 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
73 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
74 | + $ret = $ret ? is_page($ret) : false; |
|
75 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Redirects a user the success page. |
80 | 80 | */ |
81 | -function wpinv_send_to_success_page( $args = array() ) { |
|
81 | +function wpinv_send_to_success_page($args = array()) { |
|
82 | 82 | $redirect = add_query_arg( |
83 | - wp_parse_args( $args ), |
|
83 | + wp_parse_args($args), |
|
84 | 84 | wpinv_get_success_page_uri() |
85 | 85 | ); |
86 | 86 | |
87 | - wp_redirect( $redirect ); |
|
87 | + wp_redirect($redirect); |
|
88 | 88 | exit; |
89 | 89 | } |
90 | 90 | |
91 | -function wpinv_send_to_failed_page( $args = null ) { |
|
91 | +function wpinv_send_to_failed_page($args = null) { |
|
92 | 92 | $redirect = wpinv_get_failed_transaction_uri(); |
93 | 93 | |
94 | - if ( !empty( $args ) ) { |
|
94 | + if (!empty($args)) { |
|
95 | 95 | // Check for backward compatibility |
96 | - if ( is_string( $args ) ) |
|
97 | - $args = str_replace( '?', '', $args ); |
|
96 | + if (is_string($args)) |
|
97 | + $args = str_replace('?', '', $args); |
|
98 | 98 | |
99 | - $args = wp_parse_args( $args ); |
|
99 | + $args = wp_parse_args($args); |
|
100 | 100 | |
101 | - $redirect = add_query_arg( $args, $redirect ); |
|
101 | + $redirect = add_query_arg($args, $redirect); |
|
102 | 102 | } |
103 | 103 | |
104 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
104 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
105 | 105 | |
106 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
107 | - wp_redirect( $redirect ); |
|
106 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
107 | + wp_redirect($redirect); |
|
108 | 108 | exit; |
109 | 109 | } |
110 | 110 | |
111 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
111 | +function wpinv_get_checkout_uri($args = array()) { |
|
112 | + $uri = wpinv_get_option('checkout_page', false); |
|
113 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
114 | 114 | |
115 | - if ( !empty( $args ) ) { |
|
115 | + if (!empty($args)) { |
|
116 | 116 | // Check for backward compatibility |
117 | - if ( is_string( $args ) ) |
|
118 | - $args = str_replace( '?', '', $args ); |
|
117 | + if (is_string($args)) |
|
118 | + $args = str_replace('?', '', $args); |
|
119 | 119 | |
120 | - $args = wp_parse_args( $args ); |
|
120 | + $args = wp_parse_args($args); |
|
121 | 121 | |
122 | - $uri = add_query_arg( $args, $uri ); |
|
122 | + $uri = add_query_arg($args, $uri); |
|
123 | 123 | } |
124 | 124 | |
125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
125 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | 126 | |
127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
127 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
128 | 128 | |
129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
129 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
130 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
131 | 131 | } |
132 | 132 | |
133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
133 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
137 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
138 | - $success_page = get_permalink( $success_page ); |
|
136 | +function wpinv_get_success_page_url($query_string = null) { |
|
137 | + $success_page = wpinv_get_option('success_page', 0); |
|
138 | + $success_page = get_permalink($success_page); |
|
139 | 139 | |
140 | - if ( $query_string ) |
|
140 | + if ($query_string) |
|
141 | 141 | $success_page .= $query_string; |
142 | 142 | |
143 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
143 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
144 | 144 | } |
145 | 145 | |
146 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
147 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
148 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
146 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
147 | + $uri = wpinv_get_option('failure_page', ''); |
|
148 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
149 | 149 | |
150 | - if ( $extras ) |
|
150 | + if ($extras) |
|
151 | 151 | $uri .= $extras; |
152 | 152 | |
153 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
153 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | function wpinv_is_failed_transaction_page() { |
157 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
158 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
157 | + $ret = wpinv_get_option('failure_page', false); |
|
158 | + $ret = isset($ret) ? is_page($ret) : false; |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
160 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
161 | 161 | } |
162 | 162 | |
163 | -function wpinv_transaction_query( $type = 'start' ) { |
|
163 | +function wpinv_transaction_query($type = 'start') { |
|
164 | 164 | global $wpdb; |
165 | 165 | |
166 | 166 | $wpdb->hide_errors(); |
167 | 167 | |
168 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
169 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
168 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
169 | + define('WPINV_USE_TRANSACTIONS', true); |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
173 | - switch ( $type ) { |
|
172 | + if (WPINV_USE_TRANSACTIONS) { |
|
173 | + switch ($type) { |
|
174 | 174 | case 'commit' : |
175 | - $wpdb->query( 'COMMIT' ); |
|
175 | + $wpdb->query('COMMIT'); |
|
176 | 176 | break; |
177 | 177 | case 'rollback' : |
178 | - $wpdb->query( 'ROLLBACK' ); |
|
178 | + $wpdb->query('ROLLBACK'); |
|
179 | 179 | break; |
180 | 180 | default : |
181 | - $wpdb->query( 'START TRANSACTION' ); |
|
181 | + $wpdb->query('START TRANSACTION'); |
|
182 | 182 | break; |
183 | 183 | } |
184 | 184 | } |
@@ -187,141 +187,141 @@ discard block |
||
187 | 187 | function wpinv_get_prefix() { |
188 | 188 | $invoice_prefix = 'INV-'; |
189 | 189 | |
190 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
190 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | function wpinv_get_business_logo() { |
194 | - $business_logo = wpinv_get_option( 'logo' ); |
|
195 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
194 | + $business_logo = wpinv_get_option('logo'); |
|
195 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | function wpinv_get_business_name() { |
199 | 199 | $business_name = wpinv_get_option('store_name'); |
200 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
200 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | function wpinv_get_blogname() { |
204 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
204 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | function wpinv_get_admin_email() { |
208 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
209 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
208 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
209 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_get_business_website() { |
213 | - $business_website = home_url( '/' ); |
|
214 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
213 | + $business_website = home_url('/'); |
|
214 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
215 | 215 | } |
216 | 216 | |
217 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
217 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
218 | 218 | $terms_text = ''; |
219 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
219 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | function wpinv_get_business_footer() { |
223 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
224 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
225 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
223 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
224 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
225 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_required_fields() { |
229 | 229 | $required_fields = array(); |
230 | 230 | |
231 | 231 | // Let payment gateways and other extensions determine if address fields should be required |
232 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
232 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
233 | 233 | |
234 | - if ( $require_billing_details ) { |
|
235 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
234 | + if ($require_billing_details) { |
|
235 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
236 | 236 | $required_fields['first_name'] = array( |
237 | 237 | 'error_id' => 'invalid_first_name', |
238 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
238 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
239 | 239 | ); |
240 | 240 | } |
241 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
241 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
242 | 242 | $required_fields['address'] = array( |
243 | 243 | 'error_id' => 'invalid_address', |
244 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
244 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
245 | 245 | ); |
246 | 246 | } |
247 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
247 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
248 | 248 | $required_fields['city'] = array( |
249 | 249 | 'error_id' => 'invalid_city', |
250 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
250 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
251 | 251 | ); |
252 | 252 | } |
253 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
253 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
254 | 254 | $required_fields['state'] = array( |
255 | 255 | 'error_id' => 'invalid_state', |
256 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
256 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
257 | 257 | ); |
258 | 258 | } |
259 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
259 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
260 | 260 | $required_fields['country'] = array( |
261 | 261 | 'error_id' => 'invalid_country', |
262 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
262 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
263 | 263 | ); |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
267 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | function wpinv_is_ssl_enforced() { |
271 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
272 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
271 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
272 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | function wpinv_schedule_event_twicedaily() { |
276 | 276 | wpinv_email_payment_reminders(); |
277 | 277 | } |
278 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
278 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
279 | 279 | |
280 | 280 | function wpinv_require_login_to_checkout() { |
281 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
282 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
281 | + $return = wpinv_get_option('login_to_checkout', false); |
|
282 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
283 | 283 | } |
284 | 284 | |
285 | -function wpinv_sequential_number_active( $type = '' ) { |
|
286 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
287 | - if ( null !== $check ) { |
|
285 | +function wpinv_sequential_number_active($type = '') { |
|
286 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
287 | + if (null !== $check) { |
|
288 | 288 | return $check; |
289 | 289 | } |
290 | 290 | |
291 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
291 | + return wpinv_get_option('sequential_invoice_number'); |
|
292 | 292 | } |
293 | 293 | |
294 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
294 | +function wpinv_switch_to_locale($locale = NULL) { |
|
295 | 295 | global $invoicing, $wpi_switch_locale; |
296 | 296 | |
297 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
298 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
297 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
298 | + $locale = empty($locale) ? get_locale() : $locale; |
|
299 | 299 | |
300 | - switch_to_locale( $locale ); |
|
300 | + switch_to_locale($locale); |
|
301 | 301 | |
302 | 302 | $wpi_switch_locale = $locale; |
303 | 303 | |
304 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
304 | + add_filter('plugin_locale', 'get_locale'); |
|
305 | 305 | |
306 | 306 | $invoicing->load_textdomain(); |
307 | 307 | |
308 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
308 | + do_action('wpinv_switch_to_locale', $locale); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | 312 | function wpinv_restore_locale() { |
313 | 313 | global $invoicing, $wpi_switch_locale; |
314 | 314 | |
315 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
315 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
316 | 316 | restore_previous_locale(); |
317 | 317 | |
318 | 318 | $wpi_switch_locale = NULL; |
319 | 319 | |
320 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
320 | + remove_filter('plugin_locale', 'get_locale'); |
|
321 | 321 | |
322 | 322 | $invoicing->load_textdomain(); |
323 | 323 | |
324 | - do_action( 'wpinv_restore_locale' ); |
|
324 | + do_action('wpinv_restore_locale'); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
@@ -329,22 +329,22 @@ discard block |
||
329 | 329 | * Returns the default form's id. |
330 | 330 | */ |
331 | 331 | function wpinv_get_default_payment_form() { |
332 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
332 | + $form = get_option('wpinv_default_payment_form'); |
|
333 | 333 | |
334 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
334 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
335 | 335 | $form = wp_insert_post( |
336 | 336 | array( |
337 | 337 | 'post_type' => 'wpi_payment_form', |
338 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
338 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
339 | 339 | 'post_status' => 'publish', |
340 | 340 | 'meta_input' => array( |
341 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
341 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
342 | 342 | 'wpinv_form_items' => array(), |
343 | 343 | ) |
344 | 344 | ) |
345 | 345 | ); |
346 | 346 | |
347 | - update_option( 'wpinv_default_payment_form', $form ); |
|
347 | + update_option('wpinv_default_payment_form', $form); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | return $form; |
@@ -355,19 +355,19 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @param int $payment_form |
357 | 357 | */ |
358 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
358 | +function getpaid_get_payment_form_elements($payment_form) { |
|
359 | 359 | |
360 | - if ( empty( $payment_form ) ) { |
|
361 | - return wpinv_get_data( 'sample-payment-form' ); |
|
360 | + if (empty($payment_form)) { |
|
361 | + return wpinv_get_data('sample-payment-form'); |
|
362 | 362 | } |
363 | 363 | |
364 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
364 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
365 | 365 | |
366 | - if ( is_array( $form_elements ) ) { |
|
366 | + if (is_array($form_elements)) { |
|
367 | 367 | return $form_elements; |
368 | 368 | } |
369 | 369 | |
370 | - return wpinv_get_data( 'sample-payment-form' ); |
|
370 | + return wpinv_get_data('sample-payment-form'); |
|
371 | 371 | |
372 | 372 | } |
373 | 373 | |
@@ -376,13 +376,13 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param int $payment_form |
378 | 378 | */ |
379 | -function gepaid_get_form_items( $id ) { |
|
380 | - $form = new GetPaid_Payment_Form( $id ); |
|
379 | +function gepaid_get_form_items($id) { |
|
380 | + $form = new GetPaid_Payment_Form($id); |
|
381 | 381 | |
382 | 382 | // Is this a default form? |
383 | - if ( $form->is_default() ) { |
|
383 | + if ($form->is_default()) { |
|
384 | 384 | return array(); |
385 | 385 | } |
386 | 386 | |
387 | - return $form->get_items( 'view', 'arrays' ); |
|
387 | + return $form->get_items('view', 'arrays'); |
|
388 | 388 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $post_type The post type to check for. |
92 | 92 | */ |
93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
93 | +function getpaid_is_invoice_post_type($post_type) { |
|
94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
103 | 103 | */ |
104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
105 | - $data[ 'invoice_id' ] = 0; |
|
106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
105 | + $data['invoice_id'] = 0; |
|
106 | + return wpinv_insert_invoice($data, $wp_error); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
115 | 115 | */ |
116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
117 | 117 | |
118 | 118 | // Backwards compatibility. |
119 | - if ( ! empty( $data['ID'] ) ) { |
|
119 | + if (!empty($data['ID'])) { |
|
120 | 120 | $data['invoice_id'] = $data['ID']; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Do we have an invoice id? |
124 | - if ( empty( $data['invoice_id'] ) ) { |
|
125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
124 | + if (empty($data['invoice_id'])) { |
|
125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Retrieve the invoice. |
129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
130 | 130 | |
131 | 131 | // And abort if it does not exist. |
132 | - if ( empty( $invoice ) ) { |
|
133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
132 | + if (empty($invoice)) { |
|
133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Do not update totals for paid / refunded invoices. |
137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
138 | 138 | |
139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
145 | + return wpinv_insert_invoice($data, $wp_error); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
155 | 155 | */ |
156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
157 | 157 | |
158 | 158 | // Ensure that we have invoice data. |
159 | - if ( empty( $data ) ) { |
|
159 | + if (empty($data)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // The invoice id will be provided when updating an invoice. |
164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
168 | 168 | |
169 | 169 | // Do we have an error? |
170 | - if ( ! empty( $invoice->last_error ) ) { |
|
171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
170 | + if (!empty($invoice->last_error)) { |
|
171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Backwards compatibility (billing address). |
175 | - if ( ! empty( $data['user_info'] ) ) { |
|
175 | + if (!empty($data['user_info'])) { |
|
176 | 176 | |
177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
177 | + foreach ($data['user_info'] as $key => $value) { |
|
178 | 178 | |
179 | - if ( $key == 'discounts' ) { |
|
179 | + if ($key == 'discounts') { |
|
180 | 180 | $value = (array) $value; |
181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
182 | 182 | } else { |
183 | - $data[ $key ] = $value; |
|
183 | + $data[$key] = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Backwards compatibility. |
191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
191 | + if (!empty($data['payment_details'])) { |
|
192 | 192 | |
193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
194 | - $data[ $key ] = $value; |
|
193 | + foreach ($data['payment_details'] as $key => $value) { |
|
194 | + $data[$key] = $value; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set up the owner of the invoice. |
200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
201 | 201 | |
202 | 202 | // Make sure the user exists. |
203 | - if ( ! get_userdata( $user_id ) ) { |
|
204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
203 | + if (!get_userdata($user_id)) { |
|
204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
205 | 205 | } |
206 | 206 | |
207 | - $address = wpinv_get_user_address( $user_id ); |
|
207 | + $address = wpinv_get_user_address($user_id); |
|
208 | 208 | |
209 | - foreach ( $address as $key => $value ) { |
|
209 | + foreach ($address as $key => $value) { |
|
210 | 210 | |
211 | - if ( $value == '' ) { |
|
212 | - $address[ $key ] = null; |
|
211 | + if ($value == '') { |
|
212 | + $address[$key] = null; |
|
213 | 213 | } else { |
214 | - $address[ $key ] = wpinv_clean( $value ); |
|
214 | + $address[$key] = wpinv_clean($value); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
222 | 222 | array( |
223 | 223 | |
224 | 224 | // Basic info. |
225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
238 | 238 | |
239 | 239 | // Payment info. |
240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // Billing details. |
255 | 255 | 'user_id' => $data['user_id'], |
256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
267 | 267 | |
268 | 268 | ) |
269 | 269 | |
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Backwards compatibililty. |
273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
274 | 274 | $data['items'] = array(); |
275 | 275 | |
276 | - foreach( $data['cart_details'] as $_item ) { |
|
276 | + foreach ($data['cart_details'] as $_item) { |
|
277 | 277 | |
278 | 278 | // Ensure that we have an item id. |
279 | - if ( empty( $_item['id'] ) ) { |
|
279 | + if (empty($_item['id'])) { |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Retrieve the item. |
284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
285 | 285 | |
286 | 286 | // Ensure that it is purchasable. |
287 | - if ( ! $item->can_purchase() ) { |
|
287 | + if (!$item->can_purchase()) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set quantity. |
292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
293 | - $item->set_quantity( $_item['quantity'] ); |
|
292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
293 | + $item->set_quantity($_item['quantity']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set price. |
297 | - if ( isset( $_item['item_price'] ) ) { |
|
298 | - $item->set_price( $_item['item_price'] ); |
|
297 | + if (isset($_item['item_price'])) { |
|
298 | + $item->set_price($_item['item_price']); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( isset( $_item['custom_price'] ) ) { |
|
302 | - $item->set_price( $_item['custom_price'] ); |
|
301 | + if (isset($_item['custom_price'])) { |
|
302 | + $item->set_price($_item['custom_price']); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Set name. |
306 | - if ( ! empty( $_item['name'] ) ) { |
|
307 | - $item->set_name( $_item['name'] ); |
|
306 | + if (!empty($_item['name'])) { |
|
307 | + $item->set_name($_item['name']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set description. |
311 | - if ( isset( $_item['description'] ) ) { |
|
312 | - $item->set_custom_description( $_item['description'] ); |
|
311 | + if (isset($_item['description'])) { |
|
312 | + $item->set_custom_description($_item['description']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set meta. |
316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
317 | 317 | |
318 | - $item->set_item_meta( $_item['meta'] ); |
|
318 | + $item->set_item_meta($_item['meta']); |
|
319 | 319 | |
320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
320 | + if (isset($_item['meta']['description'])) { |
|
321 | + $item->set_custom_description($_item['meta']['description']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Add invoice items. |
332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
333 | 333 | |
334 | - $invoice->set_items( array() ); |
|
334 | + $invoice->set_items(array()); |
|
335 | 335 | |
336 | - foreach ( $data['items'] as $item ) { |
|
336 | + foreach ($data['items'] as $item) { |
|
337 | 337 | |
338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
339 | - $invoice->add_item( $item ); |
|
338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
339 | + $invoice->add_item($item); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |
@@ -347,30 +347,30 @@ discard block |
||
347 | 347 | $invoice->recalculate_total(); |
348 | 348 | $invoice->save(); |
349 | 349 | |
350 | - if ( ! $invoice->get_id() ) { |
|
351 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
350 | + if (!$invoice->get_id()) { |
|
351 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | // Add private note. |
355 | - if ( ! empty( $data['private_note'] ) ) { |
|
356 | - $invoice->add_note( $data['private_note'] ); |
|
355 | + if (!empty($data['private_note'])) { |
|
356 | + $invoice->add_note($data['private_note']); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | // User notes. |
360 | - if ( !empty( $data['user_note'] ) ) { |
|
361 | - $invoice->add_note( $data['user_note'], true ); |
|
360 | + if (!empty($data['user_note'])) { |
|
361 | + $invoice->add_note($data['user_note'], true); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // Created via. |
365 | - if ( isset( $data['created_via'] ) ) { |
|
366 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
365 | + if (isset($data['created_via'])) { |
|
366 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | // Backwards compatiblity. |
370 | - if ( $invoice->is_quote() ) { |
|
370 | + if ($invoice->is_quote()) { |
|
371 | 371 | |
372 | - if ( isset( $data['valid_until'] ) ) { |
|
373 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
372 | + if (isset($data['valid_until'])) { |
|
373 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
374 | 374 | } |
375 | 375 | return $invoice; |
376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | * @param $bool $deprecated |
386 | 386 | * @return WPInv_Invoice|null |
387 | 387 | */ |
388 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
388 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
389 | 389 | |
390 | 390 | // If we are retrieving the invoice from the cart... |
391 | - if ( $deprecated && empty( $invoice ) ) { |
|
391 | + if ($deprecated && empty($invoice)) { |
|
392 | 392 | $invoice = (int) getpaid_get_current_invoice_id(); |
393 | 393 | } |
394 | 394 | |
395 | 395 | // Retrieve the invoice. |
396 | - $invoice = new WPInv_Invoice( $invoice ); |
|
396 | + $invoice = new WPInv_Invoice($invoice); |
|
397 | 397 | |
398 | 398 | // Check if it exists. |
399 | - if ( $invoice->get_id() != 0 ) { |
|
399 | + if ($invoice->get_id() != 0) { |
|
400 | 400 | return $invoice; |
401 | 401 | } |
402 | 402 | |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | * @param array $args Args to search for. |
410 | 410 | * @return WPInv_Invoice[]|int[]|object |
411 | 411 | */ |
412 | -function wpinv_get_invoices( $args ) { |
|
412 | +function wpinv_get_invoices($args) { |
|
413 | 413 | |
414 | 414 | // Prepare args. |
415 | 415 | $args = wp_parse_args( |
416 | 416 | $args, |
417 | 417 | array( |
418 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
418 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
419 | 419 | 'type' => 'wpi_invoice', |
420 | - 'limit' => get_option( 'posts_per_page' ), |
|
420 | + 'limit' => get_option('posts_per_page'), |
|
421 | 421 | 'return' => 'objects', |
422 | 422 | ) |
423 | 423 | ); |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | 'post__in' => 'include', |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $map_legacy as $to => $from ) { |
|
439 | - if ( isset( $args[ $from ] ) ) { |
|
440 | - $args[ $to ] = $args[ $from ]; |
|
441 | - unset( $args[ $from ] ); |
|
438 | + foreach ($map_legacy as $to => $from) { |
|
439 | + if (isset($args[$from])) { |
|
440 | + $args[$to] = $args[$from]; |
|
441 | + unset($args[$from]); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Backwards compatibility. |
446 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
446 | + if (!empty($args['email']) && empty($args['user'])) { |
|
447 | 447 | $args['user'] = $args['email']; |
448 | - unset( $args['email'] ); |
|
448 | + unset($args['email']); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | // Handle cases where the user is set as an email. |
452 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
453 | - $user = get_user_by( 'email', $args['user'] ); |
|
452 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
453 | + $user = get_user_by('email', $args['user']); |
|
454 | 454 | |
455 | - if ( $user ) { |
|
455 | + if ($user) { |
|
456 | 456 | $args['author'] = $user->user_email; |
457 | 457 | } |
458 | 458 | |
@@ -463,31 +463,31 @@ discard block |
||
463 | 463 | |
464 | 464 | // Show all posts. |
465 | 465 | $paginate = true; |
466 | - if ( isset( $args['paginate'] ) ) { |
|
466 | + if (isset($args['paginate'])) { |
|
467 | 467 | |
468 | 468 | $paginate = $args['paginate']; |
469 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
470 | - unset( $args['paginate'] ); |
|
469 | + $args['no_found_rows'] = empty($args['paginate']); |
|
470 | + unset($args['paginate']); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
474 | 474 | // Whether to return objects or fields. |
475 | 475 | $return = $args['return']; |
476 | - unset( $args['return'] ); |
|
476 | + unset($args['return']); |
|
477 | 477 | |
478 | 478 | // Get invoices. |
479 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
479 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
480 | 480 | |
481 | 481 | // Prepare the results. |
482 | - if ( 'objects' === $return ) { |
|
483 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
484 | - } elseif ( 'self' === $return ) { |
|
482 | + if ('objects' === $return) { |
|
483 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
484 | + } elseif ('self' === $return) { |
|
485 | 485 | return $invoices; |
486 | 486 | } else { |
487 | 487 | $results = $invoices->posts; |
488 | 488 | } |
489 | 489 | |
490 | - if ( $paginate ) { |
|
490 | + if ($paginate) { |
|
491 | 491 | return (object) array( |
492 | 492 | 'invoices' => $results, |
493 | 493 | 'total' => $invoices->found_posts, |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @param string $transaction_id The transaction id to check. |
506 | 506 | * @return int Invoice id on success or 0 on failure |
507 | 507 | */ |
508 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
509 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
508 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
509 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $invoice_number The invoice number to check. |
516 | 516 | * @return int Invoice id on success or 0 on failure |
517 | 517 | */ |
518 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
519 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
518 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
519 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | * @param string $invoice_key The invoice key to check. |
526 | 526 | * @return int Invoice id on success or 0 on failure |
527 | 527 | */ |
528 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
529 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
528 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
529 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -536,19 +536,19 @@ discard block |
||
536 | 536 | * @param string $type Optionally filter by type i.e customer|system |
537 | 537 | * @return array|null |
538 | 538 | */ |
539 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
539 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
540 | 540 | |
541 | 541 | // Prepare the invoice. |
542 | - $invoice = wpinv_get_invoice( $invoice ); |
|
543 | - if ( empty( $invoice ) ) { |
|
542 | + $invoice = wpinv_get_invoice($invoice); |
|
543 | + if (empty($invoice)) { |
|
544 | 544 | return NULL; |
545 | 545 | } |
546 | 546 | |
547 | 547 | // Fetch notes. |
548 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
548 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
549 | 549 | |
550 | 550 | // Filter the notes. |
551 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
551 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -558,27 +558,27 @@ discard block |
||
558 | 558 | $columns = array( |
559 | 559 | |
560 | 560 | 'invoice-number' => array( |
561 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
561 | + 'title' => __('Invoice', 'invoicing'), |
|
562 | 562 | 'class' => 'text-left' |
563 | 563 | ), |
564 | 564 | |
565 | 565 | 'created-date' => array( |
566 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
566 | + 'title' => __('Created Date', 'invoicing'), |
|
567 | 567 | 'class' => 'text-left' |
568 | 568 | ), |
569 | 569 | |
570 | 570 | 'payment-date' => array( |
571 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
571 | + 'title' => __('Payment Date', 'invoicing'), |
|
572 | 572 | 'class' => 'text-left' |
573 | 573 | ), |
574 | 574 | |
575 | 575 | 'invoice-status' => array( |
576 | - 'title' => __( 'Status', 'invoicing' ), |
|
576 | + 'title' => __('Status', 'invoicing'), |
|
577 | 577 | 'class' => 'text-center' |
578 | 578 | ), |
579 | 579 | |
580 | 580 | 'invoice-total' => array( |
581 | - 'title' => __( 'Total', 'invoicing' ), |
|
581 | + 'title' => __('Total', 'invoicing'), |
|
582 | 582 | 'class' => 'text-right' |
583 | 583 | ), |
584 | 584 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | |
590 | 590 | ); |
591 | 591 | |
592 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
592 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -599,54 +599,54 @@ discard block |
||
599 | 599 | |
600 | 600 | // Find the invoice. |
601 | 601 | $invoice_id = getpaid_get_current_invoice_id(); |
602 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
602 | + $invoice = new WPInv_Invoice($invoice_id); |
|
603 | 603 | |
604 | 604 | // Abort if non was found. |
605 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
605 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
606 | 606 | |
607 | 607 | return aui()->alert( |
608 | 608 | array( |
609 | 609 | 'type' => 'warning', |
610 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
610 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
611 | 611 | ) |
612 | 612 | ); |
613 | 613 | |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Can the user view this invoice? |
617 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
617 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
618 | 618 | |
619 | 619 | return aui()->alert( |
620 | 620 | array( |
621 | 621 | 'type' => 'warning', |
622 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
622 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
623 | 623 | ) |
624 | 624 | ); |
625 | 625 | |
626 | 626 | } |
627 | 627 | |
628 | 628 | // Load the template. |
629 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
629 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
630 | 630 | |
631 | 631 | } |
632 | 632 | |
633 | 633 | /** |
634 | 634 | * Displays the invoice history. |
635 | 635 | */ |
636 | -function getpaid_invoice_history( $user_id = 0 ) { |
|
636 | +function getpaid_invoice_history($user_id = 0) { |
|
637 | 637 | |
638 | 638 | // Ensure that we have a user id. |
639 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
639 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
640 | 640 | $user_id = get_current_user_id(); |
641 | 641 | } |
642 | 642 | |
643 | 643 | // View user id. |
644 | - if ( empty( $user_id ) ) { |
|
644 | + if (empty($user_id)) { |
|
645 | 645 | |
646 | 646 | return aui()->alert( |
647 | 647 | array( |
648 | 648 | 'type' => 'warning', |
649 | - 'content' => __( 'You must be logged in to view your invoice history.', 'invoicing' ), |
|
649 | + 'content' => __('You must be logged in to view your invoice history.', 'invoicing'), |
|
650 | 650 | ) |
651 | 651 | ); |
652 | 652 | |
@@ -656,57 +656,57 @@ discard block |
||
656 | 656 | $invoices = wpinv_get_invoices( |
657 | 657 | |
658 | 658 | array( |
659 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
659 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
660 | 660 | 'user' => $user_id, |
661 | 661 | 'paginate' => true, |
662 | 662 | ) |
663 | 663 | |
664 | 664 | ); |
665 | 665 | |
666 | - if ( empty( $invoices->total ) ) { |
|
666 | + if (empty($invoices->total)) { |
|
667 | 667 | |
668 | 668 | return aui()->alert( |
669 | 669 | array( |
670 | 670 | 'type' => 'info', |
671 | - 'content' => __( 'No invoices found.', 'invoicing' ), |
|
671 | + 'content' => __('No invoices found.', 'invoicing'), |
|
672 | 672 | ) |
673 | 673 | ); |
674 | 674 | |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Load the template. |
678 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices' ) ); |
|
678 | + return wpinv_get_template_html('invoice-history.php', compact('invoices')); |
|
679 | 679 | |
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
683 | 683 | * Formats an invoice number given an invoice type. |
684 | 684 | */ |
685 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
685 | +function wpinv_format_invoice_number($number, $type = '') { |
|
686 | 686 | |
687 | 687 | // Allow other plugins to overide this. |
688 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
689 | - if ( null !== $check ) { |
|
688 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
689 | + if (null !== $check) { |
|
690 | 690 | return $check; |
691 | 691 | } |
692 | 692 | |
693 | 693 | // Ensure that we have a numeric number. |
694 | - if ( ! is_numeric( $number ) ) { |
|
694 | + if (!is_numeric($number)) { |
|
695 | 695 | return $number; |
696 | 696 | } |
697 | 697 | |
698 | 698 | // Format the number. |
699 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
700 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
701 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
702 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
703 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
704 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
699 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
700 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
701 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
702 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
703 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
704 | + $formatted_number = zeroise(absint($number), $padd); |
|
705 | 705 | |
706 | 706 | // Add the prefix and post fix. |
707 | 707 | $formatted_number = $prefix . $formatted_number . $postfix; |
708 | 708 | |
709 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
709 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | /** |
@@ -715,58 +715,58 @@ discard block |
||
715 | 715 | * @param string $type. |
716 | 716 | * @return int|null|bool |
717 | 717 | */ |
718 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
718 | +function wpinv_get_next_invoice_number($type = '') { |
|
719 | 719 | |
720 | 720 | // Allow plugins to overide this. |
721 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
722 | - if ( null !== $check ) { |
|
721 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
722 | + if (null !== $check) { |
|
723 | 723 | return $check; |
724 | 724 | } |
725 | 725 | |
726 | 726 | // Ensure sequential invoice numbers is active. |
727 | - if ( ! wpinv_sequential_number_active() ) { |
|
727 | + if (!wpinv_sequential_number_active()) { |
|
728 | 728 | return false; |
729 | 729 | } |
730 | 730 | |
731 | 731 | // Retrieve the current number and the start number. |
732 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
733 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
732 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
733 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
734 | 734 | |
735 | 735 | // Ensure that we are starting at a positive integer. |
736 | - $start = max( $start, 1 ); |
|
736 | + $start = max($start, 1); |
|
737 | 737 | |
738 | 738 | // If this is the first invoice, use the start number. |
739 | - $number = max( $start, $number ); |
|
739 | + $number = max($start, $number); |
|
740 | 740 | |
741 | 741 | // Format the invoice number. |
742 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
742 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
743 | 743 | |
744 | 744 | // Ensure that this number is unique. |
745 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
745 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
746 | 746 | |
747 | 747 | // We found a match. Nice. |
748 | - if ( empty( $invoice_id ) ) { |
|
749 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
750 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
748 | + if (empty($invoice_id)) { |
|
749 | + update_option('wpinv_last_invoice_number', $number); |
|
750 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
751 | 751 | } |
752 | 752 | |
753 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
754 | - return wpinv_get_next_invoice_number( $type ); |
|
753 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
754 | + return wpinv_get_next_invoice_number($type); |
|
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
759 | 759 | * The prefix used for invoice paths. |
760 | 760 | */ |
761 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
762 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
761 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
762 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
763 | 763 | } |
764 | 764 | |
765 | -function wpinv_generate_post_name( $post_ID ) { |
|
766 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
767 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
765 | +function wpinv_generate_post_name($post_ID) { |
|
766 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
767 | + $post_name = sanitize_title($prefix . $post_ID); |
|
768 | 768 | |
769 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
769 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
776 | 776 | */ |
777 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
778 | - $invoice = new WPInv_Invoice( $invoice ); |
|
777 | +function wpinv_is_invoice_viewed($invoice) { |
|
778 | + $invoice = new WPInv_Invoice($invoice); |
|
779 | 779 | return (bool) $invoice->get_is_viewed(); |
780 | 780 | } |
781 | 781 | |
@@ -784,17 +784,17 @@ discard block |
||
784 | 784 | * |
785 | 785 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
786 | 786 | */ |
787 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
788 | - $invoice = new WPInv_Invoice( $invoice ); |
|
787 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
788 | + $invoice = new WPInv_Invoice($invoice); |
|
789 | 789 | |
790 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
791 | - $invoice->set_is_viewed( true ); |
|
790 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
791 | + $invoice->set_is_viewed(true); |
|
792 | 792 | $invoice->save(); |
793 | 793 | } |
794 | 794 | |
795 | 795 | } |
796 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
797 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
796 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
797 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
798 | 798 | |
799 | 799 | /** |
800 | 800 | * Processes an invoice refund. |
@@ -803,27 +803,27 @@ discard block |
||
803 | 803 | * @param array $status_transition |
804 | 804 | * @todo: descrease customer/store earnings |
805 | 805 | */ |
806 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
806 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
807 | 807 | |
808 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
808 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
809 | 809 | return; |
810 | 810 | } |
811 | 811 | |
812 | 812 | $discount_code = $invoice->get_discount_code(); |
813 | - if ( ! empty( $discount_code ) ) { |
|
814 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
813 | + if (!empty($discount_code)) { |
|
814 | + $discount = wpinv_get_discount_obj($discount_code); |
|
815 | 815 | |
816 | - if ( $discount->exists() ) { |
|
816 | + if ($discount->exists()) { |
|
817 | 817 | $discount->increase_usage( -1 ); |
818 | 818 | } |
819 | 819 | |
820 | 820 | } |
821 | 821 | |
822 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
823 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
824 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
822 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
823 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
824 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
825 | 825 | } |
826 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
826 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
827 | 827 | |
828 | 828 | |
829 | 829 | /** |
@@ -831,48 +831,48 @@ discard block |
||
831 | 831 | * |
832 | 832 | * @param int $invoice_id |
833 | 833 | */ |
834 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
834 | +function getpaid_process_invoice_payment($invoice_id) { |
|
835 | 835 | |
836 | 836 | // Fetch the invoice. |
837 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
837 | + $invoice = new WPInv_Invoice($invoice_id); |
|
838 | 838 | |
839 | 839 | // We only want to do this once. |
840 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
840 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
841 | 841 | return; |
842 | 842 | } |
843 | 843 | |
844 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
844 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
845 | 845 | |
846 | 846 | // Fires when processing a payment. |
847 | - do_action( 'getpaid_process_payment', $invoice ); |
|
847 | + do_action('getpaid_process_payment', $invoice); |
|
848 | 848 | |
849 | 849 | // Fire an action for each invoice item. |
850 | - foreach( $invoice->get_items() as $item ) { |
|
851 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
850 | + foreach ($invoice->get_items() as $item) { |
|
851 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | // Increase discount usage. |
855 | 855 | $discount_code = $invoice->get_discount_code(); |
856 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
857 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
856 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
857 | + $discount = wpinv_get_discount_obj($discount_code); |
|
858 | 858 | |
859 | - if ( $discount->exists() ) { |
|
859 | + if ($discount->exists()) { |
|
860 | 860 | $discount->increase_usage(); |
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
864 | 864 | |
865 | 865 | // Record reverse vat. |
866 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
866 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
867 | 867 | |
868 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
869 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
868 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
869 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | } |
873 | 873 | |
874 | 874 | } |
875 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
875 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
876 | 876 | |
877 | 877 | /** |
878 | 878 | * Returns an array of invoice item columns |
@@ -880,13 +880,13 @@ discard block |
||
880 | 880 | * @param int|WPInv_Invoice $invoice |
881 | 881 | * @return array |
882 | 882 | */ |
883 | -function getpaid_invoice_item_columns( $invoice ) { |
|
883 | +function getpaid_invoice_item_columns($invoice) { |
|
884 | 884 | |
885 | 885 | // Prepare the invoice. |
886 | - $invoice = new WPInv_Invoice( $invoice ); |
|
886 | + $invoice = new WPInv_Invoice($invoice); |
|
887 | 887 | |
888 | 888 | // Abort if there is no invoice. |
889 | - if ( 0 == $invoice->get_id() ) { |
|
889 | + if (0 == $invoice->get_id()) { |
|
890 | 890 | return array(); |
891 | 891 | } |
892 | 892 | |
@@ -894,47 +894,47 @@ discard block |
||
894 | 894 | $columns = apply_filters( |
895 | 895 | 'getpaid_invoice_item_columns', |
896 | 896 | array( |
897 | - 'name' => __( 'Item', 'invoicing' ), |
|
898 | - 'price' => __( 'Price', 'invoicing' ), |
|
899 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
900 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
897 | + 'name' => __('Item', 'invoicing'), |
|
898 | + 'price' => __('Price', 'invoicing'), |
|
899 | + 'quantity' => __('Quantity', 'invoicing'), |
|
900 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
901 | 901 | ), |
902 | 902 | $invoice |
903 | 903 | ); |
904 | 904 | |
905 | 905 | // Quantities. |
906 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
906 | + if (isset($columns['quantity'])) { |
|
907 | 907 | |
908 | - if ( 'hours' == $invoice->get_template() ) { |
|
909 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
908 | + if ('hours' == $invoice->get_template()) { |
|
909 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
910 | 910 | } |
911 | 911 | |
912 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
913 | - unset( $columns[ 'quantity' ] ); |
|
912 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
913 | + unset($columns['quantity']); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | } |
917 | 917 | |
918 | 918 | |
919 | 919 | // Price. |
920 | - if ( isset( $columns[ 'price' ] ) ) { |
|
920 | + if (isset($columns['price'])) { |
|
921 | 921 | |
922 | - if ( 'amount' == $invoice->get_template() ) { |
|
923 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
922 | + if ('amount' == $invoice->get_template()) { |
|
923 | + $columns['price'] = __('Amount', 'invoicing'); |
|
924 | 924 | } |
925 | 925 | |
926 | - if ( 'hours' == $invoice->get_template() ) { |
|
927 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
926 | + if ('hours' == $invoice->get_template()) { |
|
927 | + $columns['price'] = __('Rate', 'invoicing'); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | } |
931 | 931 | |
932 | 932 | |
933 | 933 | // Sub total. |
934 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
934 | + if (isset($columns['subtotal'])) { |
|
935 | 935 | |
936 | - if ( 'amount' == $invoice->get_template() ) { |
|
937 | - unset( $columns[ 'subtotal' ] ); |
|
936 | + if ('amount' == $invoice->get_template()) { |
|
937 | + unset($columns['subtotal']); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | } |
@@ -948,30 +948,30 @@ discard block |
||
948 | 948 | * @param int|WPInv_Invoice $invoice |
949 | 949 | * @return array |
950 | 950 | */ |
951 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
951 | +function getpaid_invoice_totals_rows($invoice) { |
|
952 | 952 | |
953 | 953 | // Prepare the invoice. |
954 | - $invoice = new WPInv_Invoice( $invoice ); |
|
954 | + $invoice = new WPInv_Invoice($invoice); |
|
955 | 955 | |
956 | 956 | // Abort if there is no invoice. |
957 | - if ( 0 == $invoice->get_id() ) { |
|
957 | + if (0 == $invoice->get_id()) { |
|
958 | 958 | return array(); |
959 | 959 | } |
960 | 960 | |
961 | 961 | $totals = apply_filters( |
962 | 962 | 'getpaid_invoice_totals_rows', |
963 | 963 | array( |
964 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
965 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
966 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
967 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
968 | - 'total' => __( 'Total', 'invoicing' ), |
|
964 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
965 | + 'tax' => __('Tax', 'invoicing'), |
|
966 | + 'fee' => __('Fee', 'invoicing'), |
|
967 | + 'discount' => __('Discount', 'invoicing'), |
|
968 | + 'total' => __('Total', 'invoicing'), |
|
969 | 969 | ), |
970 | 970 | $invoice |
971 | 971 | ); |
972 | 972 | |
973 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
974 | - unset( $totals['tax'] ); |
|
973 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
974 | + unset($totals['tax']); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | return $totals; |
@@ -982,47 +982,47 @@ discard block |
||
982 | 982 | * |
983 | 983 | * @param WPInv_Invoice $invoice |
984 | 984 | */ |
985 | -function getpaid_new_invoice( $invoice ) { |
|
985 | +function getpaid_new_invoice($invoice) { |
|
986 | 986 | |
987 | - if ( ! $invoice->get_status() ) { |
|
987 | + if (!$invoice->get_status()) { |
|
988 | 988 | return; |
989 | 989 | } |
990 | 990 | |
991 | 991 | // Add an invoice created note. |
992 | 992 | $invoice->add_note( |
993 | 993 | sprintf( |
994 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
995 | - ucfirst( $invoice->get_type() ), |
|
996 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
994 | + __('%s created with the status "%s".', 'invoicing'), |
|
995 | + ucfirst($invoice->get_type()), |
|
996 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
997 | 997 | ) |
998 | 998 | ); |
999 | 999 | |
1000 | 1000 | } |
1001 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
1001 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1002 | 1002 | |
1003 | 1003 | /** |
1004 | 1004 | * This function updates invoice caches. |
1005 | 1005 | * |
1006 | 1006 | * @param WPInv_Invoice $invoice |
1007 | 1007 | */ |
1008 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1008 | +function getpaid_update_invoice_caches($invoice) { |
|
1009 | 1009 | |
1010 | 1010 | // Cache invoice number. |
1011 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1011 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1012 | 1012 | |
1013 | 1013 | // Cache invoice key. |
1014 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1014 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1015 | 1015 | |
1016 | 1016 | // (Maybe) cache transaction id. |
1017 | 1017 | $transaction_id = $invoice->get_transaction_id(); |
1018 | 1018 | |
1019 | - if ( ! empty( $transaction_id ) ) { |
|
1020 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1019 | + if (!empty($transaction_id)) { |
|
1020 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | } |
1024 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1025 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1024 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1025 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1026 | 1026 | |
1027 | 1027 | /** |
1028 | 1028 | * Duplicates an invoice. |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1033 | 1033 | * @return WPInv_Invoice The new invoice. |
1034 | 1034 | */ |
1035 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1035 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1036 | 1036 | |
1037 | 1037 | // Create the new invoice. |
1038 | 1038 | $invoice = new WPInv_Invoice(); |
@@ -1093,126 +1093,126 @@ discard block |
||
1093 | 1093 | * @param WPInv_Invoice $invoice |
1094 | 1094 | * @return array |
1095 | 1095 | */ |
1096 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1096 | +function getpaid_get_invoice_meta($invoice) { |
|
1097 | 1097 | |
1098 | 1098 | // Load the invoice meta. |
1099 | 1099 | $meta = array( |
1100 | 1100 | |
1101 | 1101 | 'number' => array( |
1102 | 1102 | 'label' => sprintf( |
1103 | - __( '%s Number', 'invoicing' ), |
|
1104 | - ucfirst( $invoice->get_type() ) |
|
1103 | + __('%s Number', 'invoicing'), |
|
1104 | + ucfirst($invoice->get_type()) |
|
1105 | 1105 | ), |
1106 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1106 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1107 | 1107 | ), |
1108 | 1108 | |
1109 | 1109 | 'status' => array( |
1110 | 1110 | 'label' => sprintf( |
1111 | - __( '%s Status', 'invoicing' ), |
|
1112 | - ucfirst( $invoice->get_type() ) |
|
1111 | + __('%s Status', 'invoicing'), |
|
1112 | + ucfirst($invoice->get_type()) |
|
1113 | 1113 | ), |
1114 | 1114 | 'value' => $invoice->get_status_label_html(), |
1115 | 1115 | ), |
1116 | 1116 | |
1117 | 1117 | 'date' => array( |
1118 | 1118 | 'label' => sprintf( |
1119 | - __( '%s Date', 'invoicing' ), |
|
1120 | - ucfirst( $invoice->get_type() ) |
|
1119 | + __('%s Date', 'invoicing'), |
|
1120 | + ucfirst($invoice->get_type()) |
|
1121 | 1121 | ), |
1122 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1122 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1123 | 1123 | ), |
1124 | 1124 | |
1125 | 1125 | 'date_paid' => array( |
1126 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1127 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1126 | + 'label' => __('Paid On', 'invoicing'), |
|
1127 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1128 | 1128 | ), |
1129 | 1129 | |
1130 | 1130 | 'gateway' => array( |
1131 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1132 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1131 | + 'label' => __('Payment Method', 'invoicing'), |
|
1132 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1133 | 1133 | ), |
1134 | 1134 | |
1135 | 1135 | 'transaction_id' => array( |
1136 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1137 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1136 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1137 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1138 | 1138 | ), |
1139 | 1139 | |
1140 | 1140 | 'due_date' => array( |
1141 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1142 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1141 | + 'label' => __('Due Date', 'invoicing'), |
|
1142 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1143 | 1143 | ), |
1144 | 1144 | |
1145 | 1145 | 'vat_number' => array( |
1146 | 1146 | 'label' => sprintf( |
1147 | - __( '%s Number', 'invoicing' ), |
|
1147 | + __('%s Number', 'invoicing'), |
|
1148 | 1148 | getpaid_tax()->get_vat_name() |
1149 | 1149 | ), |
1150 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1150 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1151 | 1151 | ), |
1152 | 1152 | |
1153 | 1153 | ); |
1154 | 1154 | |
1155 | 1155 | // If it is not paid, remove the date of payment. |
1156 | - if ( ! $invoice->is_paid() ) { |
|
1157 | - unset( $meta[ 'date_paid' ] ); |
|
1158 | - unset( $meta[ 'transaction_id' ] ); |
|
1156 | + if (!$invoice->is_paid()) { |
|
1157 | + unset($meta['date_paid']); |
|
1158 | + unset($meta['transaction_id']); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1162 | - unset( $meta[ 'gateway' ] ); |
|
1161 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1162 | + unset($meta['gateway']); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | // Only display the due date if due dates are enabled. |
1166 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1167 | - unset( $meta[ 'due_date' ] ); |
|
1166 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1167 | + unset($meta['due_date']); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | // Only display the vat number if taxes are enabled. |
1171 | - if ( ! wpinv_use_taxes() ) { |
|
1172 | - unset( $meta[ 'vat_number' ] ); |
|
1171 | + if (!wpinv_use_taxes()) { |
|
1172 | + unset($meta['vat_number']); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | - if ( $invoice->is_recurring() ) { |
|
1175 | + if ($invoice->is_recurring()) { |
|
1176 | 1176 | |
1177 | 1177 | // Link to the parent invoice. |
1178 | - if ( $invoice->is_renewal() ) { |
|
1178 | + if ($invoice->is_renewal()) { |
|
1179 | 1179 | |
1180 | - $meta[ 'parent' ] = array( |
|
1180 | + $meta['parent'] = array( |
|
1181 | 1181 | |
1182 | 1182 | 'label' => sprintf( |
1183 | - __( 'Parent %s', 'invoicing' ), |
|
1184 | - ucfirst( $invoice->get_type() ) |
|
1183 | + __('Parent %s', 'invoicing'), |
|
1184 | + ucfirst($invoice->get_type()) |
|
1185 | 1185 | ), |
1186 | 1186 | |
1187 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1187 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1188 | 1188 | |
1189 | 1189 | ); |
1190 | 1190 | |
1191 | 1191 | } |
1192 | 1192 | |
1193 | - $subscription = wpinv_get_subscription( $invoice ); |
|
1193 | + $subscription = wpinv_get_subscription($invoice); |
|
1194 | 1194 | |
1195 | - if ( ! empty ( $subscription ) ) { |
|
1195 | + if (!empty ($subscription)) { |
|
1196 | 1196 | |
1197 | 1197 | // Display the renewal date. |
1198 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1198 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1199 | 1199 | |
1200 | - $meta[ 'renewal_date' ] = array( |
|
1200 | + $meta['renewal_date'] = array( |
|
1201 | 1201 | |
1202 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1203 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1202 | + 'label' => __('Renews On', 'invoicing'), |
|
1203 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1204 | 1204 | |
1205 | 1205 | ); |
1206 | 1206 | |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - if ( $invoice->is_parent() ) { |
|
1209 | + if ($invoice->is_parent()) { |
|
1210 | 1210 | |
1211 | 1211 | // Display the recurring amount. |
1212 | - $meta[ 'recurring_total' ] = array( |
|
1212 | + $meta['recurring_total'] = array( |
|
1213 | 1213 | |
1214 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1215 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
1214 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1215 | + 'value' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
1216 | 1216 | |
1217 | 1217 | ); |
1218 | 1218 | |
@@ -1222,15 +1222,15 @@ discard block |
||
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | // Add the invoice total to the meta. |
1225 | - $meta[ 'invoice_total' ] = array( |
|
1225 | + $meta['invoice_total'] = array( |
|
1226 | 1226 | |
1227 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1228 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
1227 | + 'label' => __('Total Amount', 'invoicing'), |
|
1228 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
1229 | 1229 | |
1230 | 1230 | ); |
1231 | 1231 | |
1232 | 1232 | // Provide a way for third party plugins to filter the meta. |
1233 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1233 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1234 | 1234 | |
1235 | 1235 | return $meta; |
1236 | 1236 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.0.19 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * REST API invoices controller class. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | |
54 | 54 | 'customers' => array( |
55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
55 | + 'description' => __('Limit result set to invoices for specific user ids.', 'invoicing'), |
|
56 | 56 | 'type' => 'array', |
57 | 57 | 'items' => array( |
58 | 58 | 'type' => 'integer', |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | ), |
63 | 63 | |
64 | 64 | 'exclude_customers' => array( |
65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
65 | + 'description' => __('Exclude invoices to specific users.', 'invoicing'), |
|
66 | 66 | 'type' => 'array', |
67 | 67 | 'items' => array( |
68 | 68 | 'type' => 'integer', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ), |
73 | 73 | |
74 | 74 | 'parent' => array( |
75 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
75 | + 'description' => __('Limit result set to those of particular parent IDs.', 'invoicing'), |
|
76 | 76 | 'type' => 'array', |
77 | 77 | 'items' => array( |
78 | 78 | 'type' => 'integer', |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ), |
83 | 83 | |
84 | 84 | 'parent_exclude' => array( |
85 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
85 | + 'description' => __('Limit result set to all items except those of a particular parent ID.', 'invoicing'), |
|
86 | 86 | 'type' => 'array', |
87 | 87 | 'items' => array( |
88 | 88 | 'type' => 'integer', |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ); |
97 | 97 | |
98 | 98 | // Filter collection parameters for the invoices controller. |
99 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
99 | + return apply_filters('getpaid_rest_invoices_collection_params', $params, $this); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * @param WP_REST_Request $request Request object. |
108 | 108 | * @return array $query_args |
109 | 109 | */ |
110 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
110 | + protected function prepare_items_query($prepared_args = array(), $request = null) { |
|
111 | 111 | |
112 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
112 | + $query_args = parent::prepare_items_query($prepared_args); |
|
113 | 113 | |
114 | 114 | // Retrieve invoices for specific customers. |
115 | - if ( ! empty( $request['customers'] ) ) { |
|
115 | + if (!empty($request['customers'])) { |
|
116 | 116 | $query_args['author__in'] = $request['customers']; |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Skip invoices for specific customers. |
120 | - if ( ! empty( $request['exclude_customers'] ) ) { |
|
120 | + if (!empty($request['exclude_customers'])) { |
|
121 | 121 | $query_args['author__not_in'] = $request['exclude_customers']; |
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
124 | + return apply_filters('getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this); |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return array A list of registered item statuses. |
134 | 134 | */ |
135 | 135 | public function get_post_statuses() { |
136 | - return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
136 | + return array_keys(wpinv_get_invoice_statuses(true, false, $this->post_type)); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param WPInv_Invoice $invoice Invoice to save. |
143 | 143 | * @return WP_Error|WPInv_Invoice |
144 | 144 | */ |
145 | - protected function save_object( $invoice ) { |
|
145 | + protected function save_object($invoice) { |
|
146 | 146 | $invoice->recalculate_total(); |
147 | - return parent::save_object( $invoice ); |
|
147 | + return parent::save_object($invoice); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Invoice class. |
@@ -135,40 +135,40 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
137 | 137 | */ |
138 | - public function __construct( $invoice = false ) { |
|
138 | + public function __construct($invoice = false) { |
|
139 | 139 | |
140 | - parent::__construct( $invoice ); |
|
140 | + parent::__construct($invoice); |
|
141 | 141 | |
142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
143 | - $this->set_id( $invoice ); |
|
144 | - } elseif ( $invoice instanceof self ) { |
|
145 | - $this->set_id( $invoice->get_id() ); |
|
146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
147 | - $this->set_id( $invoice->ID ); |
|
148 | - } elseif ( is_array( $invoice ) ) { |
|
149 | - $this->set_props( $invoice ); |
|
142 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
143 | + $this->set_id($invoice); |
|
144 | + } elseif ($invoice instanceof self) { |
|
145 | + $this->set_id($invoice->get_id()); |
|
146 | + } elseif (!empty($invoice->ID)) { |
|
147 | + $this->set_id($invoice->ID); |
|
148 | + } elseif (is_array($invoice)) { |
|
149 | + $this->set_props($invoice); |
|
150 | 150 | |
151 | - if ( isset( $invoice['ID'] ) ) { |
|
152 | - $this->set_id( $invoice['ID'] ); |
|
151 | + if (isset($invoice['ID'])) { |
|
152 | + $this->set_id($invoice['ID']); |
|
153 | 153 | } |
154 | 154 | |
155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
156 | - $this->set_id( $invoice_id ); |
|
157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
158 | - $this->set_id( $invoice_id ); |
|
159 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
160 | - $this->set_id( $invoice_id ); |
|
161 | - }else { |
|
162 | - $this->set_object_read( true ); |
|
155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
156 | + $this->set_id($invoice_id); |
|
157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
158 | + $this->set_id($invoice_id); |
|
159 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
160 | + $this->set_id($invoice_id); |
|
161 | + } else { |
|
162 | + $this->set_object_read(true); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Load the datastore. |
166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
166 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
167 | 167 | |
168 | - if ( $this->get_id() > 0 ) { |
|
169 | - $this->post = get_post( $this->get_id() ); |
|
168 | + if ($this->get_id() > 0) { |
|
169 | + $this->post = get_post($this->get_id()); |
|
170 | 170 | $this->ID = $this->get_id(); |
171 | - $this->data_store->read( $this ); |
|
171 | + $this->data_store->read($this); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | } |
@@ -183,38 +183,38 @@ discard block |
||
183 | 183 | * @since 1.0.15 |
184 | 184 | * @return int |
185 | 185 | */ |
186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
186 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
187 | 187 | global $wpdb; |
188 | 188 | |
189 | 189 | // Trim the value. |
190 | - $value = trim( $value ); |
|
190 | + $value = trim($value); |
|
191 | 191 | |
192 | - if ( empty( $value ) ) { |
|
192 | + if (empty($value)) { |
|
193 | 193 | return 0; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Valid fields. |
197 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
197 | + $fields = array('key', 'number', 'transaction_id'); |
|
198 | 198 | |
199 | 199 | // Ensure a field has been passed. |
200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
200 | + if (empty($field) || !in_array($field, $fields)) { |
|
201 | 201 | return 0; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Maybe retrieve from the cache. |
205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
206 | - if ( false !== $invoice_id ) { |
|
205 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
206 | + if (false !== $invoice_id) { |
|
207 | 207 | return $invoice_id; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Fetch from the db. |
211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
212 | 212 | $invoice_id = (int) $wpdb->get_var( |
213 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
213 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | // Update the cache with our data |
217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
217 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
218 | 218 | |
219 | 219 | return $invoice_id; |
220 | 220 | } |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Checks if an invoice key is set. |
224 | 224 | */ |
225 | - public function _isset( $key ) { |
|
226 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
225 | + public function _isset($key) { |
|
226 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /* |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $context View or edit context. |
249 | 249 | * @return int |
250 | 250 | */ |
251 | - public function get_parent_id( $context = 'view' ) { |
|
252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
251 | + public function get_parent_id($context = 'view') { |
|
252 | + return (int) $this->get_prop('parent_id', $context); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @return WPInv_Invoice |
260 | 260 | */ |
261 | 261 | public function get_parent_payment() { |
262 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
262 | + return new WPInv_Invoice($this->get_parent_id()); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @param string $context View or edit context. |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public function get_status( $context = 'view' ) { |
|
283 | - return $this->get_prop( 'status', $context ); |
|
282 | + public function get_status($context = 'view') { |
|
283 | + return $this->get_prop('status', $context); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return array |
291 | 291 | */ |
292 | 292 | public function get_all_statuses() { |
293 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
293 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | public function get_status_nicename() { |
303 | 303 | $statuses = $this->get_all_statuses(); |
304 | 304 | |
305 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
305 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
306 | 306 | |
307 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
307 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function get_status_label_html() { |
317 | 317 | |
318 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
319 | - $status = sanitize_html_class( $this->get_status() ); |
|
318 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
319 | + $status = sanitize_html_class($this->get_status()); |
|
320 | 320 | |
321 | 321 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
322 | 322 | } |
@@ -328,23 +328,23 @@ discard block |
||
328 | 328 | * @param string $context View or edit context. |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public function get_version( $context = 'view' ) { |
|
332 | - return $this->get_prop( 'version', $context ); |
|
331 | + public function get_version($context = 'view') { |
|
332 | + return $this->get_prop('version', $context); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
336 | 336 | * @deprecated |
337 | 337 | */ |
338 | - public function get_invoice_date( $format = true ) { |
|
339 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
340 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
341 | - $formatted = getpaid_format_date( $date ); |
|
338 | + public function get_invoice_date($format = true) { |
|
339 | + $date = getpaid_format_date($this->get_date_completed()); |
|
340 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
341 | + $formatted = getpaid_format_date($date); |
|
342 | 342 | |
343 | - if ( $format ) { |
|
343 | + if ($format) { |
|
344 | 344 | return $formatted; |
345 | 345 | } |
346 | 346 | |
347 | - return empty( $formatted ) ? '' : $date; |
|
347 | + return empty($formatted) ? '' : $date; |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string $context View or edit context. |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public function get_date_created( $context = 'view' ) { |
|
359 | - return $this->get_prop( 'date_created', $context ); |
|
358 | + public function get_date_created($context = 'view') { |
|
359 | + return $this->get_prop('date_created', $context); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * @param string $context View or edit context. |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public function get_created_date( $context = 'view' ) { |
|
370 | - return $this->get_date_created( $context ); |
|
369 | + public function get_created_date($context = 'view') { |
|
370 | + return $this->get_date_created($context); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | * @param string $context View or edit context. |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - public function get_date_created_gmt( $context = 'view' ) { |
|
381 | - $date = $this->get_date_created( $context ); |
|
380 | + public function get_date_created_gmt($context = 'view') { |
|
381 | + $date = $this->get_date_created($context); |
|
382 | 382 | |
383 | - if ( $date ) { |
|
384 | - $date = get_gmt_from_date( $date ); |
|
383 | + if ($date) { |
|
384 | + $date = get_gmt_from_date($date); |
|
385 | 385 | } |
386 | 386 | return $date; |
387 | 387 | } |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param string $context View or edit context. |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public function get_date_modified( $context = 'view' ) { |
|
397 | - return $this->get_prop( 'date_modified', $context ); |
|
396 | + public function get_date_modified($context = 'view') { |
|
397 | + return $this->get_prop('date_modified', $context); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param string $context View or edit context. |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public function get_modified_date( $context = 'view' ) { |
|
408 | - return $this->get_date_modified( $context ); |
|
407 | + public function get_modified_date($context = 'view') { |
|
408 | + return $this->get_date_modified($context); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | * @param string $context View or edit context. |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
419 | - $date = $this->get_date_modified( $context ); |
|
418 | + public function get_date_modified_gmt($context = 'view') { |
|
419 | + $date = $this->get_date_modified($context); |
|
420 | 420 | |
421 | - if ( $date ) { |
|
422 | - $date = get_gmt_from_date( $date ); |
|
421 | + if ($date) { |
|
422 | + $date = get_gmt_from_date($date); |
|
423 | 423 | } |
424 | 424 | return $date; |
425 | 425 | } |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param string $context View or edit context. |
432 | 432 | * @return string |
433 | 433 | */ |
434 | - public function get_due_date( $context = 'view' ) { |
|
435 | - return $this->get_prop( 'due_date', $context ); |
|
434 | + public function get_due_date($context = 'view') { |
|
435 | + return $this->get_prop('due_date', $context); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $context View or edit context. |
443 | 443 | * @return string |
444 | 444 | */ |
445 | - public function get_date_due( $context = 'view' ) { |
|
446 | - return $this->get_due_date( $context ); |
|
445 | + public function get_date_due($context = 'view') { |
|
446 | + return $this->get_due_date($context); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | * @param string $context View or edit context. |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public function get_due_date_gmt( $context = 'view' ) { |
|
457 | - $date = $this->get_due_date( $context ); |
|
456 | + public function get_due_date_gmt($context = 'view') { |
|
457 | + $date = $this->get_due_date($context); |
|
458 | 458 | |
459 | - if ( $date ) { |
|
460 | - $date = get_gmt_from_date( $date ); |
|
459 | + if ($date) { |
|
460 | + $date = get_gmt_from_date($date); |
|
461 | 461 | } |
462 | 462 | return $date; |
463 | 463 | } |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | * @param string $context View or edit context. |
470 | 470 | * @return string |
471 | 471 | */ |
472 | - public function get_gmt_date_due( $context = 'view' ) { |
|
473 | - return $this->get_due_date_gmt( $context ); |
|
472 | + public function get_gmt_date_due($context = 'view') { |
|
473 | + return $this->get_due_date_gmt($context); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | * @param string $context View or edit context. |
481 | 481 | * @return string |
482 | 482 | */ |
483 | - public function get_completed_date( $context = 'view' ) { |
|
484 | - return $this->get_prop( 'completed_date', $context ); |
|
483 | + public function get_completed_date($context = 'view') { |
|
484 | + return $this->get_prop('completed_date', $context); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * @param string $context View or edit context. |
492 | 492 | * @return string |
493 | 493 | */ |
494 | - public function get_date_completed( $context = 'view' ) { |
|
495 | - return $this->get_completed_date( $context ); |
|
494 | + public function get_date_completed($context = 'view') { |
|
495 | + return $this->get_completed_date($context); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param string $context View or edit context. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
506 | - $date = $this->get_completed_date( $context ); |
|
505 | + public function get_completed_date_gmt($context = 'view') { |
|
506 | + $date = $this->get_completed_date($context); |
|
507 | 507 | |
508 | - if ( $date ) { |
|
509 | - $date = get_gmt_from_date( $date ); |
|
508 | + if ($date) { |
|
509 | + $date = get_gmt_from_date($date); |
|
510 | 510 | } |
511 | 511 | return $date; |
512 | 512 | } |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | * @param string $context View or edit context. |
519 | 519 | * @return string |
520 | 520 | */ |
521 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
522 | - return $this->get_completed_date_gmt( $context ); |
|
521 | + public function get_gmt_completed_date($context = 'view') { |
|
522 | + return $this->get_completed_date_gmt($context); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | /** |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | * @param string $context View or edit context. |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function get_number( $context = 'view' ) { |
|
533 | - $number = $this->get_prop( 'number', $context ); |
|
532 | + public function get_number($context = 'view') { |
|
533 | + $number = $this->get_prop('number', $context); |
|
534 | 534 | |
535 | - if ( empty( $number ) ) { |
|
535 | + if (empty($number)) { |
|
536 | 536 | $number = $this->generate_number(); |
537 | - $this->set_number( $this->generate_number() ); |
|
537 | + $this->set_number($this->generate_number()); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | return $number; |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | public function maybe_set_number() { |
549 | 549 | $number = $this->get_number(); |
550 | 550 | |
551 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
552 | - $this->set_number( $this->generate_number() ); |
|
551 | + if (empty($number) || $this->get_id() == $number) { |
|
552 | + $this->set_number($this->generate_number()); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | } |
@@ -561,8 +561,8 @@ discard block |
||
561 | 561 | * @param string $context View or edit context. |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - public function get_key( $context = 'view' ) { |
|
565 | - return $this->get_prop( 'key', $context ); |
|
564 | + public function get_key($context = 'view') { |
|
565 | + return $this->get_prop('key', $context); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -573,9 +573,9 @@ discard block |
||
573 | 573 | public function maybe_set_key() { |
574 | 574 | $key = $this->get_key(); |
575 | 575 | |
576 | - if ( empty( $key ) ) { |
|
577 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
578 | - $this->set_key( $key ); |
|
576 | + if (empty($key)) { |
|
577 | + $key = $this->generate_key($this->get_type() . '_'); |
|
578 | + $this->set_key($key); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | } |
@@ -587,15 +587,15 @@ discard block |
||
587 | 587 | * @param string $context View or edit context. |
588 | 588 | * @return string |
589 | 589 | */ |
590 | - public function get_type( $context = 'view' ) { |
|
591 | - return $this->get_prop( 'type', $context ); |
|
590 | + public function get_type($context = 'view') { |
|
591 | + return $this->get_prop('type', $context); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
595 | 595 | * @deprecated |
596 | 596 | */ |
597 | 597 | public function get_invoice_quote_type() { |
598 | - ucfirst( $this->get_type() ); |
|
598 | + ucfirst($this->get_type()); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | * @param string $context View or edit context. |
606 | 606 | * @return string |
607 | 607 | */ |
608 | - public function get_post_type( $context = 'view' ) { |
|
609 | - return $this->get_prop( 'post_type', $context ); |
|
608 | + public function get_post_type($context = 'view') { |
|
609 | + return $this->get_prop('post_type', $context); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | * @param string $context View or edit context. |
617 | 617 | * @return string |
618 | 618 | */ |
619 | - public function get_mode( $context = 'view' ) { |
|
620 | - return $this->get_prop( 'mode', $context ); |
|
619 | + public function get_mode($context = 'view') { |
|
620 | + return $this->get_prop('mode', $context); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -627,13 +627,13 @@ discard block |
||
627 | 627 | * @param string $context View or edit context. |
628 | 628 | * @return string |
629 | 629 | */ |
630 | - public function get_path( $context = 'view' ) { |
|
631 | - $path = $this->get_prop( 'path', $context ); |
|
630 | + public function get_path($context = 'view') { |
|
631 | + $path = $this->get_prop('path', $context); |
|
632 | 632 | $prefix = $this->get_type(); |
633 | 633 | |
634 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
635 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
636 | - $this->set_path( $path ); |
|
634 | + if (0 !== strpos($path, $prefix)) { |
|
635 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
636 | + $this->set_path($path); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | return $path; |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | * @param string $context View or edit context. |
647 | 647 | * @return string |
648 | 648 | */ |
649 | - public function get_name( $context = 'view' ) { |
|
650 | - return $this->get_prop( 'title', $context ); |
|
649 | + public function get_name($context = 'view') { |
|
650 | + return $this->get_prop('title', $context); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -657,8 +657,8 @@ discard block |
||
657 | 657 | * @param string $context View or edit context. |
658 | 658 | * @return string |
659 | 659 | */ |
660 | - public function get_title( $context = 'view' ) { |
|
661 | - return $this->get_name( $context ); |
|
660 | + public function get_title($context = 'view') { |
|
661 | + return $this->get_name($context); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | * @param string $context View or edit context. |
669 | 669 | * @return string |
670 | 670 | */ |
671 | - public function get_description( $context = 'view' ) { |
|
672 | - return $this->get_prop( 'description', $context ); |
|
671 | + public function get_description($context = 'view') { |
|
672 | + return $this->get_prop('description', $context); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | * @param string $context View or edit context. |
680 | 680 | * @return string |
681 | 681 | */ |
682 | - public function get_excerpt( $context = 'view' ) { |
|
683 | - return $this->get_description( $context ); |
|
682 | + public function get_excerpt($context = 'view') { |
|
683 | + return $this->get_description($context); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @param string $context View or edit context. |
691 | 691 | * @return string |
692 | 692 | */ |
693 | - public function get_summary( $context = 'view' ) { |
|
694 | - return $this->get_description( $context ); |
|
693 | + public function get_summary($context = 'view') { |
|
694 | + return $this->get_description($context); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -701,25 +701,25 @@ discard block |
||
701 | 701 | * @param string $context View or edit context. |
702 | 702 | * @return array |
703 | 703 | */ |
704 | - public function get_user_info( $context = 'view' ) { |
|
704 | + public function get_user_info($context = 'view') { |
|
705 | 705 | |
706 | 706 | $user_info = array( |
707 | - 'user_id' => $this->get_user_id( $context ), |
|
708 | - 'email' => $this->get_email( $context ), |
|
709 | - 'first_name' => $this->get_first_name( $context ), |
|
710 | - 'last_name' => $this->get_last_name( $context ), |
|
711 | - 'address' => $this->get_address( $context ), |
|
712 | - 'phone' => $this->get_phone( $context ), |
|
713 | - 'city' => $this->get_city( $context ), |
|
714 | - 'country' => $this->get_country( $context ), |
|
715 | - 'state' => $this->get_state( $context ), |
|
716 | - 'zip' => $this->get_zip( $context ), |
|
717 | - 'company' => $this->get_company( $context ), |
|
718 | - 'vat_number' => $this->get_vat_number( $context ), |
|
719 | - 'discount' => $this->get_discount_code( $context ), |
|
707 | + 'user_id' => $this->get_user_id($context), |
|
708 | + 'email' => $this->get_email($context), |
|
709 | + 'first_name' => $this->get_first_name($context), |
|
710 | + 'last_name' => $this->get_last_name($context), |
|
711 | + 'address' => $this->get_address($context), |
|
712 | + 'phone' => $this->get_phone($context), |
|
713 | + 'city' => $this->get_city($context), |
|
714 | + 'country' => $this->get_country($context), |
|
715 | + 'state' => $this->get_state($context), |
|
716 | + 'zip' => $this->get_zip($context), |
|
717 | + 'company' => $this->get_company($context), |
|
718 | + 'vat_number' => $this->get_vat_number($context), |
|
719 | + 'discount' => $this->get_discount_code($context), |
|
720 | 720 | ); |
721 | 721 | |
722 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
722 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
723 | 723 | |
724 | 724 | } |
725 | 725 | |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param string $context View or edit context. |
731 | 731 | * @return int |
732 | 732 | */ |
733 | - public function get_author( $context = 'view' ) { |
|
734 | - return (int) $this->get_prop( 'author', $context ); |
|
733 | + public function get_author($context = 'view') { |
|
734 | + return (int) $this->get_prop('author', $context); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -741,8 +741,8 @@ discard block |
||
741 | 741 | * @param string $context View or edit context. |
742 | 742 | * @return int |
743 | 743 | */ |
744 | - public function get_user_id( $context = 'view' ) { |
|
745 | - return $this->get_author( $context ); |
|
744 | + public function get_user_id($context = 'view') { |
|
745 | + return $this->get_author($context); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | /** |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | * @param string $context View or edit context. |
753 | 753 | * @return int |
754 | 754 | */ |
755 | - public function get_customer_id( $context = 'view' ) { |
|
756 | - return $this->get_author( $context ); |
|
755 | + public function get_customer_id($context = 'view') { |
|
756 | + return $this->get_author($context); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | /** |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | * @param string $context View or edit context. |
764 | 764 | * @return string |
765 | 765 | */ |
766 | - public function get_ip( $context = 'view' ) { |
|
767 | - return $this->get_prop( 'user_ip', $context ); |
|
766 | + public function get_ip($context = 'view') { |
|
767 | + return $this->get_prop('user_ip', $context); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | * @param string $context View or edit context. |
775 | 775 | * @return string |
776 | 776 | */ |
777 | - public function get_user_ip( $context = 'view' ) { |
|
778 | - return $this->get_ip( $context ); |
|
777 | + public function get_user_ip($context = 'view') { |
|
778 | + return $this->get_ip($context); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | * @param string $context View or edit context. |
786 | 786 | * @return string |
787 | 787 | */ |
788 | - public function get_customer_ip( $context = 'view' ) { |
|
789 | - return $this->get_ip( $context ); |
|
788 | + public function get_customer_ip($context = 'view') { |
|
789 | + return $this->get_ip($context); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -796,8 +796,8 @@ discard block |
||
796 | 796 | * @param string $context View or edit context. |
797 | 797 | * @return string |
798 | 798 | */ |
799 | - public function get_first_name( $context = 'view' ) { |
|
800 | - return $this->get_prop( 'first_name', $context ); |
|
799 | + public function get_first_name($context = 'view') { |
|
800 | + return $this->get_prop('first_name', $context); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | /** |
@@ -807,8 +807,8 @@ discard block |
||
807 | 807 | * @param string $context View or edit context. |
808 | 808 | * @return int |
809 | 809 | */ |
810 | - public function get_user_first_name( $context = 'view' ) { |
|
811 | - return $this->get_first_name( $context ); |
|
810 | + public function get_user_first_name($context = 'view') { |
|
811 | + return $this->get_first_name($context); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
@@ -818,8 +818,8 @@ discard block |
||
818 | 818 | * @param string $context View or edit context. |
819 | 819 | * @return int |
820 | 820 | */ |
821 | - public function get_customer_first_name( $context = 'view' ) { |
|
822 | - return $this->get_first_name( $context ); |
|
821 | + public function get_customer_first_name($context = 'view') { |
|
822 | + return $this->get_first_name($context); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | * @param string $context View or edit context. |
830 | 830 | * @return string |
831 | 831 | */ |
832 | - public function get_last_name( $context = 'view' ) { |
|
833 | - return $this->get_prop( 'last_name', $context ); |
|
832 | + public function get_last_name($context = 'view') { |
|
833 | + return $this->get_prop('last_name', $context); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | * @param string $context View or edit context. |
841 | 841 | * @return int |
842 | 842 | */ |
843 | - public function get_user_last_name( $context = 'view' ) { |
|
844 | - return $this->get_last_name( $context ); |
|
843 | + public function get_user_last_name($context = 'view') { |
|
844 | + return $this->get_last_name($context); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | * @param string $context View or edit context. |
852 | 852 | * @return int |
853 | 853 | */ |
854 | - public function get_customer_last_name( $context = 'view' ) { |
|
855 | - return $this->get_last_name( $context ); |
|
854 | + public function get_customer_last_name($context = 'view') { |
|
855 | + return $this->get_last_name($context); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
@@ -862,8 +862,8 @@ discard block |
||
862 | 862 | * @param string $context View or edit context. |
863 | 863 | * @return string |
864 | 864 | */ |
865 | - public function get_full_name( $context = 'view' ) { |
|
866 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
865 | + public function get_full_name($context = 'view') { |
|
866 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | /** |
@@ -873,8 +873,8 @@ discard block |
||
873 | 873 | * @param string $context View or edit context. |
874 | 874 | * @return int |
875 | 875 | */ |
876 | - public function get_user_full_name( $context = 'view' ) { |
|
877 | - return $this->get_full_name( $context ); |
|
876 | + public function get_user_full_name($context = 'view') { |
|
877 | + return $this->get_full_name($context); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | /** |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | * @param string $context View or edit context. |
885 | 885 | * @return int |
886 | 886 | */ |
887 | - public function get_customer_full_name( $context = 'view' ) { |
|
888 | - return $this->get_full_name( $context ); |
|
887 | + public function get_customer_full_name($context = 'view') { |
|
888 | + return $this->get_full_name($context); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * @param string $context View or edit context. |
896 | 896 | * @return string |
897 | 897 | */ |
898 | - public function get_phone( $context = 'view' ) { |
|
899 | - return $this->get_prop( 'phone', $context ); |
|
898 | + public function get_phone($context = 'view') { |
|
899 | + return $this->get_prop('phone', $context); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -906,8 +906,8 @@ discard block |
||
906 | 906 | * @param string $context View or edit context. |
907 | 907 | * @return int |
908 | 908 | */ |
909 | - public function get_phone_number( $context = 'view' ) { |
|
910 | - return $this->get_phone( $context ); |
|
909 | + public function get_phone_number($context = 'view') { |
|
910 | + return $this->get_phone($context); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | * @param string $context View or edit context. |
918 | 918 | * @return int |
919 | 919 | */ |
920 | - public function get_user_phone( $context = 'view' ) { |
|
921 | - return $this->get_phone( $context ); |
|
920 | + public function get_user_phone($context = 'view') { |
|
921 | + return $this->get_phone($context); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
@@ -928,8 +928,8 @@ discard block |
||
928 | 928 | * @param string $context View or edit context. |
929 | 929 | * @return int |
930 | 930 | */ |
931 | - public function get_customer_phone( $context = 'view' ) { |
|
932 | - return $this->get_phone( $context ); |
|
931 | + public function get_customer_phone($context = 'view') { |
|
932 | + return $this->get_phone($context); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | * @param string $context View or edit context. |
940 | 940 | * @return string |
941 | 941 | */ |
942 | - public function get_email( $context = 'view' ) { |
|
943 | - return $this->get_prop( 'email', $context ); |
|
942 | + public function get_email($context = 'view') { |
|
943 | + return $this->get_prop('email', $context); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | /** |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | * @param string $context View or edit context. |
951 | 951 | * @return string |
952 | 952 | */ |
953 | - public function get_email_address( $context = 'view' ) { |
|
954 | - return $this->get_email( $context ); |
|
953 | + public function get_email_address($context = 'view') { |
|
954 | + return $this->get_email($context); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | /** |
@@ -961,8 +961,8 @@ discard block |
||
961 | 961 | * @param string $context View or edit context. |
962 | 962 | * @return int |
963 | 963 | */ |
964 | - public function get_user_email( $context = 'view' ) { |
|
965 | - return $this->get_email( $context ); |
|
964 | + public function get_user_email($context = 'view') { |
|
965 | + return $this->get_email($context); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -972,8 +972,8 @@ discard block |
||
972 | 972 | * @param string $context View or edit context. |
973 | 973 | * @return int |
974 | 974 | */ |
975 | - public function get_customer_email( $context = 'view' ) { |
|
976 | - return $this->get_email( $context ); |
|
975 | + public function get_customer_email($context = 'view') { |
|
976 | + return $this->get_email($context); |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | /** |
@@ -983,9 +983,9 @@ discard block |
||
983 | 983 | * @param string $context View or edit context. |
984 | 984 | * @return string |
985 | 985 | */ |
986 | - public function get_country( $context = 'view' ) { |
|
987 | - $country = $this->get_prop( 'country', $context ); |
|
988 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
986 | + public function get_country($context = 'view') { |
|
987 | + $country = $this->get_prop('country', $context); |
|
988 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * @param string $context View or edit context. |
996 | 996 | * @return int |
997 | 997 | */ |
998 | - public function get_user_country( $context = 'view' ) { |
|
999 | - return $this->get_country( $context ); |
|
998 | + public function get_user_country($context = 'view') { |
|
999 | + return $this->get_country($context); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | /** |
@@ -1006,8 +1006,8 @@ discard block |
||
1006 | 1006 | * @param string $context View or edit context. |
1007 | 1007 | * @return int |
1008 | 1008 | */ |
1009 | - public function get_customer_country( $context = 'view' ) { |
|
1010 | - return $this->get_country( $context ); |
|
1009 | + public function get_customer_country($context = 'view') { |
|
1010 | + return $this->get_country($context); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | * @param string $context View or edit context. |
1018 | 1018 | * @return string |
1019 | 1019 | */ |
1020 | - public function get_state( $context = 'view' ) { |
|
1021 | - $state = $this->get_prop( 'state', $context ); |
|
1022 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1020 | + public function get_state($context = 'view') { |
|
1021 | + $state = $this->get_prop('state', $context); |
|
1022 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @param string $context View or edit context. |
1030 | 1030 | * @return int |
1031 | 1031 | */ |
1032 | - public function get_user_state( $context = 'view' ) { |
|
1033 | - return $this->get_state( $context ); |
|
1032 | + public function get_user_state($context = 'view') { |
|
1033 | + return $this->get_state($context); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | * @param string $context View or edit context. |
1041 | 1041 | * @return int |
1042 | 1042 | */ |
1043 | - public function get_customer_state( $context = 'view' ) { |
|
1044 | - return $this->get_state( $context ); |
|
1043 | + public function get_customer_state($context = 'view') { |
|
1044 | + return $this->get_state($context); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * @param string $context View or edit context. |
1052 | 1052 | * @return string |
1053 | 1053 | */ |
1054 | - public function get_city( $context = 'view' ) { |
|
1055 | - return $this->get_prop( 'city', $context ); |
|
1054 | + public function get_city($context = 'view') { |
|
1055 | + return $this->get_prop('city', $context); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1062,8 +1062,8 @@ discard block |
||
1062 | 1062 | * @param string $context View or edit context. |
1063 | 1063 | * @return string |
1064 | 1064 | */ |
1065 | - public function get_user_city( $context = 'view' ) { |
|
1066 | - return $this->get_city( $context ); |
|
1065 | + public function get_user_city($context = 'view') { |
|
1066 | + return $this->get_city($context); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | /** |
@@ -1073,8 +1073,8 @@ discard block |
||
1073 | 1073 | * @param string $context View or edit context. |
1074 | 1074 | * @return string |
1075 | 1075 | */ |
1076 | - public function get_customer_city( $context = 'view' ) { |
|
1077 | - return $this->get_city( $context ); |
|
1076 | + public function get_customer_city($context = 'view') { |
|
1077 | + return $this->get_city($context); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | /** |
@@ -1084,8 +1084,8 @@ discard block |
||
1084 | 1084 | * @param string $context View or edit context. |
1085 | 1085 | * @return string |
1086 | 1086 | */ |
1087 | - public function get_zip( $context = 'view' ) { |
|
1088 | - return $this->get_prop( 'zip', $context ); |
|
1087 | + public function get_zip($context = 'view') { |
|
1088 | + return $this->get_prop('zip', $context); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | /** |
@@ -1095,8 +1095,8 @@ discard block |
||
1095 | 1095 | * @param string $context View or edit context. |
1096 | 1096 | * @return string |
1097 | 1097 | */ |
1098 | - public function get_user_zip( $context = 'view' ) { |
|
1099 | - return $this->get_zip( $context ); |
|
1098 | + public function get_user_zip($context = 'view') { |
|
1099 | + return $this->get_zip($context); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1106,8 +1106,8 @@ discard block |
||
1106 | 1106 | * @param string $context View or edit context. |
1107 | 1107 | * @return string |
1108 | 1108 | */ |
1109 | - public function get_customer_zip( $context = 'view' ) { |
|
1110 | - return $this->get_zip( $context ); |
|
1109 | + public function get_customer_zip($context = 'view') { |
|
1110 | + return $this->get_zip($context); |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | /** |
@@ -1117,8 +1117,8 @@ discard block |
||
1117 | 1117 | * @param string $context View or edit context. |
1118 | 1118 | * @return string |
1119 | 1119 | */ |
1120 | - public function get_company( $context = 'view' ) { |
|
1121 | - return $this->get_prop( 'company', $context ); |
|
1120 | + public function get_company($context = 'view') { |
|
1121 | + return $this->get_prop('company', $context); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | /** |
@@ -1128,8 +1128,8 @@ discard block |
||
1128 | 1128 | * @param string $context View or edit context. |
1129 | 1129 | * @return string |
1130 | 1130 | */ |
1131 | - public function get_user_company( $context = 'view' ) { |
|
1132 | - return $this->get_company( $context ); |
|
1131 | + public function get_user_company($context = 'view') { |
|
1132 | + return $this->get_company($context); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | /** |
@@ -1139,8 +1139,8 @@ discard block |
||
1139 | 1139 | * @param string $context View or edit context. |
1140 | 1140 | * @return string |
1141 | 1141 | */ |
1142 | - public function get_customer_company( $context = 'view' ) { |
|
1143 | - return $this->get_company( $context ); |
|
1142 | + public function get_customer_company($context = 'view') { |
|
1143 | + return $this->get_company($context); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | /** |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | * @param string $context View or edit context. |
1151 | 1151 | * @return string |
1152 | 1152 | */ |
1153 | - public function get_vat_number( $context = 'view' ) { |
|
1154 | - return $this->get_prop( 'vat_number', $context ); |
|
1153 | + public function get_vat_number($context = 'view') { |
|
1154 | + return $this->get_prop('vat_number', $context); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | /** |
@@ -1161,8 +1161,8 @@ discard block |
||
1161 | 1161 | * @param string $context View or edit context. |
1162 | 1162 | * @return string |
1163 | 1163 | */ |
1164 | - public function get_user_vat_number( $context = 'view' ) { |
|
1165 | - return $this->get_vat_number( $context ); |
|
1164 | + public function get_user_vat_number($context = 'view') { |
|
1165 | + return $this->get_vat_number($context); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | /** |
@@ -1172,8 +1172,8 @@ discard block |
||
1172 | 1172 | * @param string $context View or edit context. |
1173 | 1173 | * @return string |
1174 | 1174 | */ |
1175 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1176 | - return $this->get_vat_number( $context ); |
|
1175 | + public function get_customer_vat_number($context = 'view') { |
|
1176 | + return $this->get_vat_number($context); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | /** |
@@ -1183,8 +1183,8 @@ discard block |
||
1183 | 1183 | * @param string $context View or edit context. |
1184 | 1184 | * @return string |
1185 | 1185 | */ |
1186 | - public function get_vat_rate( $context = 'view' ) { |
|
1187 | - return $this->get_prop( 'vat_rate', $context ); |
|
1186 | + public function get_vat_rate($context = 'view') { |
|
1187 | + return $this->get_prop('vat_rate', $context); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | /** |
@@ -1194,8 +1194,8 @@ discard block |
||
1194 | 1194 | * @param string $context View or edit context. |
1195 | 1195 | * @return string |
1196 | 1196 | */ |
1197 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1198 | - return $this->get_vat_rate( $context ); |
|
1197 | + public function get_user_vat_rate($context = 'view') { |
|
1198 | + return $this->get_vat_rate($context); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | /** |
@@ -1205,8 +1205,8 @@ discard block |
||
1205 | 1205 | * @param string $context View or edit context. |
1206 | 1206 | * @return string |
1207 | 1207 | */ |
1208 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1209 | - return $this->get_vat_rate( $context ); |
|
1208 | + public function get_customer_vat_rate($context = 'view') { |
|
1209 | + return $this->get_vat_rate($context); |
|
1210 | 1210 | } |
1211 | 1211 | |
1212 | 1212 | /** |
@@ -1216,8 +1216,8 @@ discard block |
||
1216 | 1216 | * @param string $context View or edit context. |
1217 | 1217 | * @return string |
1218 | 1218 | */ |
1219 | - public function get_address( $context = 'view' ) { |
|
1220 | - return $this->get_prop( 'address', $context ); |
|
1219 | + public function get_address($context = 'view') { |
|
1220 | + return $this->get_prop('address', $context); |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | /** |
@@ -1227,8 +1227,8 @@ discard block |
||
1227 | 1227 | * @param string $context View or edit context. |
1228 | 1228 | * @return string |
1229 | 1229 | */ |
1230 | - public function get_user_address( $context = 'view' ) { |
|
1231 | - return $this->get_address( $context ); |
|
1230 | + public function get_user_address($context = 'view') { |
|
1231 | + return $this->get_address($context); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | /** |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | * @param string $context View or edit context. |
1239 | 1239 | * @return string |
1240 | 1240 | */ |
1241 | - public function get_customer_address( $context = 'view' ) { |
|
1242 | - return $this->get_address( $context ); |
|
1241 | + public function get_customer_address($context = 'view') { |
|
1242 | + return $this->get_address($context); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | /** |
@@ -1249,8 +1249,8 @@ discard block |
||
1249 | 1249 | * @param string $context View or edit context. |
1250 | 1250 | * @return bool |
1251 | 1251 | */ |
1252 | - public function get_is_viewed( $context = 'view' ) { |
|
1253 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1252 | + public function get_is_viewed($context = 'view') { |
|
1253 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | /** |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | * @param string $context View or edit context. |
1261 | 1261 | * @return bool |
1262 | 1262 | */ |
1263 | - public function get_email_cc( $context = 'view' ) { |
|
1264 | - return $this->get_prop( 'email_cc', $context ); |
|
1263 | + public function get_email_cc($context = 'view') { |
|
1264 | + return $this->get_prop('email_cc', $context); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1271,8 +1271,8 @@ discard block |
||
1271 | 1271 | * @param string $context View or edit context. |
1272 | 1272 | * @return bool |
1273 | 1273 | */ |
1274 | - public function get_template( $context = 'view' ) { |
|
1275 | - return $this->get_prop( 'template', $context ); |
|
1274 | + public function get_template($context = 'view') { |
|
1275 | + return $this->get_prop('template', $context); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | /** |
@@ -1282,8 +1282,8 @@ discard block |
||
1282 | 1282 | * @param string $context View or edit context. |
1283 | 1283 | * @return bool |
1284 | 1284 | */ |
1285 | - public function get_created_via( $context = 'view' ) { |
|
1286 | - return $this->get_prop( 'created_via', $context ); |
|
1285 | + public function get_created_via($context = 'view') { |
|
1286 | + return $this->get_prop('created_via', $context); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | /** |
@@ -1293,8 +1293,8 @@ discard block |
||
1293 | 1293 | * @param string $context View or edit context. |
1294 | 1294 | * @return bool |
1295 | 1295 | */ |
1296 | - public function get_address_confirmed( $context = 'view' ) { |
|
1297 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1296 | + public function get_address_confirmed($context = 'view') { |
|
1297 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | /** |
@@ -1304,8 +1304,8 @@ discard block |
||
1304 | 1304 | * @param string $context View or edit context. |
1305 | 1305 | * @return bool |
1306 | 1306 | */ |
1307 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1308 | - return $this->get_address_confirmed( $context ); |
|
1307 | + public function get_user_address_confirmed($context = 'view') { |
|
1308 | + return $this->get_address_confirmed($context); |
|
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | /** |
@@ -1315,8 +1315,8 @@ discard block |
||
1315 | 1315 | * @param string $context View or edit context. |
1316 | 1316 | * @return bool |
1317 | 1317 | */ |
1318 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1319 | - return $this->get_address_confirmed( $context ); |
|
1318 | + public function get_customer_address_confirmed($context = 'view') { |
|
1319 | + return $this->get_address_confirmed($context); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | /** |
@@ -1326,12 +1326,12 @@ discard block |
||
1326 | 1326 | * @param string $context View or edit context. |
1327 | 1327 | * @return float |
1328 | 1328 | */ |
1329 | - public function get_subtotal( $context = 'view' ) { |
|
1330 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1329 | + public function get_subtotal($context = 'view') { |
|
1330 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1331 | 1331 | |
1332 | 1332 | // Backwards compatibility. |
1333 | - if ( is_bool( $context ) && $context ) { |
|
1334 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1333 | + if (is_bool($context) && $context) { |
|
1334 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | return $subtotal; |
@@ -1344,8 +1344,8 @@ discard block |
||
1344 | 1344 | * @param string $context View or edit context. |
1345 | 1345 | * @return float |
1346 | 1346 | */ |
1347 | - public function get_total_discount( $context = 'view' ) { |
|
1348 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1347 | + public function get_total_discount($context = 'view') { |
|
1348 | + return (float) $this->get_prop('total_discount', $context); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | /** |
@@ -1355,18 +1355,18 @@ discard block |
||
1355 | 1355 | * @param string $context View or edit context. |
1356 | 1356 | * @return float |
1357 | 1357 | */ |
1358 | - public function get_total_tax( $context = 'view' ) { |
|
1359 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1358 | + public function get_total_tax($context = 'view') { |
|
1359 | + return (float) $this->get_prop('total_tax', $context); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
1363 | 1363 | * @deprecated |
1364 | 1364 | */ |
1365 | - public function get_final_tax( $currency = false ) { |
|
1365 | + public function get_final_tax($currency = false) { |
|
1366 | 1366 | $tax = $this->get_total_tax(); |
1367 | 1367 | |
1368 | - if ( $currency ) { |
|
1369 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1368 | + if ($currency) { |
|
1369 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | return $tax; |
@@ -1379,8 +1379,8 @@ discard block |
||
1379 | 1379 | * @param string $context View or edit context. |
1380 | 1380 | * @return float |
1381 | 1381 | */ |
1382 | - public function get_total_fees( $context = 'view' ) { |
|
1383 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1382 | + public function get_total_fees($context = 'view') { |
|
1383 | + return (float) $this->get_prop('total_fees', $context); |
|
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | /** |
@@ -1390,8 +1390,8 @@ discard block |
||
1390 | 1390 | * @param string $context View or edit context. |
1391 | 1391 | * @return float |
1392 | 1392 | */ |
1393 | - public function get_fees_total( $context = 'view' ) { |
|
1394 | - return $this->get_total_fees( $context ); |
|
1393 | + public function get_fees_total($context = 'view') { |
|
1394 | + return $this->get_total_fees($context); |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | /** |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | */ |
1403 | 1403 | public function get_total() { |
1404 | 1404 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1405 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1405 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | /** |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | */ |
1425 | 1425 | public function get_initial_total() { |
1426 | 1426 | |
1427 | - if ( empty( $this->totals ) ) { |
|
1427 | + if (empty($this->totals)) { |
|
1428 | 1428 | $this->recalculate_total(); |
1429 | 1429 | } |
1430 | 1430 | |
@@ -1434,11 +1434,11 @@ discard block |
||
1434 | 1434 | $subtotal = $this->totals['subtotal']['initial']; |
1435 | 1435 | $total = $tax + $fee - $discount + $subtotal; |
1436 | 1436 | |
1437 | - if ( 0 > $total ) { |
|
1437 | + if (0 > $total) { |
|
1438 | 1438 | $total = 0; |
1439 | 1439 | } |
1440 | 1440 | |
1441 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1441 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | */ |
1451 | 1451 | public function get_recurring_total() { |
1452 | 1452 | |
1453 | - if ( empty( $this->totals ) ) { |
|
1453 | + if (empty($this->totals)) { |
|
1454 | 1454 | $this->recalculate_total(); |
1455 | 1455 | } |
1456 | 1456 | |
@@ -1460,11 +1460,11 @@ discard block |
||
1460 | 1460 | $subtotal = $this->totals['subtotal']['recurring']; |
1461 | 1461 | $total = $tax + $fee - $discount + $subtotal; |
1462 | 1462 | |
1463 | - if ( 0 > $total ) { |
|
1463 | + if (0 > $total) { |
|
1464 | 1464 | $total = 0; |
1465 | 1465 | } |
1466 | 1466 | |
1467 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1467 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | /** |
@@ -1475,10 +1475,10 @@ discard block |
||
1475 | 1475 | * @param string $currency Whether to include the currency. |
1476 | 1476 | * @return float |
1477 | 1477 | */ |
1478 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1478 | + public function get_recurring_details($field = '', $currency = false) { |
|
1479 | 1479 | |
1480 | 1480 | // Maybe recalculate totals. |
1481 | - if ( empty( $this->totals ) ) { |
|
1481 | + if (empty($this->totals)) { |
|
1482 | 1482 | $this->recalculate_total(); |
1483 | 1483 | } |
1484 | 1484 | |
@@ -1498,8 +1498,8 @@ discard block |
||
1498 | 1498 | $currency |
1499 | 1499 | ); |
1500 | 1500 | |
1501 | - if ( isset( $data[$field] ) ) { |
|
1502 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1501 | + if (isset($data[$field])) { |
|
1502 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | return $data; |
@@ -1512,8 +1512,8 @@ discard block |
||
1512 | 1512 | * @param string $context View or edit context. |
1513 | 1513 | * @return array |
1514 | 1514 | */ |
1515 | - public function get_fees( $context = 'view' ) { |
|
1516 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1515 | + public function get_fees($context = 'view') { |
|
1516 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | /** |
@@ -1523,8 +1523,8 @@ discard block |
||
1523 | 1523 | * @param string $context View or edit context. |
1524 | 1524 | * @return array |
1525 | 1525 | */ |
1526 | - public function get_discounts( $context = 'view' ) { |
|
1527 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1526 | + public function get_discounts($context = 'view') { |
|
1527 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | /** |
@@ -1534,8 +1534,8 @@ discard block |
||
1534 | 1534 | * @param string $context View or edit context. |
1535 | 1535 | * @return array |
1536 | 1536 | */ |
1537 | - public function get_taxes( $context = 'view' ) { |
|
1538 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1537 | + public function get_taxes($context = 'view') { |
|
1538 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | /** |
@@ -1545,8 +1545,8 @@ discard block |
||
1545 | 1545 | * @param string $context View or edit context. |
1546 | 1546 | * @return GetPaid_Form_Item[] |
1547 | 1547 | */ |
1548 | - public function get_items( $context = 'view' ) { |
|
1549 | - return $this->get_prop( 'items', $context ); |
|
1548 | + public function get_items($context = 'view') { |
|
1549 | + return $this->get_prop('items', $context); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | /** |
@@ -1556,8 +1556,8 @@ discard block |
||
1556 | 1556 | * @param string $context View or edit context. |
1557 | 1557 | * @return int |
1558 | 1558 | */ |
1559 | - public function get_payment_form( $context = 'view' ) { |
|
1560 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1559 | + public function get_payment_form($context = 'view') { |
|
1560 | + return intval($this->get_prop('payment_form', $context)); |
|
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | /** |
@@ -1567,8 +1567,8 @@ discard block |
||
1567 | 1567 | * @param string $context View or edit context. |
1568 | 1568 | * @return string |
1569 | 1569 | */ |
1570 | - public function get_submission_id( $context = 'view' ) { |
|
1571 | - return $this->get_prop( 'submission_id', $context ); |
|
1570 | + public function get_submission_id($context = 'view') { |
|
1571 | + return $this->get_prop('submission_id', $context); |
|
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | /** |
@@ -1578,8 +1578,8 @@ discard block |
||
1578 | 1578 | * @param string $context View or edit context. |
1579 | 1579 | * @return string |
1580 | 1580 | */ |
1581 | - public function get_discount_code( $context = 'view' ) { |
|
1582 | - return $this->get_prop( 'discount_code', $context ); |
|
1581 | + public function get_discount_code($context = 'view') { |
|
1582 | + return $this->get_prop('discount_code', $context); |
|
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | /** |
@@ -1589,8 +1589,8 @@ discard block |
||
1589 | 1589 | * @param string $context View or edit context. |
1590 | 1590 | * @return string |
1591 | 1591 | */ |
1592 | - public function get_gateway( $context = 'view' ) { |
|
1593 | - return $this->get_prop( 'gateway', $context ); |
|
1592 | + public function get_gateway($context = 'view') { |
|
1593 | + return $this->get_prop('gateway', $context); |
|
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | /** |
@@ -1600,8 +1600,8 @@ discard block |
||
1600 | 1600 | * @return string |
1601 | 1601 | */ |
1602 | 1602 | public function get_gateway_title() { |
1603 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1604 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1603 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1604 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | /** |
@@ -1611,8 +1611,8 @@ discard block |
||
1611 | 1611 | * @param string $context View or edit context. |
1612 | 1612 | * @return string |
1613 | 1613 | */ |
1614 | - public function get_transaction_id( $context = 'view' ) { |
|
1615 | - return $this->get_prop( 'transaction_id', $context ); |
|
1614 | + public function get_transaction_id($context = 'view') { |
|
1615 | + return $this->get_prop('transaction_id', $context); |
|
1616 | 1616 | } |
1617 | 1617 | |
1618 | 1618 | /** |
@@ -1622,9 +1622,9 @@ discard block |
||
1622 | 1622 | * @param string $context View or edit context. |
1623 | 1623 | * @return string |
1624 | 1624 | */ |
1625 | - public function get_currency( $context = 'view' ) { |
|
1626 | - $currency = $this->get_prop( 'currency', $context ); |
|
1627 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1625 | + public function get_currency($context = 'view') { |
|
1626 | + $currency = $this->get_prop('currency', $context); |
|
1627 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | /** |
@@ -1634,8 +1634,8 @@ discard block |
||
1634 | 1634 | * @param string $context View or edit context. |
1635 | 1635 | * @return bool |
1636 | 1636 | */ |
1637 | - public function get_disable_taxes( $context = 'view' ) { |
|
1638 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1637 | + public function get_disable_taxes($context = 'view') { |
|
1638 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | /** |
@@ -1645,8 +1645,8 @@ discard block |
||
1645 | 1645 | * @param string $context View or edit context. |
1646 | 1646 | * @return int |
1647 | 1647 | */ |
1648 | - public function get_subscription_id( $context = 'view' ) { |
|
1649 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1648 | + public function get_subscription_id($context = 'view') { |
|
1649 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | /** |
@@ -1656,12 +1656,12 @@ discard block |
||
1656 | 1656 | * @param string $context View or edit context. |
1657 | 1657 | * @return int |
1658 | 1658 | */ |
1659 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1660 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1659 | + public function get_remote_subscription_id($context = 'view') { |
|
1660 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1661 | 1661 | |
1662 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1662 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1663 | 1663 | $parent = $this->get_parent(); |
1664 | - return $parent->get_subscription_id( $context ); |
|
1664 | + return $parent->get_subscription_id($context); |
|
1665 | 1665 | } |
1666 | 1666 | |
1667 | 1667 | return $subscription_id; |
@@ -1674,20 +1674,20 @@ discard block |
||
1674 | 1674 | * @param string $context View or edit context. |
1675 | 1675 | * @return array |
1676 | 1676 | */ |
1677 | - public function get_payment_meta( $context = 'view' ) { |
|
1677 | + public function get_payment_meta($context = 'view') { |
|
1678 | 1678 | |
1679 | 1679 | return array( |
1680 | - 'price' => $this->get_total( $context ), |
|
1681 | - 'date' => $this->get_date_created( $context ), |
|
1682 | - 'user_email' => $this->get_email( $context ), |
|
1683 | - 'invoice_key' => $this->get_key( $context ), |
|
1684 | - 'currency' => $this->get_currency( $context ), |
|
1685 | - 'items' => $this->get_items( $context ), |
|
1686 | - 'user_info' => $this->get_user_info( $context ), |
|
1680 | + 'price' => $this->get_total($context), |
|
1681 | + 'date' => $this->get_date_created($context), |
|
1682 | + 'user_email' => $this->get_email($context), |
|
1683 | + 'invoice_key' => $this->get_key($context), |
|
1684 | + 'currency' => $this->get_currency($context), |
|
1685 | + 'items' => $this->get_items($context), |
|
1686 | + 'user_info' => $this->get_user_info($context), |
|
1687 | 1687 | 'cart_details' => $this->get_cart_details(), |
1688 | - 'status' => $this->get_status( $context ), |
|
1689 | - 'fees' => $this->get_fees( $context ), |
|
1690 | - 'taxes' => $this->get_taxes( $context ), |
|
1688 | + 'status' => $this->get_status($context), |
|
1689 | + 'fees' => $this->get_fees($context), |
|
1690 | + 'taxes' => $this->get_taxes($context), |
|
1691 | 1691 | ); |
1692 | 1692 | |
1693 | 1693 | } |
@@ -1702,9 +1702,9 @@ discard block |
||
1702 | 1702 | $items = $this->get_items(); |
1703 | 1703 | $cart_details = array(); |
1704 | 1704 | |
1705 | - foreach ( $items as $item_id => $item ) { |
|
1705 | + foreach ($items as $item_id => $item) { |
|
1706 | 1706 | $item->invoice_id = $this->get_id(); |
1707 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1707 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | return $cart_details; |
@@ -1715,11 +1715,11 @@ discard block |
||
1715 | 1715 | * |
1716 | 1716 | * @return null|GetPaid_Form_Item|int |
1717 | 1717 | */ |
1718 | - public function get_recurring( $object = false ) { |
|
1718 | + public function get_recurring($object = false) { |
|
1719 | 1719 | |
1720 | 1720 | // Are we returning an object? |
1721 | - if ( $object ) { |
|
1722 | - return $this->get_item( $this->recurring_item ); |
|
1721 | + if ($object) { |
|
1722 | + return $this->get_item($this->recurring_item); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | return $this->recurring_item; |
@@ -1734,15 +1734,15 @@ discard block |
||
1734 | 1734 | public function get_subscription_name() { |
1735 | 1735 | |
1736 | 1736 | // Retrieve the recurring name |
1737 | - $item = $this->get_recurring( true ); |
|
1737 | + $item = $this->get_recurring(true); |
|
1738 | 1738 | |
1739 | 1739 | // Abort if it does not exist. |
1740 | - if ( empty( $item ) ) { |
|
1740 | + if (empty($item)) { |
|
1741 | 1741 | return ''; |
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | // Return the item name. |
1745 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1745 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1746 | 1746 | } |
1747 | 1747 | |
1748 | 1748 | /** |
@@ -1752,9 +1752,9 @@ discard block |
||
1752 | 1752 | * @return string |
1753 | 1753 | */ |
1754 | 1754 | public function get_view_url() { |
1755 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1756 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1757 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1755 | + $invoice_url = get_permalink($this->get_id()); |
|
1756 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1757 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1758 | 1758 | } |
1759 | 1759 | |
1760 | 1760 | /** |
@@ -1763,25 +1763,25 @@ discard block |
||
1763 | 1763 | * @since 1.0.19 |
1764 | 1764 | * @return string |
1765 | 1765 | */ |
1766 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1766 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1767 | 1767 | |
1768 | 1768 | // Retrieve the checkout url. |
1769 | 1769 | $pay_url = wpinv_get_checkout_uri(); |
1770 | 1770 | |
1771 | 1771 | // Maybe force ssl. |
1772 | - if ( is_ssl() ) { |
|
1773 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1772 | + if (is_ssl()) { |
|
1773 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | // Add the invoice key. |
1777 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1777 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1778 | 1778 | |
1779 | 1779 | // (Maybe?) add a secret |
1780 | - if ( $secret ) { |
|
1781 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1780 | + if ($secret) { |
|
1781 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1784 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | /** |
@@ -1796,14 +1796,14 @@ discard block |
||
1796 | 1796 | $receipt_url = wpinv_get_success_page_uri(); |
1797 | 1797 | |
1798 | 1798 | // Maybe force ssl. |
1799 | - if ( is_ssl() ) { |
|
1800 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1799 | + if (is_ssl()) { |
|
1800 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1801 | 1801 | } |
1802 | 1802 | |
1803 | 1803 | // Add the invoice key. |
1804 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1804 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1805 | 1805 | |
1806 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1806 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1807 | 1807 | } |
1808 | 1808 | |
1809 | 1809 | /** |
@@ -1816,7 +1816,7 @@ discard block |
||
1816 | 1816 | |
1817 | 1817 | $type = $this->get_type(); |
1818 | 1818 | $status = "wpi-$type-pending"; |
1819 | - return str_replace( '-invoice', '', $status ); |
|
1819 | + return str_replace('-invoice', '', $status); |
|
1820 | 1820 | |
1821 | 1821 | } |
1822 | 1822 | |
@@ -1830,8 +1830,8 @@ discard block |
||
1830 | 1830 | * @param string $context View or edit context. |
1831 | 1831 | * @return mixed Value of the given invoice property (if set). |
1832 | 1832 | */ |
1833 | - public function get( $key, $context = 'view' ) { |
|
1834 | - return $this->get_prop( $key, $context ); |
|
1833 | + public function get($key, $context = 'view') { |
|
1834 | + return $this->get_prop($key, $context); |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | /* |
@@ -1854,11 +1854,11 @@ discard block |
||
1854 | 1854 | * @param mixed $value new value. |
1855 | 1855 | * @return mixed Value of the given invoice property (if set). |
1856 | 1856 | */ |
1857 | - public function set( $key, $value ) { |
|
1857 | + public function set($key, $value) { |
|
1858 | 1858 | |
1859 | 1859 | $setter = "set_$key"; |
1860 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1861 | - $this->{$setter}( $value ); |
|
1860 | + if (is_callable(array($this, $setter))) { |
|
1861 | + $this->{$setter}($value); |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | } |
@@ -1872,47 +1872,47 @@ discard block |
||
1872 | 1872 | * @param bool $manual_update Is this a manual status change?. |
1873 | 1873 | * @return array details of change. |
1874 | 1874 | */ |
1875 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1875 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1876 | 1876 | $old_status = $this->get_status(); |
1877 | 1877 | |
1878 | 1878 | $statuses = $this->get_all_statuses(); |
1879 | 1879 | |
1880 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1881 | - unset( $statuses[ 'draft' ] ); |
|
1880 | + if (isset($statuses['draft'])) { |
|
1881 | + unset($statuses['draft']); |
|
1882 | 1882 | } |
1883 | 1883 | |
1884 | - $this->set_prop( 'status', $new_status ); |
|
1884 | + $this->set_prop('status', $new_status); |
|
1885 | 1885 | |
1886 | 1886 | // If setting the status, ensure it's set to a valid status. |
1887 | - if ( true === $this->object_read ) { |
|
1887 | + if (true === $this->object_read) { |
|
1888 | 1888 | |
1889 | 1889 | // Only allow valid new status. |
1890 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1890 | + if (!array_key_exists($new_status, $statuses)) { |
|
1891 | 1891 | $new_status = $this->get_default_status(); |
1892 | 1892 | } |
1893 | 1893 | |
1894 | 1894 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1895 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1895 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1896 | 1896 | $old_status = $this->get_default_status(); |
1897 | 1897 | } |
1898 | 1898 | |
1899 | 1899 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1900 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1900 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1901 | 1901 | $old_status = 'wpi-pending'; |
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | } |
1905 | 1905 | |
1906 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1906 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1907 | 1907 | $this->status_transition = array( |
1908 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1908 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1909 | 1909 | 'to' => $new_status, |
1910 | 1910 | 'note' => $note, |
1911 | 1911 | 'manual' => (bool) $manual_update, |
1912 | 1912 | ); |
1913 | 1913 | |
1914 | - if ( $manual_update ) { |
|
1915 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1914 | + if ($manual_update) { |
|
1915 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | $this->maybe_set_date_paid(); |
@@ -1935,8 +1935,8 @@ discard block |
||
1935 | 1935 | */ |
1936 | 1936 | public function maybe_set_date_paid() { |
1937 | 1937 | |
1938 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1939 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1938 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1939 | + $this->set_date_completed(current_time('mysql')); |
|
1940 | 1940 | } |
1941 | 1941 | } |
1942 | 1942 | |
@@ -1945,11 +1945,11 @@ discard block |
||
1945 | 1945 | * |
1946 | 1946 | * @since 1.0.19 |
1947 | 1947 | */ |
1948 | - public function set_parent_id( $value ) { |
|
1949 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1948 | + public function set_parent_id($value) { |
|
1949 | + if ($value && ($value === $this->get_id())) { |
|
1950 | 1950 | return; |
1951 | 1951 | } |
1952 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1952 | + $this->set_prop('parent_id', absint($value)); |
|
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | /** |
@@ -1957,8 +1957,8 @@ discard block |
||
1957 | 1957 | * |
1958 | 1958 | * @since 1.0.19 |
1959 | 1959 | */ |
1960 | - public function set_version( $value ) { |
|
1961 | - $this->set_prop( 'version', $value ); |
|
1960 | + public function set_version($value) { |
|
1961 | + $this->set_prop('version', $value); |
|
1962 | 1962 | } |
1963 | 1963 | |
1964 | 1964 | /** |
@@ -1968,15 +1968,15 @@ discard block |
||
1968 | 1968 | * @param string $value Value to set. |
1969 | 1969 | * @return bool Whether or not the date was set. |
1970 | 1970 | */ |
1971 | - public function set_date_created( $value ) { |
|
1972 | - $date = strtotime( $value ); |
|
1971 | + public function set_date_created($value) { |
|
1972 | + $date = strtotime($value); |
|
1973 | 1973 | |
1974 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1975 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1974 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1975 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1976 | 1976 | return true; |
1977 | 1977 | } |
1978 | 1978 | |
1979 | - return $this->set_prop( 'date_created', '' ); |
|
1979 | + return $this->set_prop('date_created', ''); |
|
1980 | 1980 | |
1981 | 1981 | } |
1982 | 1982 | |
@@ -1987,15 +1987,15 @@ discard block |
||
1987 | 1987 | * @param string $value Value to set. |
1988 | 1988 | * @return bool Whether or not the date was set. |
1989 | 1989 | */ |
1990 | - public function set_due_date( $value ) { |
|
1991 | - $date = strtotime( $value ); |
|
1990 | + public function set_due_date($value) { |
|
1991 | + $date = strtotime($value); |
|
1992 | 1992 | |
1993 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1994 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1993 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1994 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
1995 | 1995 | return true; |
1996 | 1996 | } |
1997 | 1997 | |
1998 | - $this->set_prop( 'due_date', '' ); |
|
1998 | + $this->set_prop('due_date', ''); |
|
1999 | 1999 | return false; |
2000 | 2000 | |
2001 | 2001 | } |
@@ -2006,8 +2006,8 @@ discard block |
||
2006 | 2006 | * @since 1.0.19 |
2007 | 2007 | * @param string $value New name. |
2008 | 2008 | */ |
2009 | - public function set_date_due( $value ) { |
|
2010 | - $this->set_due_date( $value ); |
|
2009 | + public function set_date_due($value) { |
|
2010 | + $this->set_due_date($value); |
|
2011 | 2011 | } |
2012 | 2012 | |
2013 | 2013 | /** |
@@ -2017,15 +2017,15 @@ discard block |
||
2017 | 2017 | * @param string $value Value to set. |
2018 | 2018 | * @return bool Whether or not the date was set. |
2019 | 2019 | */ |
2020 | - public function set_completed_date( $value ) { |
|
2021 | - $date = strtotime( $value ); |
|
2020 | + public function set_completed_date($value) { |
|
2021 | + $date = strtotime($value); |
|
2022 | 2022 | |
2023 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2024 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2023 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2024 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2025 | 2025 | return true; |
2026 | 2026 | } |
2027 | 2027 | |
2028 | - $this->set_prop( 'completed_date', '' ); |
|
2028 | + $this->set_prop('completed_date', ''); |
|
2029 | 2029 | return false; |
2030 | 2030 | |
2031 | 2031 | } |
@@ -2036,8 +2036,8 @@ discard block |
||
2036 | 2036 | * @since 1.0.19 |
2037 | 2037 | * @param string $value New name. |
2038 | 2038 | */ |
2039 | - public function set_date_completed( $value ) { |
|
2040 | - $this->set_completed_date( $value ); |
|
2039 | + public function set_date_completed($value) { |
|
2040 | + $this->set_completed_date($value); |
|
2041 | 2041 | } |
2042 | 2042 | |
2043 | 2043 | /** |
@@ -2047,15 +2047,15 @@ discard block |
||
2047 | 2047 | * @param string $value Value to set. |
2048 | 2048 | * @return bool Whether or not the date was set. |
2049 | 2049 | */ |
2050 | - public function set_date_modified( $value ) { |
|
2051 | - $date = strtotime( $value ); |
|
2050 | + public function set_date_modified($value) { |
|
2051 | + $date = strtotime($value); |
|
2052 | 2052 | |
2053 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2054 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2053 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2054 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2055 | 2055 | return true; |
2056 | 2056 | } |
2057 | 2057 | |
2058 | - $this->set_prop( 'date_modified', '' ); |
|
2058 | + $this->set_prop('date_modified', ''); |
|
2059 | 2059 | return false; |
2060 | 2060 | |
2061 | 2061 | } |
@@ -2066,9 +2066,9 @@ discard block |
||
2066 | 2066 | * @since 1.0.19 |
2067 | 2067 | * @param string $value New number. |
2068 | 2068 | */ |
2069 | - public function set_number( $value ) { |
|
2070 | - $number = sanitize_text_field( $value ); |
|
2071 | - $this->set_prop( 'number', $number ); |
|
2069 | + public function set_number($value) { |
|
2070 | + $number = sanitize_text_field($value); |
|
2071 | + $this->set_prop('number', $number); |
|
2072 | 2072 | } |
2073 | 2073 | |
2074 | 2074 | /** |
@@ -2077,9 +2077,9 @@ discard block |
||
2077 | 2077 | * @since 1.0.19 |
2078 | 2078 | * @param string $value Type. |
2079 | 2079 | */ |
2080 | - public function set_type( $value ) { |
|
2081 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2082 | - $this->set_prop( 'type', $type ); |
|
2080 | + public function set_type($value) { |
|
2081 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2082 | + $this->set_prop('type', $type); |
|
2083 | 2083 | } |
2084 | 2084 | |
2085 | 2085 | /** |
@@ -2088,10 +2088,10 @@ discard block |
||
2088 | 2088 | * @since 1.0.19 |
2089 | 2089 | * @param string $value Post type. |
2090 | 2090 | */ |
2091 | - public function set_post_type( $value ) { |
|
2092 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2093 | - $this->set_type( $value ); |
|
2094 | - $this->set_prop( 'post_type', $value ); |
|
2091 | + public function set_post_type($value) { |
|
2092 | + if (getpaid_is_invoice_post_type($value)) { |
|
2093 | + $this->set_type($value); |
|
2094 | + $this->set_prop('post_type', $value); |
|
2095 | 2095 | } |
2096 | 2096 | } |
2097 | 2097 | |
@@ -2101,9 +2101,9 @@ discard block |
||
2101 | 2101 | * @since 1.0.19 |
2102 | 2102 | * @param string $value New key. |
2103 | 2103 | */ |
2104 | - public function set_key( $value ) { |
|
2105 | - $key = sanitize_text_field( $value ); |
|
2106 | - $this->set_prop( 'key', $key ); |
|
2104 | + public function set_key($value) { |
|
2105 | + $key = sanitize_text_field($value); |
|
2106 | + $this->set_prop('key', $key); |
|
2107 | 2107 | } |
2108 | 2108 | |
2109 | 2109 | /** |
@@ -2112,9 +2112,9 @@ discard block |
||
2112 | 2112 | * @since 1.0.19 |
2113 | 2113 | * @param string $value mode. |
2114 | 2114 | */ |
2115 | - public function set_mode( $value ) { |
|
2116 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2117 | - $this->set_prop( 'value', $value ); |
|
2115 | + public function set_mode($value) { |
|
2116 | + if (!in_array($value, array('live', 'test'))) { |
|
2117 | + $this->set_prop('value', $value); |
|
2118 | 2118 | } |
2119 | 2119 | } |
2120 | 2120 | |
@@ -2124,8 +2124,8 @@ discard block |
||
2124 | 2124 | * @since 1.0.19 |
2125 | 2125 | * @param string $value path. |
2126 | 2126 | */ |
2127 | - public function set_path( $value ) { |
|
2128 | - $this->set_prop( 'path', $value ); |
|
2127 | + public function set_path($value) { |
|
2128 | + $this->set_prop('path', $value); |
|
2129 | 2129 | } |
2130 | 2130 | |
2131 | 2131 | /** |
@@ -2134,9 +2134,9 @@ discard block |
||
2134 | 2134 | * @since 1.0.19 |
2135 | 2135 | * @param string $value New name. |
2136 | 2136 | */ |
2137 | - public function set_name( $value ) { |
|
2138 | - $name = sanitize_text_field( $value ); |
|
2139 | - $this->set_prop( 'name', $name ); |
|
2137 | + public function set_name($value) { |
|
2138 | + $name = sanitize_text_field($value); |
|
2139 | + $this->set_prop('name', $name); |
|
2140 | 2140 | } |
2141 | 2141 | |
2142 | 2142 | /** |
@@ -2145,8 +2145,8 @@ discard block |
||
2145 | 2145 | * @since 1.0.19 |
2146 | 2146 | * @param string $value New name. |
2147 | 2147 | */ |
2148 | - public function set_title( $value ) { |
|
2149 | - $this->set_name( $value ); |
|
2148 | + public function set_title($value) { |
|
2149 | + $this->set_name($value); |
|
2150 | 2150 | } |
2151 | 2151 | |
2152 | 2152 | /** |
@@ -2155,9 +2155,9 @@ discard block |
||
2155 | 2155 | * @since 1.0.19 |
2156 | 2156 | * @param string $value New description. |
2157 | 2157 | */ |
2158 | - public function set_description( $value ) { |
|
2159 | - $description = wp_kses_post( $value ); |
|
2160 | - return $this->set_prop( 'description', $description ); |
|
2158 | + public function set_description($value) { |
|
2159 | + $description = wp_kses_post($value); |
|
2160 | + return $this->set_prop('description', $description); |
|
2161 | 2161 | } |
2162 | 2162 | |
2163 | 2163 | /** |
@@ -2166,8 +2166,8 @@ discard block |
||
2166 | 2166 | * @since 1.0.19 |
2167 | 2167 | * @param string $value New description. |
2168 | 2168 | */ |
2169 | - public function set_excerpt( $value ) { |
|
2170 | - $this->set_description( $value ); |
|
2169 | + public function set_excerpt($value) { |
|
2170 | + $this->set_description($value); |
|
2171 | 2171 | } |
2172 | 2172 | |
2173 | 2173 | /** |
@@ -2176,8 +2176,8 @@ discard block |
||
2176 | 2176 | * @since 1.0.19 |
2177 | 2177 | * @param string $value New description. |
2178 | 2178 | */ |
2179 | - public function set_summary( $value ) { |
|
2180 | - $this->set_description( $value ); |
|
2179 | + public function set_summary($value) { |
|
2180 | + $this->set_description($value); |
|
2181 | 2181 | } |
2182 | 2182 | |
2183 | 2183 | /** |
@@ -2186,12 +2186,12 @@ discard block |
||
2186 | 2186 | * @since 1.0.19 |
2187 | 2187 | * @param int $value New author. |
2188 | 2188 | */ |
2189 | - public function set_author( $value ) { |
|
2190 | - $user = get_user_by( 'id', (int) $value ); |
|
2189 | + public function set_author($value) { |
|
2190 | + $user = get_user_by('id', (int) $value); |
|
2191 | 2191 | |
2192 | - if ( $user && $user->ID ) { |
|
2193 | - $this->set_prop( 'author', $user->ID ); |
|
2194 | - $this->set_prop( 'email', $user->user_email ); |
|
2192 | + if ($user && $user->ID) { |
|
2193 | + $this->set_prop('author', $user->ID); |
|
2194 | + $this->set_prop('email', $user->user_email); |
|
2195 | 2195 | } |
2196 | 2196 | |
2197 | 2197 | } |
@@ -2202,8 +2202,8 @@ discard block |
||
2202 | 2202 | * @since 1.0.19 |
2203 | 2203 | * @param int $value New user id. |
2204 | 2204 | */ |
2205 | - public function set_user_id( $value ) { |
|
2206 | - $this->set_author( $value ); |
|
2205 | + public function set_user_id($value) { |
|
2206 | + $this->set_author($value); |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | /** |
@@ -2212,8 +2212,8 @@ discard block |
||
2212 | 2212 | * @since 1.0.19 |
2213 | 2213 | * @param int $value New user id. |
2214 | 2214 | */ |
2215 | - public function set_customer_id( $value ) { |
|
2216 | - $this->set_author( $value ); |
|
2215 | + public function set_customer_id($value) { |
|
2216 | + $this->set_author($value); |
|
2217 | 2217 | } |
2218 | 2218 | |
2219 | 2219 | /** |
@@ -2222,8 +2222,8 @@ discard block |
||
2222 | 2222 | * @since 1.0.19 |
2223 | 2223 | * @param string $value ip address. |
2224 | 2224 | */ |
2225 | - public function set_ip( $value ) { |
|
2226 | - $this->set_prop( 'ip', $value ); |
|
2225 | + public function set_ip($value) { |
|
2226 | + $this->set_prop('ip', $value); |
|
2227 | 2227 | } |
2228 | 2228 | |
2229 | 2229 | /** |
@@ -2232,8 +2232,8 @@ discard block |
||
2232 | 2232 | * @since 1.0.19 |
2233 | 2233 | * @param string $value ip address. |
2234 | 2234 | */ |
2235 | - public function set_user_ip( $value ) { |
|
2236 | - $this->set_ip( $value ); |
|
2235 | + public function set_user_ip($value) { |
|
2236 | + $this->set_ip($value); |
|
2237 | 2237 | } |
2238 | 2238 | |
2239 | 2239 | /** |
@@ -2242,8 +2242,8 @@ discard block |
||
2242 | 2242 | * @since 1.0.19 |
2243 | 2243 | * @param string $value first name. |
2244 | 2244 | */ |
2245 | - public function set_first_name( $value ) { |
|
2246 | - $this->set_prop( 'first_name', $value ); |
|
2245 | + public function set_first_name($value) { |
|
2246 | + $this->set_prop('first_name', $value); |
|
2247 | 2247 | } |
2248 | 2248 | |
2249 | 2249 | /** |
@@ -2252,8 +2252,8 @@ discard block |
||
2252 | 2252 | * @since 1.0.19 |
2253 | 2253 | * @param string $value first name. |
2254 | 2254 | */ |
2255 | - public function set_user_first_name( $value ) { |
|
2256 | - $this->set_first_name( $value ); |
|
2255 | + public function set_user_first_name($value) { |
|
2256 | + $this->set_first_name($value); |
|
2257 | 2257 | } |
2258 | 2258 | |
2259 | 2259 | /** |
@@ -2262,8 +2262,8 @@ discard block |
||
2262 | 2262 | * @since 1.0.19 |
2263 | 2263 | * @param string $value first name. |
2264 | 2264 | */ |
2265 | - public function set_customer_first_name( $value ) { |
|
2266 | - $this->set_first_name( $value ); |
|
2265 | + public function set_customer_first_name($value) { |
|
2266 | + $this->set_first_name($value); |
|
2267 | 2267 | } |
2268 | 2268 | |
2269 | 2269 | /** |
@@ -2272,8 +2272,8 @@ discard block |
||
2272 | 2272 | * @since 1.0.19 |
2273 | 2273 | * @param string $value last name. |
2274 | 2274 | */ |
2275 | - public function set_last_name( $value ) { |
|
2276 | - $this->set_prop( 'last_name', $value ); |
|
2275 | + public function set_last_name($value) { |
|
2276 | + $this->set_prop('last_name', $value); |
|
2277 | 2277 | } |
2278 | 2278 | |
2279 | 2279 | /** |
@@ -2282,8 +2282,8 @@ discard block |
||
2282 | 2282 | * @since 1.0.19 |
2283 | 2283 | * @param string $value last name. |
2284 | 2284 | */ |
2285 | - public function set_user_last_name( $value ) { |
|
2286 | - $this->set_last_name( $value ); |
|
2285 | + public function set_user_last_name($value) { |
|
2286 | + $this->set_last_name($value); |
|
2287 | 2287 | } |
2288 | 2288 | |
2289 | 2289 | /** |
@@ -2292,8 +2292,8 @@ discard block |
||
2292 | 2292 | * @since 1.0.19 |
2293 | 2293 | * @param string $value last name. |
2294 | 2294 | */ |
2295 | - public function set_customer_last_name( $value ) { |
|
2296 | - $this->set_last_name( $value ); |
|
2295 | + public function set_customer_last_name($value) { |
|
2296 | + $this->set_last_name($value); |
|
2297 | 2297 | } |
2298 | 2298 | |
2299 | 2299 | /** |
@@ -2302,8 +2302,8 @@ discard block |
||
2302 | 2302 | * @since 1.0.19 |
2303 | 2303 | * @param string $value phone. |
2304 | 2304 | */ |
2305 | - public function set_phone( $value ) { |
|
2306 | - $this->set_prop( 'phone', $value ); |
|
2305 | + public function set_phone($value) { |
|
2306 | + $this->set_prop('phone', $value); |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | /** |
@@ -2312,8 +2312,8 @@ discard block |
||
2312 | 2312 | * @since 1.0.19 |
2313 | 2313 | * @param string $value phone. |
2314 | 2314 | */ |
2315 | - public function set_user_phone( $value ) { |
|
2316 | - $this->set_phone( $value ); |
|
2315 | + public function set_user_phone($value) { |
|
2316 | + $this->set_phone($value); |
|
2317 | 2317 | } |
2318 | 2318 | |
2319 | 2319 | /** |
@@ -2322,8 +2322,8 @@ discard block |
||
2322 | 2322 | * @since 1.0.19 |
2323 | 2323 | * @param string $value phone. |
2324 | 2324 | */ |
2325 | - public function set_customer_phone( $value ) { |
|
2326 | - $this->set_phone( $value ); |
|
2325 | + public function set_customer_phone($value) { |
|
2326 | + $this->set_phone($value); |
|
2327 | 2327 | } |
2328 | 2328 | |
2329 | 2329 | /** |
@@ -2332,8 +2332,8 @@ discard block |
||
2332 | 2332 | * @since 1.0.19 |
2333 | 2333 | * @param string $value phone. |
2334 | 2334 | */ |
2335 | - public function set_phone_number( $value ) { |
|
2336 | - $this->set_phone( $value ); |
|
2335 | + public function set_phone_number($value) { |
|
2336 | + $this->set_phone($value); |
|
2337 | 2337 | } |
2338 | 2338 | |
2339 | 2339 | /** |
@@ -2342,8 +2342,8 @@ discard block |
||
2342 | 2342 | * @since 1.0.19 |
2343 | 2343 | * @param string $value email address. |
2344 | 2344 | */ |
2345 | - public function set_email( $value ) { |
|
2346 | - $this->set_prop( 'email', $value ); |
|
2345 | + public function set_email($value) { |
|
2346 | + $this->set_prop('email', $value); |
|
2347 | 2347 | } |
2348 | 2348 | |
2349 | 2349 | /** |
@@ -2352,8 +2352,8 @@ discard block |
||
2352 | 2352 | * @since 1.0.19 |
2353 | 2353 | * @param string $value email address. |
2354 | 2354 | */ |
2355 | - public function set_user_email( $value ) { |
|
2356 | - $this->set_email( $value ); |
|
2355 | + public function set_user_email($value) { |
|
2356 | + $this->set_email($value); |
|
2357 | 2357 | } |
2358 | 2358 | |
2359 | 2359 | /** |
@@ -2362,8 +2362,8 @@ discard block |
||
2362 | 2362 | * @since 1.0.19 |
2363 | 2363 | * @param string $value email address. |
2364 | 2364 | */ |
2365 | - public function set_email_address( $value ) { |
|
2366 | - $this->set_email( $value ); |
|
2365 | + public function set_email_address($value) { |
|
2366 | + $this->set_email($value); |
|
2367 | 2367 | } |
2368 | 2368 | |
2369 | 2369 | /** |
@@ -2372,8 +2372,8 @@ discard block |
||
2372 | 2372 | * @since 1.0.19 |
2373 | 2373 | * @param string $value email address. |
2374 | 2374 | */ |
2375 | - public function set_customer_email( $value ) { |
|
2376 | - $this->set_email( $value ); |
|
2375 | + public function set_customer_email($value) { |
|
2376 | + $this->set_email($value); |
|
2377 | 2377 | } |
2378 | 2378 | |
2379 | 2379 | /** |
@@ -2382,8 +2382,8 @@ discard block |
||
2382 | 2382 | * @since 1.0.19 |
2383 | 2383 | * @param string $value country. |
2384 | 2384 | */ |
2385 | - public function set_country( $value ) { |
|
2386 | - $this->set_prop( 'country', $value ); |
|
2385 | + public function set_country($value) { |
|
2386 | + $this->set_prop('country', $value); |
|
2387 | 2387 | } |
2388 | 2388 | |
2389 | 2389 | /** |
@@ -2392,8 +2392,8 @@ discard block |
||
2392 | 2392 | * @since 1.0.19 |
2393 | 2393 | * @param string $value country. |
2394 | 2394 | */ |
2395 | - public function set_user_country( $value ) { |
|
2396 | - $this->set_country( $value ); |
|
2395 | + public function set_user_country($value) { |
|
2396 | + $this->set_country($value); |
|
2397 | 2397 | } |
2398 | 2398 | |
2399 | 2399 | /** |
@@ -2402,8 +2402,8 @@ discard block |
||
2402 | 2402 | * @since 1.0.19 |
2403 | 2403 | * @param string $value country. |
2404 | 2404 | */ |
2405 | - public function set_customer_country( $value ) { |
|
2406 | - $this->set_country( $value ); |
|
2405 | + public function set_customer_country($value) { |
|
2406 | + $this->set_country($value); |
|
2407 | 2407 | } |
2408 | 2408 | |
2409 | 2409 | /** |
@@ -2412,8 +2412,8 @@ discard block |
||
2412 | 2412 | * @since 1.0.19 |
2413 | 2413 | * @param string $value state. |
2414 | 2414 | */ |
2415 | - public function set_state( $value ) { |
|
2416 | - $this->set_prop( 'state', $value ); |
|
2415 | + public function set_state($value) { |
|
2416 | + $this->set_prop('state', $value); |
|
2417 | 2417 | } |
2418 | 2418 | |
2419 | 2419 | /** |
@@ -2422,8 +2422,8 @@ discard block |
||
2422 | 2422 | * @since 1.0.19 |
2423 | 2423 | * @param string $value state. |
2424 | 2424 | */ |
2425 | - public function set_user_state( $value ) { |
|
2426 | - $this->set_state( $value ); |
|
2425 | + public function set_user_state($value) { |
|
2426 | + $this->set_state($value); |
|
2427 | 2427 | } |
2428 | 2428 | |
2429 | 2429 | /** |
@@ -2432,8 +2432,8 @@ discard block |
||
2432 | 2432 | * @since 1.0.19 |
2433 | 2433 | * @param string $value state. |
2434 | 2434 | */ |
2435 | - public function set_customer_state( $value ) { |
|
2436 | - $this->set_state( $value ); |
|
2435 | + public function set_customer_state($value) { |
|
2436 | + $this->set_state($value); |
|
2437 | 2437 | } |
2438 | 2438 | |
2439 | 2439 | /** |
@@ -2442,8 +2442,8 @@ discard block |
||
2442 | 2442 | * @since 1.0.19 |
2443 | 2443 | * @param string $value city. |
2444 | 2444 | */ |
2445 | - public function set_city( $value ) { |
|
2446 | - $this->set_prop( 'city', $value ); |
|
2445 | + public function set_city($value) { |
|
2446 | + $this->set_prop('city', $value); |
|
2447 | 2447 | } |
2448 | 2448 | |
2449 | 2449 | /** |
@@ -2452,8 +2452,8 @@ discard block |
||
2452 | 2452 | * @since 1.0.19 |
2453 | 2453 | * @param string $value city. |
2454 | 2454 | */ |
2455 | - public function set_user_city( $value ) { |
|
2456 | - $this->set_city( $value ); |
|
2455 | + public function set_user_city($value) { |
|
2456 | + $this->set_city($value); |
|
2457 | 2457 | } |
2458 | 2458 | |
2459 | 2459 | /** |
@@ -2462,8 +2462,8 @@ discard block |
||
2462 | 2462 | * @since 1.0.19 |
2463 | 2463 | * @param string $value city. |
2464 | 2464 | */ |
2465 | - public function set_customer_city( $value ) { |
|
2466 | - $this->set_city( $value ); |
|
2465 | + public function set_customer_city($value) { |
|
2466 | + $this->set_city($value); |
|
2467 | 2467 | } |
2468 | 2468 | |
2469 | 2469 | /** |
@@ -2472,8 +2472,8 @@ discard block |
||
2472 | 2472 | * @since 1.0.19 |
2473 | 2473 | * @param string $value zip. |
2474 | 2474 | */ |
2475 | - public function set_zip( $value ) { |
|
2476 | - $this->set_prop( 'zip', $value ); |
|
2475 | + public function set_zip($value) { |
|
2476 | + $this->set_prop('zip', $value); |
|
2477 | 2477 | } |
2478 | 2478 | |
2479 | 2479 | /** |
@@ -2482,8 +2482,8 @@ discard block |
||
2482 | 2482 | * @since 1.0.19 |
2483 | 2483 | * @param string $value zip. |
2484 | 2484 | */ |
2485 | - public function set_user_zip( $value ) { |
|
2486 | - $this->set_zip( $value ); |
|
2485 | + public function set_user_zip($value) { |
|
2486 | + $this->set_zip($value); |
|
2487 | 2487 | } |
2488 | 2488 | |
2489 | 2489 | /** |
@@ -2492,8 +2492,8 @@ discard block |
||
2492 | 2492 | * @since 1.0.19 |
2493 | 2493 | * @param string $value zip. |
2494 | 2494 | */ |
2495 | - public function set_customer_zip( $value ) { |
|
2496 | - $this->set_zip( $value ); |
|
2495 | + public function set_customer_zip($value) { |
|
2496 | + $this->set_zip($value); |
|
2497 | 2497 | } |
2498 | 2498 | |
2499 | 2499 | /** |
@@ -2502,8 +2502,8 @@ discard block |
||
2502 | 2502 | * @since 1.0.19 |
2503 | 2503 | * @param string $value company. |
2504 | 2504 | */ |
2505 | - public function set_company( $value ) { |
|
2506 | - $this->set_prop( 'company', $value ); |
|
2505 | + public function set_company($value) { |
|
2506 | + $this->set_prop('company', $value); |
|
2507 | 2507 | } |
2508 | 2508 | |
2509 | 2509 | /** |
@@ -2512,8 +2512,8 @@ discard block |
||
2512 | 2512 | * @since 1.0.19 |
2513 | 2513 | * @param string $value company. |
2514 | 2514 | */ |
2515 | - public function set_user_company( $value ) { |
|
2516 | - $this->set_company( $value ); |
|
2515 | + public function set_user_company($value) { |
|
2516 | + $this->set_company($value); |
|
2517 | 2517 | } |
2518 | 2518 | |
2519 | 2519 | /** |
@@ -2522,8 +2522,8 @@ discard block |
||
2522 | 2522 | * @since 1.0.19 |
2523 | 2523 | * @param string $value company. |
2524 | 2524 | */ |
2525 | - public function set_customer_company( $value ) { |
|
2526 | - $this->set_company( $value ); |
|
2525 | + public function set_customer_company($value) { |
|
2526 | + $this->set_company($value); |
|
2527 | 2527 | } |
2528 | 2528 | |
2529 | 2529 | /** |
@@ -2532,8 +2532,8 @@ discard block |
||
2532 | 2532 | * @since 1.0.19 |
2533 | 2533 | * @param string $value var number. |
2534 | 2534 | */ |
2535 | - public function set_vat_number( $value ) { |
|
2536 | - $this->set_prop( 'vat_number', $value ); |
|
2535 | + public function set_vat_number($value) { |
|
2536 | + $this->set_prop('vat_number', $value); |
|
2537 | 2537 | } |
2538 | 2538 | |
2539 | 2539 | /** |
@@ -2542,8 +2542,8 @@ discard block |
||
2542 | 2542 | * @since 1.0.19 |
2543 | 2543 | * @param string $value var number. |
2544 | 2544 | */ |
2545 | - public function set_user_vat_number( $value ) { |
|
2546 | - $this->set_vat_number( $value ); |
|
2545 | + public function set_user_vat_number($value) { |
|
2546 | + $this->set_vat_number($value); |
|
2547 | 2547 | } |
2548 | 2548 | |
2549 | 2549 | /** |
@@ -2552,8 +2552,8 @@ discard block |
||
2552 | 2552 | * @since 1.0.19 |
2553 | 2553 | * @param string $value var number. |
2554 | 2554 | */ |
2555 | - public function set_customer_vat_number( $value ) { |
|
2556 | - $this->set_vat_number( $value ); |
|
2555 | + public function set_customer_vat_number($value) { |
|
2556 | + $this->set_vat_number($value); |
|
2557 | 2557 | } |
2558 | 2558 | |
2559 | 2559 | /** |
@@ -2562,8 +2562,8 @@ discard block |
||
2562 | 2562 | * @since 1.0.19 |
2563 | 2563 | * @param string $value var rate. |
2564 | 2564 | */ |
2565 | - public function set_vat_rate( $value ) { |
|
2566 | - $this->set_prop( 'vat_rate', $value ); |
|
2565 | + public function set_vat_rate($value) { |
|
2566 | + $this->set_prop('vat_rate', $value); |
|
2567 | 2567 | } |
2568 | 2568 | |
2569 | 2569 | /** |
@@ -2572,8 +2572,8 @@ discard block |
||
2572 | 2572 | * @since 1.0.19 |
2573 | 2573 | * @param string $value var number. |
2574 | 2574 | */ |
2575 | - public function set_user_vat_rate( $value ) { |
|
2576 | - $this->set_vat_rate( $value ); |
|
2575 | + public function set_user_vat_rate($value) { |
|
2576 | + $this->set_vat_rate($value); |
|
2577 | 2577 | } |
2578 | 2578 | |
2579 | 2579 | /** |
@@ -2582,8 +2582,8 @@ discard block |
||
2582 | 2582 | * @since 1.0.19 |
2583 | 2583 | * @param string $value var number. |
2584 | 2584 | */ |
2585 | - public function set_customer_vat_rate( $value ) { |
|
2586 | - $this->set_vat_rate( $value ); |
|
2585 | + public function set_customer_vat_rate($value) { |
|
2586 | + $this->set_vat_rate($value); |
|
2587 | 2587 | } |
2588 | 2588 | |
2589 | 2589 | /** |
@@ -2592,8 +2592,8 @@ discard block |
||
2592 | 2592 | * @since 1.0.19 |
2593 | 2593 | * @param string $value address. |
2594 | 2594 | */ |
2595 | - public function set_address( $value ) { |
|
2596 | - $this->set_prop( 'address', $value ); |
|
2595 | + public function set_address($value) { |
|
2596 | + $this->set_prop('address', $value); |
|
2597 | 2597 | } |
2598 | 2598 | |
2599 | 2599 | /** |
@@ -2602,8 +2602,8 @@ discard block |
||
2602 | 2602 | * @since 1.0.19 |
2603 | 2603 | * @param string $value address. |
2604 | 2604 | */ |
2605 | - public function set_user_address( $value ) { |
|
2606 | - $this->set_address( $value ); |
|
2605 | + public function set_user_address($value) { |
|
2606 | + $this->set_address($value); |
|
2607 | 2607 | } |
2608 | 2608 | |
2609 | 2609 | /** |
@@ -2612,8 +2612,8 @@ discard block |
||
2612 | 2612 | * @since 1.0.19 |
2613 | 2613 | * @param string $value address. |
2614 | 2614 | */ |
2615 | - public function set_customer_address( $value ) { |
|
2616 | - $this->set_address( $value ); |
|
2615 | + public function set_customer_address($value) { |
|
2616 | + $this->set_address($value); |
|
2617 | 2617 | } |
2618 | 2618 | |
2619 | 2619 | /** |
@@ -2622,8 +2622,8 @@ discard block |
||
2622 | 2622 | * @since 1.0.19 |
2623 | 2623 | * @param int|bool $value confirmed. |
2624 | 2624 | */ |
2625 | - public function set_is_viewed( $value ) { |
|
2626 | - $this->set_prop( 'is_viewed', $value ); |
|
2625 | + public function set_is_viewed($value) { |
|
2626 | + $this->set_prop('is_viewed', $value); |
|
2627 | 2627 | } |
2628 | 2628 | |
2629 | 2629 | /** |
@@ -2632,8 +2632,8 @@ discard block |
||
2632 | 2632 | * @since 1.0.19 |
2633 | 2633 | * @param string $value email recipients. |
2634 | 2634 | */ |
2635 | - public function set_email_cc( $value ) { |
|
2636 | - $this->set_prop( 'email_cc', $value ); |
|
2635 | + public function set_email_cc($value) { |
|
2636 | + $this->set_prop('email_cc', $value); |
|
2637 | 2637 | } |
2638 | 2638 | |
2639 | 2639 | /** |
@@ -2642,9 +2642,9 @@ discard block |
||
2642 | 2642 | * @since 1.0.19 |
2643 | 2643 | * @param string $value template. |
2644 | 2644 | */ |
2645 | - public function set_template( $value ) { |
|
2646 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2647 | - $this->set_prop( 'template', $value ); |
|
2645 | + public function set_template($value) { |
|
2646 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2647 | + $this->set_prop('template', $value); |
|
2648 | 2648 | } |
2649 | 2649 | } |
2650 | 2650 | |
@@ -2654,8 +2654,8 @@ discard block |
||
2654 | 2654 | * @since 1.0.19 |
2655 | 2655 | * @param string $value email recipients. |
2656 | 2656 | */ |
2657 | - public function created_via( $value ) { |
|
2658 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2657 | + public function created_via($value) { |
|
2658 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2659 | 2659 | } |
2660 | 2660 | |
2661 | 2661 | /** |
@@ -2664,8 +2664,8 @@ discard block |
||
2664 | 2664 | * @since 1.0.19 |
2665 | 2665 | * @param int|bool $value confirmed. |
2666 | 2666 | */ |
2667 | - public function set_address_confirmed( $value ) { |
|
2668 | - $this->set_prop( 'address_confirmed', $value ); |
|
2667 | + public function set_address_confirmed($value) { |
|
2668 | + $this->set_prop('address_confirmed', $value); |
|
2669 | 2669 | } |
2670 | 2670 | |
2671 | 2671 | /** |
@@ -2674,8 +2674,8 @@ discard block |
||
2674 | 2674 | * @since 1.0.19 |
2675 | 2675 | * @param int|bool $value confirmed. |
2676 | 2676 | */ |
2677 | - public function set_user_address_confirmed( $value ) { |
|
2678 | - $this->set_address_confirmed( $value ); |
|
2677 | + public function set_user_address_confirmed($value) { |
|
2678 | + $this->set_address_confirmed($value); |
|
2679 | 2679 | } |
2680 | 2680 | |
2681 | 2681 | /** |
@@ -2684,8 +2684,8 @@ discard block |
||
2684 | 2684 | * @since 1.0.19 |
2685 | 2685 | * @param int|bool $value confirmed. |
2686 | 2686 | */ |
2687 | - public function set_customer_address_confirmed( $value ) { |
|
2688 | - $this->set_address_confirmed( $value ); |
|
2687 | + public function set_customer_address_confirmed($value) { |
|
2688 | + $this->set_address_confirmed($value); |
|
2689 | 2689 | } |
2690 | 2690 | |
2691 | 2691 | /** |
@@ -2694,8 +2694,8 @@ discard block |
||
2694 | 2694 | * @since 1.0.19 |
2695 | 2695 | * @param float $value sub total. |
2696 | 2696 | */ |
2697 | - public function set_subtotal( $value ) { |
|
2698 | - $this->set_prop( 'subtotal', $value ); |
|
2697 | + public function set_subtotal($value) { |
|
2698 | + $this->set_prop('subtotal', $value); |
|
2699 | 2699 | } |
2700 | 2700 | |
2701 | 2701 | /** |
@@ -2704,8 +2704,8 @@ discard block |
||
2704 | 2704 | * @since 1.0.19 |
2705 | 2705 | * @param float $value discount total. |
2706 | 2706 | */ |
2707 | - public function set_total_discount( $value ) { |
|
2708 | - $this->set_prop( 'total_discount', $value ); |
|
2707 | + public function set_total_discount($value) { |
|
2708 | + $this->set_prop('total_discount', $value); |
|
2709 | 2709 | } |
2710 | 2710 | |
2711 | 2711 | /** |
@@ -2714,8 +2714,8 @@ discard block |
||
2714 | 2714 | * @since 1.0.19 |
2715 | 2715 | * @param float $value discount total. |
2716 | 2716 | */ |
2717 | - public function set_discount( $value ) { |
|
2718 | - $this->set_total_discount( $value ); |
|
2717 | + public function set_discount($value) { |
|
2718 | + $this->set_total_discount($value); |
|
2719 | 2719 | } |
2720 | 2720 | |
2721 | 2721 | /** |
@@ -2724,8 +2724,8 @@ discard block |
||
2724 | 2724 | * @since 1.0.19 |
2725 | 2725 | * @param float $value tax total. |
2726 | 2726 | */ |
2727 | - public function set_total_tax( $value ) { |
|
2728 | - $this->set_prop( 'total_tax', $value ); |
|
2727 | + public function set_total_tax($value) { |
|
2728 | + $this->set_prop('total_tax', $value); |
|
2729 | 2729 | } |
2730 | 2730 | |
2731 | 2731 | /** |
@@ -2734,8 +2734,8 @@ discard block |
||
2734 | 2734 | * @since 1.0.19 |
2735 | 2735 | * @param float $value tax total. |
2736 | 2736 | */ |
2737 | - public function set_tax_total( $value ) { |
|
2738 | - $this->set_total_tax( $value ); |
|
2737 | + public function set_tax_total($value) { |
|
2738 | + $this->set_total_tax($value); |
|
2739 | 2739 | } |
2740 | 2740 | |
2741 | 2741 | /** |
@@ -2744,8 +2744,8 @@ discard block |
||
2744 | 2744 | * @since 1.0.19 |
2745 | 2745 | * @param float $value fees total. |
2746 | 2746 | */ |
2747 | - public function set_total_fees( $value ) { |
|
2748 | - $this->set_prop( 'total_fees', $value ); |
|
2747 | + public function set_total_fees($value) { |
|
2748 | + $this->set_prop('total_fees', $value); |
|
2749 | 2749 | } |
2750 | 2750 | |
2751 | 2751 | /** |
@@ -2754,8 +2754,8 @@ discard block |
||
2754 | 2754 | * @since 1.0.19 |
2755 | 2755 | * @param float $value fees total. |
2756 | 2756 | */ |
2757 | - public function set_fees_total( $value ) { |
|
2758 | - $this->set_total_fees( $value ); |
|
2757 | + public function set_fees_total($value) { |
|
2758 | + $this->set_total_fees($value); |
|
2759 | 2759 | } |
2760 | 2760 | |
2761 | 2761 | /** |
@@ -2764,13 +2764,13 @@ discard block |
||
2764 | 2764 | * @since 1.0.19 |
2765 | 2765 | * @param array $value fees. |
2766 | 2766 | */ |
2767 | - public function set_fees( $value ) { |
|
2767 | + public function set_fees($value) { |
|
2768 | 2768 | |
2769 | - if ( ! is_array( $value ) ) { |
|
2769 | + if (!is_array($value)) { |
|
2770 | 2770 | $value = array(); |
2771 | 2771 | } |
2772 | 2772 | |
2773 | - $this->set_prop( 'fees', $value ); |
|
2773 | + $this->set_prop('fees', $value); |
|
2774 | 2774 | |
2775 | 2775 | } |
2776 | 2776 | |
@@ -2780,13 +2780,13 @@ discard block |
||
2780 | 2780 | * @since 1.0.19 |
2781 | 2781 | * @param array $value taxes. |
2782 | 2782 | */ |
2783 | - public function set_taxes( $value ) { |
|
2783 | + public function set_taxes($value) { |
|
2784 | 2784 | |
2785 | - if ( ! is_array( $value ) ) { |
|
2785 | + if (!is_array($value)) { |
|
2786 | 2786 | $value = array(); |
2787 | 2787 | } |
2788 | 2788 | |
2789 | - $this->set_prop( 'taxes', $value ); |
|
2789 | + $this->set_prop('taxes', $value); |
|
2790 | 2790 | |
2791 | 2791 | } |
2792 | 2792 | |
@@ -2796,13 +2796,13 @@ discard block |
||
2796 | 2796 | * @since 1.0.19 |
2797 | 2797 | * @param array $value discounts. |
2798 | 2798 | */ |
2799 | - public function set_discounts( $value ) { |
|
2799 | + public function set_discounts($value) { |
|
2800 | 2800 | |
2801 | - if ( ! is_array( $value ) ) { |
|
2801 | + if (!is_array($value)) { |
|
2802 | 2802 | $value = array(); |
2803 | 2803 | } |
2804 | 2804 | |
2805 | - $this->set_prop( 'discounts', $value ); |
|
2805 | + $this->set_prop('discounts', $value); |
|
2806 | 2806 | } |
2807 | 2807 | |
2808 | 2808 | /** |
@@ -2811,18 +2811,18 @@ discard block |
||
2811 | 2811 | * @since 1.0.19 |
2812 | 2812 | * @param GetPaid_Form_Item[] $value items. |
2813 | 2813 | */ |
2814 | - public function set_items( $value ) { |
|
2814 | + public function set_items($value) { |
|
2815 | 2815 | |
2816 | 2816 | // Remove existing items. |
2817 | - $this->set_prop( 'items', array() ); |
|
2817 | + $this->set_prop('items', array()); |
|
2818 | 2818 | |
2819 | 2819 | // Ensure that we have an array. |
2820 | - if ( ! is_array( $value ) ) { |
|
2820 | + if (!is_array($value)) { |
|
2821 | 2821 | return; |
2822 | 2822 | } |
2823 | 2823 | |
2824 | - foreach ( $value as $item ) { |
|
2825 | - $this->add_item( $item ); |
|
2824 | + foreach ($value as $item) { |
|
2825 | + $this->add_item($item); |
|
2826 | 2826 | } |
2827 | 2827 | |
2828 | 2828 | } |
@@ -2833,8 +2833,8 @@ discard block |
||
2833 | 2833 | * @since 1.0.19 |
2834 | 2834 | * @param int $value payment form. |
2835 | 2835 | */ |
2836 | - public function set_payment_form( $value ) { |
|
2837 | - $this->set_prop( 'payment_form', $value ); |
|
2836 | + public function set_payment_form($value) { |
|
2837 | + $this->set_prop('payment_form', $value); |
|
2838 | 2838 | } |
2839 | 2839 | |
2840 | 2840 | /** |
@@ -2843,8 +2843,8 @@ discard block |
||
2843 | 2843 | * @since 1.0.19 |
2844 | 2844 | * @param string $value submission id. |
2845 | 2845 | */ |
2846 | - public function set_submission_id( $value ) { |
|
2847 | - $this->set_prop( 'submission_id', $value ); |
|
2846 | + public function set_submission_id($value) { |
|
2847 | + $this->set_prop('submission_id', $value); |
|
2848 | 2848 | } |
2849 | 2849 | |
2850 | 2850 | /** |
@@ -2853,8 +2853,8 @@ discard block |
||
2853 | 2853 | * @since 1.0.19 |
2854 | 2854 | * @param string $value discount code. |
2855 | 2855 | */ |
2856 | - public function set_discount_code( $value ) { |
|
2857 | - $this->set_prop( 'discount_code', $value ); |
|
2856 | + public function set_discount_code($value) { |
|
2857 | + $this->set_prop('discount_code', $value); |
|
2858 | 2858 | } |
2859 | 2859 | |
2860 | 2860 | /** |
@@ -2863,8 +2863,8 @@ discard block |
||
2863 | 2863 | * @since 1.0.19 |
2864 | 2864 | * @param string $value gateway. |
2865 | 2865 | */ |
2866 | - public function set_gateway( $value ) { |
|
2867 | - $this->set_prop( 'gateway', $value ); |
|
2866 | + public function set_gateway($value) { |
|
2867 | + $this->set_prop('gateway', $value); |
|
2868 | 2868 | } |
2869 | 2869 | |
2870 | 2870 | /** |
@@ -2873,9 +2873,9 @@ discard block |
||
2873 | 2873 | * @since 1.0.19 |
2874 | 2874 | * @param string $value transaction id. |
2875 | 2875 | */ |
2876 | - public function set_transaction_id( $value ) { |
|
2877 | - if ( ! empty( $value ) ) { |
|
2878 | - $this->set_prop( 'transaction_id', $value ); |
|
2876 | + public function set_transaction_id($value) { |
|
2877 | + if (!empty($value)) { |
|
2878 | + $this->set_prop('transaction_id', $value); |
|
2879 | 2879 | } |
2880 | 2880 | } |
2881 | 2881 | |
@@ -2885,8 +2885,8 @@ discard block |
||
2885 | 2885 | * @since 1.0.19 |
2886 | 2886 | * @param string $value currency id. |
2887 | 2887 | */ |
2888 | - public function set_currency( $value ) { |
|
2889 | - $this->set_prop( 'currency', $value ); |
|
2888 | + public function set_currency($value) { |
|
2889 | + $this->set_prop('currency', $value); |
|
2890 | 2890 | } |
2891 | 2891 | |
2892 | 2892 | /** |
@@ -2895,8 +2895,8 @@ discard block |
||
2895 | 2895 | * @since 1.0.19 |
2896 | 2896 | * @param bool $value value. |
2897 | 2897 | */ |
2898 | - public function set_disable_taxes( $value ) { |
|
2899 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2898 | + public function set_disable_taxes($value) { |
|
2899 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2900 | 2900 | } |
2901 | 2901 | |
2902 | 2902 | /** |
@@ -2905,8 +2905,8 @@ discard block |
||
2905 | 2905 | * @since 1.0.19 |
2906 | 2906 | * @param string $value subscription id. |
2907 | 2907 | */ |
2908 | - public function set_subscription_id( $value ) { |
|
2909 | - $this->set_prop( 'subscription_id', $value ); |
|
2908 | + public function set_subscription_id($value) { |
|
2909 | + $this->set_prop('subscription_id', $value); |
|
2910 | 2910 | } |
2911 | 2911 | |
2912 | 2912 | /** |
@@ -2915,8 +2915,8 @@ discard block |
||
2915 | 2915 | * @since 1.0.19 |
2916 | 2916 | * @param string $value subscription id. |
2917 | 2917 | */ |
2918 | - public function set_remote_subscription_id( $value ) { |
|
2919 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2918 | + public function set_remote_subscription_id($value) { |
|
2919 | + $this->set_prop('remote_subscription_id', $value); |
|
2920 | 2920 | } |
2921 | 2921 | |
2922 | 2922 | /* |
@@ -2933,28 +2933,28 @@ discard block |
||
2933 | 2933 | */ |
2934 | 2934 | public function is_parent() { |
2935 | 2935 | $parent = $this->get_parent_id(); |
2936 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2936 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2937 | 2937 | } |
2938 | 2938 | |
2939 | 2939 | /** |
2940 | 2940 | * Checks if this is a renewal invoice. |
2941 | 2941 | */ |
2942 | 2942 | public function is_renewal() { |
2943 | - return ! $this->is_parent(); |
|
2943 | + return !$this->is_parent(); |
|
2944 | 2944 | } |
2945 | 2945 | |
2946 | 2946 | /** |
2947 | 2947 | * Checks if this is a recurring invoice. |
2948 | 2948 | */ |
2949 | 2949 | public function is_recurring() { |
2950 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2950 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2951 | 2951 | } |
2952 | 2952 | |
2953 | 2953 | /** |
2954 | 2954 | * Checks if this is a taxable invoice. |
2955 | 2955 | */ |
2956 | 2956 | public function is_taxable() { |
2957 | - return ! $this->get_disable_taxes(); |
|
2957 | + return !$this->get_disable_taxes(); |
|
2958 | 2958 | } |
2959 | 2959 | |
2960 | 2960 | /** |
@@ -2965,57 +2965,57 @@ discard block |
||
2965 | 2965 | |
2966 | 2966 | $requires_vat = false; |
2967 | 2967 | |
2968 | - if ( $this->country ) { |
|
2968 | + if ($this->country) { |
|
2969 | 2969 | $wpi_country = $this->country; |
2970 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
2970 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
2971 | 2971 | } |
2972 | 2972 | |
2973 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
2973 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
2974 | 2974 | } |
2975 | 2975 | |
2976 | 2976 | /** |
2977 | 2977 | * Checks to see if the invoice requires payment. |
2978 | 2978 | */ |
2979 | 2979 | public function is_free() { |
2980 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2980 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2981 | 2981 | |
2982 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2982 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2983 | 2983 | $is_free = false; |
2984 | 2984 | } |
2985 | 2985 | |
2986 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2986 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2987 | 2987 | } |
2988 | 2988 | |
2989 | 2989 | /** |
2990 | 2990 | * Checks if the invoice is paid. |
2991 | 2991 | */ |
2992 | 2992 | public function is_paid() { |
2993 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2994 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2993 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2994 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2995 | 2995 | } |
2996 | 2996 | |
2997 | 2997 | /** |
2998 | 2998 | * Checks if the invoice needs payment. |
2999 | 2999 | */ |
3000 | 3000 | public function needs_payment() { |
3001 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
3002 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
3001 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
3002 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
3003 | 3003 | } |
3004 | 3004 | |
3005 | 3005 | /** |
3006 | 3006 | * Checks if the invoice is refunded. |
3007 | 3007 | */ |
3008 | 3008 | public function is_refunded() { |
3009 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3010 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3009 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3010 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3011 | 3011 | } |
3012 | 3012 | |
3013 | 3013 | /** |
3014 | 3014 | * Checks if the invoice is held. |
3015 | 3015 | */ |
3016 | 3016 | public function is_held() { |
3017 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3018 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3017 | + $is_held = $this->has_status('wpi-onhold'); |
|
3018 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3019 | 3019 | } |
3020 | 3020 | |
3021 | 3021 | /** |
@@ -3023,30 +3023,30 @@ discard block |
||
3023 | 3023 | */ |
3024 | 3024 | public function is_due() { |
3025 | 3025 | $due_date = $this->get_due_date(); |
3026 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3026 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3027 | 3027 | } |
3028 | 3028 | |
3029 | 3029 | /** |
3030 | 3030 | * Checks if the invoice is draft. |
3031 | 3031 | */ |
3032 | 3032 | public function is_draft() { |
3033 | - return $this->has_status( 'draft, auto-draft' ); |
|
3033 | + return $this->has_status('draft, auto-draft'); |
|
3034 | 3034 | } |
3035 | 3035 | |
3036 | 3036 | /** |
3037 | 3037 | * Checks if the invoice has a given status. |
3038 | 3038 | */ |
3039 | - public function has_status( $status ) { |
|
3040 | - $status = wpinv_parse_list( $status ); |
|
3041 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3039 | + public function has_status($status) { |
|
3040 | + $status = wpinv_parse_list($status); |
|
3041 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3042 | 3042 | } |
3043 | 3043 | |
3044 | 3044 | /** |
3045 | 3045 | * Checks if the invoice is of a given type. |
3046 | 3046 | */ |
3047 | - public function is_type( $type ) { |
|
3048 | - $type = wpinv_parse_list( $type ); |
|
3049 | - return in_array( $this->get_type(), $type ); |
|
3047 | + public function is_type($type) { |
|
3048 | + $type = wpinv_parse_list($type); |
|
3049 | + return in_array($this->get_type(), $type); |
|
3050 | 3050 | } |
3051 | 3051 | |
3052 | 3052 | /** |
@@ -3078,8 +3078,8 @@ discard block |
||
3078 | 3078 | * |
3079 | 3079 | */ |
3080 | 3080 | public function is_initial_free() { |
3081 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3082 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3081 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3082 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3083 | 3083 | } |
3084 | 3084 | |
3085 | 3085 | /** |
@@ -3089,11 +3089,11 @@ discard block |
||
3089 | 3089 | public function item_has_free_trial() { |
3090 | 3090 | |
3091 | 3091 | // Ensure we have a recurring item. |
3092 | - if ( ! $this->is_recurring() ) { |
|
3092 | + if (!$this->is_recurring()) { |
|
3093 | 3093 | return false; |
3094 | 3094 | } |
3095 | 3095 | |
3096 | - $item = $this->get_recurring( true ); |
|
3096 | + $item = $this->get_recurring(true); |
|
3097 | 3097 | return $item->has_free_trial(); |
3098 | 3098 | } |
3099 | 3099 | |
@@ -3101,7 +3101,7 @@ discard block |
||
3101 | 3101 | * Check if the free trial is a result of a discount. |
3102 | 3102 | */ |
3103 | 3103 | public function is_free_trial_from_discount() { |
3104 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3104 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3105 | 3105 | } |
3106 | 3106 | |
3107 | 3107 | /** |
@@ -3110,17 +3110,17 @@ discard block |
||
3110 | 3110 | public function discount_first_payment_only() { |
3111 | 3111 | |
3112 | 3112 | $discount_code = $this->get_discount_code(); |
3113 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
3113 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
3114 | 3114 | return true; |
3115 | 3115 | } |
3116 | 3116 | |
3117 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3117 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3118 | 3118 | |
3119 | - if ( ! $discount || ! $discount->exists() ) { |
|
3119 | + if (!$discount || !$discount->exists()) { |
|
3120 | 3120 | return true; |
3121 | 3121 | } |
3122 | 3122 | |
3123 | - return ! $discount->get_is_recurring(); |
|
3123 | + return !$discount->get_is_recurring(); |
|
3124 | 3124 | } |
3125 | 3125 | |
3126 | 3126 | /* |
@@ -3138,27 +3138,27 @@ discard block |
||
3138 | 3138 | * @param GetPaid_Form_Item|array $item |
3139 | 3139 | * @return WP_Error|Bool |
3140 | 3140 | */ |
3141 | - public function add_item( $item ) { |
|
3141 | + public function add_item($item) { |
|
3142 | 3142 | |
3143 | - if ( is_array( $item ) ) { |
|
3144 | - $item = $this->process_array_item( $item ); |
|
3143 | + if (is_array($item)) { |
|
3144 | + $item = $this->process_array_item($item); |
|
3145 | 3145 | } |
3146 | 3146 | |
3147 | - if ( is_numeric( $item ) ) { |
|
3148 | - $item = new GetPaid_Form_Item( $item ); |
|
3147 | + if (is_numeric($item)) { |
|
3148 | + $item = new GetPaid_Form_Item($item); |
|
3149 | 3149 | } |
3150 | 3150 | |
3151 | 3151 | // Make sure that it is available for purchase. |
3152 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3153 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3152 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3153 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3154 | 3154 | } |
3155 | 3155 | |
3156 | 3156 | // Do we have a recurring item? |
3157 | - if ( $item->is_recurring() ) { |
|
3157 | + if ($item->is_recurring()) { |
|
3158 | 3158 | |
3159 | 3159 | // An invoice can only contain one recurring item. |
3160 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3161 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3160 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3161 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3162 | 3162 | } |
3163 | 3163 | |
3164 | 3164 | $this->recurring_item = $item->get_id(); |
@@ -3169,9 +3169,9 @@ discard block |
||
3169 | 3169 | |
3170 | 3170 | // Retrieve all items. |
3171 | 3171 | $items = $this->get_items(); |
3172 | - $items[ (int) $item->get_id() ] = $item; |
|
3172 | + $items[(int) $item->get_id()] = $item; |
|
3173 | 3173 | |
3174 | - $this->set_prop( 'items', $items ); |
|
3174 | + $this->set_prop('items', $items); |
|
3175 | 3175 | return true; |
3176 | 3176 | } |
3177 | 3177 | |
@@ -3181,26 +3181,26 @@ discard block |
||
3181 | 3181 | * @since 1.0.19 |
3182 | 3182 | * @return GetPaid_Form_Item |
3183 | 3183 | */ |
3184 | - protected function process_array_item( $array ) { |
|
3184 | + protected function process_array_item($array) { |
|
3185 | 3185 | |
3186 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3187 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3186 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3187 | + $item = new GetPaid_Form_Item($item_id); |
|
3188 | 3188 | |
3189 | 3189 | // Set item data. |
3190 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3191 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3190 | + foreach (array('name', 'price', 'description') as $key) { |
|
3191 | + if (isset($array["item_$key"])) { |
|
3192 | 3192 | $method = "set_$key"; |
3193 | - $item->$method( $array[ "item_$key" ] ); |
|
3193 | + $item->$method($array["item_$key"]); |
|
3194 | 3194 | } |
3195 | 3195 | } |
3196 | 3196 | |
3197 | - if ( isset( $array['quantity'] ) ) { |
|
3198 | - $item->set_quantity( $array['quantity'] ); |
|
3197 | + if (isset($array['quantity'])) { |
|
3198 | + $item->set_quantity($array['quantity']); |
|
3199 | 3199 | } |
3200 | 3200 | |
3201 | 3201 | // Set item meta. |
3202 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3203 | - $item->set_item_meta( $array['meta'] ); |
|
3202 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3203 | + $item->set_item_meta($array['meta']); |
|
3204 | 3204 | } |
3205 | 3205 | |
3206 | 3206 | return $item; |
@@ -3212,10 +3212,10 @@ discard block |
||
3212 | 3212 | * |
3213 | 3213 | * @since 1.0.19 |
3214 | 3214 | */ |
3215 | - public function get_item( $item_id ) { |
|
3215 | + public function get_item($item_id) { |
|
3216 | 3216 | $items = $this->get_items(); |
3217 | 3217 | $item_id = (int) $item_id; |
3218 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3218 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3219 | 3219 | } |
3220 | 3220 | |
3221 | 3221 | /** |
@@ -3223,17 +3223,17 @@ discard block |
||
3223 | 3223 | * |
3224 | 3224 | * @since 1.0.19 |
3225 | 3225 | */ |
3226 | - public function remove_item( $item_id ) { |
|
3226 | + public function remove_item($item_id) { |
|
3227 | 3227 | $items = $this->get_items(); |
3228 | 3228 | $item_id = (int) $item_id; |
3229 | 3229 | |
3230 | - if ( $item_id == $this->recurring_item ) { |
|
3230 | + if ($item_id == $this->recurring_item) { |
|
3231 | 3231 | $this->recurring_item = null; |
3232 | 3232 | } |
3233 | 3233 | |
3234 | - if ( isset( $items[ $item_id ] ) ) { |
|
3235 | - unset( $items[ $item_id ] ); |
|
3236 | - $this->set_prop( 'items', $items ); |
|
3234 | + if (isset($items[$item_id])) { |
|
3235 | + unset($items[$item_id]); |
|
3236 | + $this->set_prop('items', $items); |
|
3237 | 3237 | } |
3238 | 3238 | } |
3239 | 3239 | |
@@ -3243,11 +3243,11 @@ discard block |
||
3243 | 3243 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3244 | 3244 | * @since 1.0.19 |
3245 | 3245 | */ |
3246 | - public function add_fee( $fee ) { |
|
3246 | + public function add_fee($fee) { |
|
3247 | 3247 | |
3248 | 3248 | $fees = $this->get_fees(); |
3249 | - $fees[ $fee['name'] ] = $fee; |
|
3250 | - $this->set_prop( 'fees', $fees ); |
|
3249 | + $fees[$fee['name']] = $fee; |
|
3250 | + $this->set_prop('fees', $fees); |
|
3251 | 3251 | |
3252 | 3252 | } |
3253 | 3253 | |
@@ -3256,9 +3256,9 @@ discard block |
||
3256 | 3256 | * |
3257 | 3257 | * @since 1.0.19 |
3258 | 3258 | */ |
3259 | - public function get_fee( $fee ) { |
|
3259 | + public function get_fee($fee) { |
|
3260 | 3260 | $fees = $this->get_fees(); |
3261 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3261 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3262 | 3262 | } |
3263 | 3263 | |
3264 | 3264 | /** |
@@ -3266,11 +3266,11 @@ discard block |
||
3266 | 3266 | * |
3267 | 3267 | * @since 1.0.19 |
3268 | 3268 | */ |
3269 | - public function remove_fee( $fee ) { |
|
3269 | + public function remove_fee($fee) { |
|
3270 | 3270 | $fees = $this->get_fees(); |
3271 | - if ( isset( $fees[ $fee ] ) ) { |
|
3272 | - unset( $fees[ $fee ] ); |
|
3273 | - $this->set_prop( 'fees', $fees ); |
|
3271 | + if (isset($fees[$fee])) { |
|
3272 | + unset($fees[$fee]); |
|
3273 | + $this->set_prop('fees', $fees); |
|
3274 | 3274 | } |
3275 | 3275 | } |
3276 | 3276 | |
@@ -3280,11 +3280,11 @@ discard block |
||
3280 | 3280 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3281 | 3281 | * @since 1.0.19 |
3282 | 3282 | */ |
3283 | - public function add_discount( $discount ) { |
|
3283 | + public function add_discount($discount) { |
|
3284 | 3284 | |
3285 | 3285 | $discounts = $this->get_discounts(); |
3286 | - $discounts[ $discount['name'] ] = $discount; |
|
3287 | - $this->set_prop( 'discounts', $discounts ); |
|
3286 | + $discounts[$discount['name']] = $discount; |
|
3287 | + $this->set_prop('discounts', $discounts); |
|
3288 | 3288 | |
3289 | 3289 | } |
3290 | 3290 | |
@@ -3294,15 +3294,15 @@ discard block |
||
3294 | 3294 | * @since 1.0.19 |
3295 | 3295 | * @return float |
3296 | 3296 | */ |
3297 | - public function get_discount( $discount = false ) { |
|
3297 | + public function get_discount($discount = false) { |
|
3298 | 3298 | |
3299 | 3299 | // Backwards compatibilty. |
3300 | - if ( empty( $discount ) ) { |
|
3300 | + if (empty($discount)) { |
|
3301 | 3301 | return $this->get_total_discount(); |
3302 | 3302 | } |
3303 | 3303 | |
3304 | 3304 | $discounts = $this->get_discounts(); |
3305 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3305 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3306 | 3306 | } |
3307 | 3307 | |
3308 | 3308 | /** |
@@ -3310,11 +3310,11 @@ discard block |
||
3310 | 3310 | * |
3311 | 3311 | * @since 1.0.19 |
3312 | 3312 | */ |
3313 | - public function remove_discount( $discount ) { |
|
3313 | + public function remove_discount($discount) { |
|
3314 | 3314 | $discounts = $this->get_discounts(); |
3315 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3316 | - unset( $discounts[ $discount ] ); |
|
3317 | - $this->set_prop( 'discounts', $discounts ); |
|
3315 | + if (isset($discounts[$discount])) { |
|
3316 | + unset($discounts[$discount]); |
|
3317 | + $this->set_prop('discounts', $discounts); |
|
3318 | 3318 | } |
3319 | 3319 | } |
3320 | 3320 | |
@@ -3323,12 +3323,12 @@ discard block |
||
3323 | 3323 | * |
3324 | 3324 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3325 | 3325 | */ |
3326 | - public function add_tax( $tax ) { |
|
3327 | - if ( $this->is_taxable() ) { |
|
3326 | + public function add_tax($tax) { |
|
3327 | + if ($this->is_taxable()) { |
|
3328 | 3328 | |
3329 | - $taxes = $this->get_taxes(); |
|
3330 | - $taxes[ $tax['name'] ] = $tax; |
|
3331 | - $this->set_prop( 'taxes', $tax ); |
|
3329 | + $taxes = $this->get_taxes(); |
|
3330 | + $taxes[$tax['name']] = $tax; |
|
3331 | + $this->set_prop('taxes', $tax); |
|
3332 | 3332 | |
3333 | 3333 | } |
3334 | 3334 | } |
@@ -3338,15 +3338,15 @@ discard block |
||
3338 | 3338 | * |
3339 | 3339 | * @since 1.0.19 |
3340 | 3340 | */ |
3341 | - public function get_tax( $tax = null ) { |
|
3341 | + public function get_tax($tax = null) { |
|
3342 | 3342 | |
3343 | 3343 | // Backwards compatility. |
3344 | - if ( empty( $tax ) ) { |
|
3344 | + if (empty($tax)) { |
|
3345 | 3345 | return $this->get_total_tax(); |
3346 | 3346 | } |
3347 | 3347 | |
3348 | 3348 | $taxes = $this->get_taxes(); |
3349 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3349 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3350 | 3350 | } |
3351 | 3351 | |
3352 | 3352 | /** |
@@ -3354,11 +3354,11 @@ discard block |
||
3354 | 3354 | * |
3355 | 3355 | * @since 1.0.19 |
3356 | 3356 | */ |
3357 | - public function remove_tax( $tax ) { |
|
3357 | + public function remove_tax($tax) { |
|
3358 | 3358 | $taxes = $this->get_taxes(); |
3359 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3360 | - unset( $taxes[ $tax ] ); |
|
3361 | - $this->set_prop( 'taxes', $taxes ); |
|
3359 | + if (isset($taxes[$tax])) { |
|
3360 | + unset($taxes[$tax]); |
|
3361 | + $this->set_prop('taxes', $taxes); |
|
3362 | 3362 | } |
3363 | 3363 | } |
3364 | 3364 | |
@@ -3369,17 +3369,17 @@ discard block |
||
3369 | 3369 | * @return float The recalculated subtotal |
3370 | 3370 | */ |
3371 | 3371 | public function recalculate_subtotal() { |
3372 | - $items = $this->get_items(); |
|
3372 | + $items = $this->get_items(); |
|
3373 | 3373 | $subtotal = 0; |
3374 | 3374 | $recurring = 0; |
3375 | 3375 | |
3376 | - foreach ( $items as $item ) { |
|
3376 | + foreach ($items as $item) { |
|
3377 | 3377 | $subtotal += $item->get_sub_total(); |
3378 | 3378 | $recurring += $item->get_recurring_sub_total(); |
3379 | 3379 | } |
3380 | 3380 | |
3381 | 3381 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3382 | - $this->set_subtotal( $current ); |
|
3382 | + $this->set_subtotal($current); |
|
3383 | 3383 | |
3384 | 3384 | $this->totals['subtotal'] = array( |
3385 | 3385 | 'initial' => $subtotal, |
@@ -3400,14 +3400,14 @@ discard block |
||
3400 | 3400 | $discount = 0; |
3401 | 3401 | $recurring = 0; |
3402 | 3402 | |
3403 | - foreach ( $discounts as $data ) { |
|
3404 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3405 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3403 | + foreach ($discounts as $data) { |
|
3404 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3405 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3406 | 3406 | } |
3407 | 3407 | |
3408 | 3408 | $current = $this->is_renewal() ? $recurring : $discount; |
3409 | 3409 | |
3410 | - $this->set_total_discount( $current ); |
|
3410 | + $this->set_total_discount($current); |
|
3411 | 3411 | |
3412 | 3412 | $this->totals['discount'] = array( |
3413 | 3413 | 'initial' => $discount, |
@@ -3425,17 +3425,17 @@ discard block |
||
3425 | 3425 | * @return float The recalculated tax |
3426 | 3426 | */ |
3427 | 3427 | public function recalculate_total_tax() { |
3428 | - $taxes = $this->get_taxes(); |
|
3428 | + $taxes = $this->get_taxes(); |
|
3429 | 3429 | $tax = 0; |
3430 | 3430 | $recurring = 0; |
3431 | 3431 | |
3432 | - foreach ( $taxes as $data ) { |
|
3433 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
3434 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
3432 | + foreach ($taxes as $data) { |
|
3433 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
3434 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
3435 | 3435 | } |
3436 | 3436 | |
3437 | 3437 | $current = $this->is_renewal() ? $recurring : $tax; |
3438 | - $this->set_total_tax( $current ); |
|
3438 | + $this->set_total_tax($current); |
|
3439 | 3439 | |
3440 | 3440 | $this->totals['tax'] = array( |
3441 | 3441 | 'initial' => $tax, |
@@ -3457,20 +3457,20 @@ discard block |
||
3457 | 3457 | $fee = 0; |
3458 | 3458 | $recurring = 0; |
3459 | 3459 | |
3460 | - foreach ( $fees as $data ) { |
|
3461 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3462 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3460 | + foreach ($fees as $data) { |
|
3461 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3462 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3463 | 3463 | } |
3464 | 3464 | |
3465 | 3465 | $current = $this->is_renewal() ? $recurring : $fee; |
3466 | - $this->set_total_fees( $current ); |
|
3466 | + $this->set_total_fees($current); |
|
3467 | 3467 | |
3468 | 3468 | $this->totals['fee'] = array( |
3469 | 3469 | 'initial' => $fee, |
3470 | 3470 | 'recurring' => $recurring, |
3471 | 3471 | ); |
3472 | 3472 | |
3473 | - $this->set_total_fees( $fee ); |
|
3473 | + $this->set_total_fees($fee); |
|
3474 | 3474 | return $current; |
3475 | 3475 | } |
3476 | 3476 | |
@@ -3491,9 +3491,9 @@ discard block |
||
3491 | 3491 | /** |
3492 | 3492 | * @deprecated |
3493 | 3493 | */ |
3494 | - public function recalculate_totals( $temp = false ) { |
|
3495 | - $this->update_items( $temp ); |
|
3496 | - $this->save( true ); |
|
3494 | + public function recalculate_totals($temp = false) { |
|
3495 | + $this->update_items($temp); |
|
3496 | + $this->save(true); |
|
3497 | 3497 | return $this; |
3498 | 3498 | } |
3499 | 3499 | |
@@ -3511,10 +3511,10 @@ discard block |
||
3511 | 3511 | * @return int|false The new note's ID on success, false on failure. |
3512 | 3512 | * |
3513 | 3513 | */ |
3514 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3514 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3515 | 3515 | |
3516 | 3516 | // Bail if no note specified or this invoice is not yet saved. |
3517 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3517 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3518 | 3518 | return false; |
3519 | 3519 | } |
3520 | 3520 | |
@@ -3522,23 +3522,23 @@ discard block |
||
3522 | 3522 | $author_email = '[email protected]'; |
3523 | 3523 | |
3524 | 3524 | // If this is an admin comment or it has been added by the user. |
3525 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3526 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3525 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3526 | + $user = get_user_by('id', get_current_user_id()); |
|
3527 | 3527 | $author = $user->display_name; |
3528 | 3528 | $author_email = $user->user_email; |
3529 | 3529 | } |
3530 | 3530 | |
3531 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3531 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3532 | 3532 | |
3533 | 3533 | } |
3534 | 3534 | |
3535 | 3535 | /** |
3536 | 3536 | * Generates a unique key for the invoice. |
3537 | 3537 | */ |
3538 | - public function generate_key( $string = '' ) { |
|
3539 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3538 | + public function generate_key($string = '') { |
|
3539 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3540 | 3540 | return strtolower( |
3541 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3541 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3542 | 3542 | ); |
3543 | 3543 | } |
3544 | 3544 | |
@@ -3548,11 +3548,11 @@ discard block |
||
3548 | 3548 | public function generate_number() { |
3549 | 3549 | $number = $this->get_id(); |
3550 | 3550 | |
3551 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3552 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3551 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3552 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3553 | 3553 | } |
3554 | 3554 | |
3555 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3555 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3556 | 3556 | |
3557 | 3557 | } |
3558 | 3558 | |
@@ -3565,55 +3565,55 @@ discard block |
||
3565 | 3565 | // Reset status transition variable. |
3566 | 3566 | $this->status_transition = false; |
3567 | 3567 | |
3568 | - if ( $status_transition ) { |
|
3568 | + if ($status_transition) { |
|
3569 | 3569 | try { |
3570 | 3570 | |
3571 | 3571 | // Fire a hook for the status change. |
3572 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3572 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3573 | 3573 | |
3574 | 3574 | // @deprecated this is deprecated and will be removed in the future. |
3575 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3575 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3576 | 3576 | |
3577 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3577 | + if (!empty($status_transition['from'])) { |
|
3578 | 3578 | |
3579 | 3579 | /* translators: 1: old invoice status 2: new invoice status */ |
3580 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3580 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
3581 | 3581 | |
3582 | 3582 | // Fire another hook. |
3583 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3584 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3583 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3584 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3585 | 3585 | |
3586 | 3586 | // @deprecated this is deprecated and will be removed in the future. |
3587 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3587 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3588 | 3588 | |
3589 | 3589 | // Note the transition occurred. |
3590 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3590 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3591 | 3591 | |
3592 | 3592 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3593 | 3593 | if ( |
3594 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3595 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3594 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3595 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3596 | 3596 | ) { |
3597 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3597 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3598 | 3598 | } |
3599 | 3599 | |
3600 | 3600 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3601 | 3601 | if ( |
3602 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3603 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3602 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3603 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3604 | 3604 | ) { |
3605 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3605 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3606 | 3606 | } |
3607 | 3607 | } else { |
3608 | 3608 | /* translators: %s: new invoice status */ |
3609 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3609 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3610 | 3610 | |
3611 | 3611 | // Note the transition occurred. |
3612 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3612 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3613 | 3613 | |
3614 | 3614 | } |
3615 | - } catch ( Exception $e ) { |
|
3616 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3615 | + } catch (Exception $e) { |
|
3616 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3617 | 3617 | } |
3618 | 3618 | } |
3619 | 3619 | } |
@@ -3621,13 +3621,13 @@ discard block |
||
3621 | 3621 | /** |
3622 | 3622 | * Updates an invoice status. |
3623 | 3623 | */ |
3624 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3624 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3625 | 3625 | |
3626 | 3626 | // Fires before updating a status. |
3627 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3627 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3628 | 3628 | |
3629 | 3629 | // Update the status. |
3630 | - $this->set_status( $new_status, $note, $manual ); |
|
3630 | + $this->set_status($new_status, $note, $manual); |
|
3631 | 3631 | |
3632 | 3632 | // Save the order. |
3633 | 3633 | return $this->save(); |
@@ -3638,18 +3638,18 @@ discard block |
||
3638 | 3638 | * @deprecated |
3639 | 3639 | */ |
3640 | 3640 | public function refresh_item_ids() { |
3641 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3642 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3641 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3642 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3643 | 3643 | } |
3644 | 3644 | |
3645 | 3645 | /** |
3646 | 3646 | * @deprecated |
3647 | 3647 | */ |
3648 | - public function update_items( $temp = false ) { |
|
3648 | + public function update_items($temp = false) { |
|
3649 | 3649 | |
3650 | - $this->set_items( $this->get_items() ); |
|
3650 | + $this->set_items($this->get_items()); |
|
3651 | 3651 | |
3652 | - if ( ! $temp ) { |
|
3652 | + if (!$temp) { |
|
3653 | 3653 | $this->save(); |
3654 | 3654 | } |
3655 | 3655 | |
@@ -3663,11 +3663,11 @@ discard block |
||
3663 | 3663 | |
3664 | 3664 | $discount_code = $this->get_discount_code(); |
3665 | 3665 | |
3666 | - if ( empty( $discount_code ) ) { |
|
3666 | + if (empty($discount_code)) { |
|
3667 | 3667 | return false; |
3668 | 3668 | } |
3669 | 3669 | |
3670 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3670 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3671 | 3671 | |
3672 | 3672 | // Ensure it is active. |
3673 | 3673 | return $discount->exists(); |
@@ -3678,7 +3678,7 @@ discard block |
||
3678 | 3678 | * Refunds an invoice. |
3679 | 3679 | */ |
3680 | 3680 | public function refund() { |
3681 | - $this->set_status( 'wpi-refunded' ); |
|
3681 | + $this->set_status('wpi-refunded'); |
|
3682 | 3682 | $this->save(); |
3683 | 3683 | } |
3684 | 3684 | |
@@ -3687,56 +3687,56 @@ discard block |
||
3687 | 3687 | * |
3688 | 3688 | * @param string $transaction_id |
3689 | 3689 | */ |
3690 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3690 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3691 | 3691 | |
3692 | 3692 | // Set the transaction id. |
3693 | - if ( empty( $transaction_id ) ) { |
|
3693 | + if (empty($transaction_id)) { |
|
3694 | 3694 | $transaction_id = $this->generate_key('trans_'); |
3695 | 3695 | } |
3696 | 3696 | |
3697 | - if ( ! $this->get_transaction_id() ) { |
|
3698 | - $this->set_transaction_id( $transaction_id ); |
|
3697 | + if (!$this->get_transaction_id()) { |
|
3698 | + $this->set_transaction_id($transaction_id); |
|
3699 | 3699 | } |
3700 | 3700 | |
3701 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3701 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3702 | 3702 | return $this->save(); |
3703 | 3703 | } |
3704 | 3704 | |
3705 | 3705 | // Set the completed date. |
3706 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3706 | + $this->set_date_completed(current_time('mysql')); |
|
3707 | 3707 | |
3708 | 3708 | // Set the new status. |
3709 | - if ( $this->is_renewal() ) { |
|
3709 | + if ($this->is_renewal()) { |
|
3710 | 3710 | |
3711 | 3711 | $_note = sprintf( |
3712 | - __( 'Renewed via %s', 'invoicing' ), |
|
3713 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3712 | + __('Renewed via %s', 'invoicing'), |
|
3713 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3714 | 3714 | ); |
3715 | 3715 | |
3716 | - if ( 'none' == $this->get_gateway() ) { |
|
3716 | + if ('none' == $this->get_gateway()) { |
|
3717 | 3717 | $_note = $note; |
3718 | 3718 | } |
3719 | 3719 | |
3720 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3720 | + $this->set_status('wpi-renewal', $_note); |
|
3721 | 3721 | |
3722 | 3722 | } else { |
3723 | 3723 | |
3724 | 3724 | $_note = sprintf( |
3725 | - __( 'Paid via %s', 'invoicing' ), |
|
3726 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3725 | + __('Paid via %s', 'invoicing'), |
|
3726 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3727 | 3727 | ); |
3728 | 3728 | |
3729 | - if ( 'none' == $this->get_gateway() ) { |
|
3729 | + if ('none' == $this->get_gateway()) { |
|
3730 | 3730 | $_note = $note; |
3731 | 3731 | } |
3732 | 3732 | |
3733 | - $this->set_status( 'publish',$_note ); |
|
3733 | + $this->set_status('publish', $_note); |
|
3734 | 3734 | |
3735 | 3735 | } |
3736 | 3736 | |
3737 | 3737 | // Set checkout mode. |
3738 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3739 | - $this->set_mode( $mode ); |
|
3738 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3739 | + $this->set_mode($mode); |
|
3740 | 3740 | |
3741 | 3741 | // Save the invoice. |
3742 | 3742 | $this->save(); |
@@ -3762,9 +3762,9 @@ discard block |
||
3762 | 3762 | * Clears the subscription's cache. |
3763 | 3763 | */ |
3764 | 3764 | public function clear_cache() { |
3765 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3766 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3767 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3765 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3766 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3767 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3768 | 3768 | } |
3769 | 3769 | |
3770 | 3770 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * GetPaid_Invoice_Data_Store class file. |
5 | 5 | * |
6 | 6 | */ |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -108,61 +108,61 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param WPInv_Invoice $invoice Invoice object. |
110 | 110 | */ |
111 | - public function create( &$invoice ) { |
|
112 | - $invoice->set_version( WPINV_VERSION ); |
|
113 | - $invoice->set_date_created( current_time('mysql') ); |
|
111 | + public function create(&$invoice) { |
|
112 | + $invoice->set_version(WPINV_VERSION); |
|
113 | + $invoice->set_date_created(current_time('mysql')); |
|
114 | 114 | |
115 | 115 | // Create a new post. |
116 | 116 | $id = wp_insert_post( |
117 | 117 | apply_filters( |
118 | 118 | 'getpaid_new_invoice_data', |
119 | 119 | array( |
120 | - 'post_date' => $invoice->get_date_created( 'edit' ), |
|
121 | - 'post_type' => $invoice->get_post_type( 'edit' ), |
|
122 | - 'post_status' => $this->get_post_status( $invoice ), |
|
120 | + 'post_date' => $invoice->get_date_created('edit'), |
|
121 | + 'post_type' => $invoice->get_post_type('edit'), |
|
122 | + 'post_status' => $this->get_post_status($invoice), |
|
123 | 123 | 'ping_status' => 'closed', |
124 | - 'post_author' => $invoice->get_user_id( 'edit' ), |
|
125 | - 'post_title' => $invoice->get_title( 'edit' ), |
|
126 | - 'post_excerpt' => $invoice->get_description( 'edit' ), |
|
127 | - 'post_parent' => $invoice->get_parent_id( 'edit' ), |
|
124 | + 'post_author' => $invoice->get_user_id('edit'), |
|
125 | + 'post_title' => $invoice->get_title('edit'), |
|
126 | + 'post_excerpt' => $invoice->get_description('edit'), |
|
127 | + 'post_parent' => $invoice->get_parent_id('edit'), |
|
128 | 128 | ) |
129 | 129 | ), |
130 | 130 | true |
131 | 131 | ); |
132 | 132 | |
133 | - if ( $id && ! is_wp_error( $id ) ) { |
|
133 | + if ($id && !is_wp_error($id)) { |
|
134 | 134 | |
135 | 135 | // Update the new id and regenerate a title. |
136 | - $invoice->set_id( $id ); |
|
136 | + $invoice->set_id($id); |
|
137 | 137 | |
138 | 138 | $invoice->maybe_set_number(); |
139 | 139 | |
140 | 140 | wp_update_post( |
141 | 141 | array( |
142 | 142 | 'ID' => $invoice->get_id(), |
143 | - 'post_title' => $invoice->get_number( 'edit' ), |
|
144 | - 'post_name' => $invoice->get_path( 'edit' ) |
|
143 | + 'post_title' => $invoice->get_number('edit'), |
|
144 | + 'post_name' => $invoice->get_path('edit') |
|
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Save special fields and items. |
149 | - $this->save_special_fields( $invoice ); |
|
150 | - $this->save_items( $invoice ); |
|
149 | + $this->save_special_fields($invoice); |
|
150 | + $this->save_items($invoice); |
|
151 | 151 | |
152 | 152 | // Update meta data. |
153 | - $this->update_post_meta( $invoice ); |
|
153 | + $this->update_post_meta($invoice); |
|
154 | 154 | $invoice->save_meta_data(); |
155 | 155 | |
156 | 156 | // Apply changes. |
157 | 157 | $invoice->apply_changes(); |
158 | - $this->clear_caches( $invoice ); |
|
158 | + $this->clear_caches($invoice); |
|
159 | 159 | |
160 | 160 | // Fires after a new invoice is created. |
161 | - do_action( 'getpaid_new_invoice', $invoice ); |
|
161 | + do_action('getpaid_new_invoice', $invoice); |
|
162 | 162 | return true; |
163 | 163 | } |
164 | 164 | |
165 | - if ( is_wp_error( $id ) ) { |
|
165 | + if (is_wp_error($id)) { |
|
166 | 166 | $invoice->last_error = $id->get_error_message(); |
167 | 167 | } |
168 | 168 | |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * @param WPInv_Invoice $invoice Invoice object. |
176 | 176 | * |
177 | 177 | */ |
178 | - public function read( &$invoice ) { |
|
178 | + public function read(&$invoice) { |
|
179 | 179 | |
180 | 180 | $invoice->set_defaults(); |
181 | - $invoice_object = get_post( $invoice->get_id() ); |
|
181 | + $invoice_object = get_post($invoice->get_id()); |
|
182 | 182 | |
183 | - if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) { |
|
184 | - $invoice->last_error = __( 'Invalid invoice.', 'invoicing' ); |
|
185 | - $invoice->set_id( 0 ); |
|
183 | + if (!$invoice->get_id() || !$invoice_object || !getpaid_is_invoice_post_type($invoice_object->post_type)) { |
|
184 | + $invoice->last_error = __('Invalid invoice.', 'invoicing'); |
|
185 | + $invoice->set_id(0); |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | ) |
201 | 201 | ); |
202 | 202 | |
203 | - $invoice->set_type( $invoice_object->post_type ); |
|
203 | + $invoice->set_type($invoice_object->post_type); |
|
204 | 204 | |
205 | - $this->read_object_data( $invoice, $invoice_object ); |
|
206 | - $this->add_special_fields( $invoice ); |
|
207 | - $this->add_items( $invoice ); |
|
205 | + $this->read_object_data($invoice, $invoice_object); |
|
206 | + $this->add_special_fields($invoice); |
|
207 | + $this->add_items($invoice); |
|
208 | 208 | $invoice->read_meta_data(); |
209 | - $invoice->set_object_read( true ); |
|
210 | - do_action( 'getpaid_read_invoice', $invoice ); |
|
209 | + $invoice->set_object_read(true); |
|
210 | + do_action('getpaid_read_invoice', $invoice); |
|
211 | 211 | |
212 | 212 | } |
213 | 213 | |
@@ -216,35 +216,35 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param WPInv_Invoice $invoice Invoice object. |
218 | 218 | */ |
219 | - public function update( &$invoice ) { |
|
219 | + public function update(&$invoice) { |
|
220 | 220 | $invoice->save_meta_data(); |
221 | - $invoice->set_version( WPINV_VERSION ); |
|
221 | + $invoice->set_version(WPINV_VERSION); |
|
222 | 222 | |
223 | - if ( null === $invoice->get_date_created( 'edit' ) ) { |
|
224 | - $invoice->set_date_created( current_time('mysql') ); |
|
223 | + if (null === $invoice->get_date_created('edit')) { |
|
224 | + $invoice->set_date_created(current_time('mysql')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Ensure both the key and number are set. |
228 | 228 | $invoice->get_path(); |
229 | 229 | |
230 | 230 | // Grab the current status so we can compare. |
231 | - $previous_status = get_post_status( $invoice->get_id() ); |
|
231 | + $previous_status = get_post_status($invoice->get_id()); |
|
232 | 232 | |
233 | 233 | $changes = $invoice->get_changes(); |
234 | 234 | |
235 | 235 | // Only update the post when the post data changes. |
236 | - if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) { |
|
236 | + if (array_intersect(array('date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path'), array_keys($changes))) { |
|
237 | 237 | $post_data = array( |
238 | - 'post_date' => $invoice->get_date_created( 'edit' ), |
|
239 | - 'post_date_gmt' => $invoice->get_date_created_gmt( 'edit' ), |
|
240 | - 'post_status' => $invoice->get_status( 'edit' ), |
|
241 | - 'post_title' => $invoice->get_name( 'edit' ), |
|
242 | - 'post_author' => $invoice->get_user_id( 'edit' ), |
|
243 | - 'post_modified' => $invoice->get_date_modified( 'edit' ), |
|
244 | - 'post_excerpt' => $invoice->get_description( 'edit' ), |
|
245 | - 'post_parent' => $invoice->get_parent_id( 'edit' ), |
|
246 | - 'post_name' => $invoice->get_path( 'edit' ), |
|
247 | - 'post_type' => $invoice->get_post_type( 'edit' ), |
|
238 | + 'post_date' => $invoice->get_date_created('edit'), |
|
239 | + 'post_date_gmt' => $invoice->get_date_created_gmt('edit'), |
|
240 | + 'post_status' => $invoice->get_status('edit'), |
|
241 | + 'post_title' => $invoice->get_name('edit'), |
|
242 | + 'post_author' => $invoice->get_user_id('edit'), |
|
243 | + 'post_modified' => $invoice->get_date_modified('edit'), |
|
244 | + 'post_excerpt' => $invoice->get_description('edit'), |
|
245 | + 'post_parent' => $invoice->get_parent_id('edit'), |
|
246 | + 'post_name' => $invoice->get_path('edit'), |
|
247 | + 'post_type' => $invoice->get_post_type('edit'), |
|
248 | 248 | ); |
249 | 249 | |
250 | 250 | /** |
@@ -255,35 +255,35 @@ discard block |
||
255 | 255 | * This ensures hooks are fired by either WP itself (admin screen save), |
256 | 256 | * or an update purely from CRUD. |
257 | 257 | */ |
258 | - if ( doing_action( 'save_post' ) ) { |
|
259 | - $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) ); |
|
260 | - clean_post_cache( $invoice->get_id() ); |
|
258 | + if (doing_action('save_post')) { |
|
259 | + $GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $invoice->get_id())); |
|
260 | + clean_post_cache($invoice->get_id()); |
|
261 | 261 | } else { |
262 | - wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) ); |
|
262 | + wp_update_post(array_merge(array('ID' => $invoice->get_id()), $post_data)); |
|
263 | 263 | } |
264 | - $invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
264 | + $invoice->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Update meta data. |
268 | - $this->update_post_meta( $invoice ); |
|
268 | + $this->update_post_meta($invoice); |
|
269 | 269 | |
270 | 270 | // Save special fields and items. |
271 | - $this->save_special_fields( $invoice ); |
|
272 | - $this->save_items( $invoice ); |
|
271 | + $this->save_special_fields($invoice); |
|
272 | + $this->save_items($invoice); |
|
273 | 273 | |
274 | 274 | // Apply the changes. |
275 | 275 | $invoice->apply_changes(); |
276 | 276 | |
277 | 277 | // Clear caches. |
278 | - $this->clear_caches( $invoice ); |
|
278 | + $this->clear_caches($invoice); |
|
279 | 279 | |
280 | 280 | // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
281 | - $new_status = $invoice->get_status( 'edit' ); |
|
281 | + $new_status = $invoice->get_status('edit'); |
|
282 | 282 | |
283 | - if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
284 | - do_action( 'getpaid_new_invoice', $invoice ); |
|
283 | + if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) { |
|
284 | + do_action('getpaid_new_invoice', $invoice); |
|
285 | 285 | } else { |
286 | - do_action( 'getpaid_update_invoice', $invoice ); |
|
286 | + do_action('getpaid_update_invoice', $invoice); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | } |
@@ -299,45 +299,45 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param WPInv_Invoice $invoice Invoice object. |
301 | 301 | */ |
302 | - public function add_special_fields( &$invoice ) { |
|
302 | + public function add_special_fields(&$invoice) { |
|
303 | 303 | global $wpdb; |
304 | 304 | |
305 | 305 | // Maybe retrieve from the cache. |
306 | - $data = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
306 | + $data = wp_cache_get($invoice->get_id(), 'getpaid_invoice_special_fields'); |
|
307 | 307 | |
308 | 308 | // If not found, retrieve from the db. |
309 | - if ( false === $data ) { |
|
310 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
309 | + if (false === $data) { |
|
310 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
311 | 311 | |
312 | 312 | $data = $wpdb->get_row( |
313 | - $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ), |
|
313 | + $wpdb->prepare("SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id()), |
|
314 | 314 | ARRAY_A |
315 | 315 | ); |
316 | 316 | |
317 | 317 | // Update the cache with our data |
318 | - wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' ); |
|
318 | + wp_cache_set($invoice->get_id(), $data, 'getpaid_invoice_special_fields'); |
|
319 | 319 | |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Abort if the data does not exist. |
323 | - if ( empty( $data ) ) { |
|
324 | - $invoice->set_object_read( true ); |
|
325 | - $invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) ); |
|
323 | + if (empty($data)) { |
|
324 | + $invoice->set_object_read(true); |
|
325 | + $invoice->set_props(wpinv_get_user_address($invoice->get_user_id())); |
|
326 | 326 | return; |
327 | 327 | } |
328 | 328 | |
329 | 329 | $props = array(); |
330 | 330 | |
331 | - foreach ( $this->database_fields_to_props as $db_field => $prop ) { |
|
331 | + foreach ($this->database_fields_to_props as $db_field => $prop) { |
|
332 | 332 | |
333 | - if ( $db_field == 'post_id' ) { |
|
333 | + if ($db_field == 'post_id') { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | 336 | |
337 | - $props[ $prop ] = $data[ $db_field ]; |
|
337 | + $props[$prop] = $data[$db_field]; |
|
338 | 338 | } |
339 | 339 | |
340 | - $invoice->set_props( $props ); |
|
340 | + $invoice->set_props($props); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param WPInv_Invoice $invoice The Invoice object. |
349 | 349 | * @return array A mapping of field keys => prop names, filtered by ones that should be updated. |
350 | 350 | */ |
351 | - protected function get_special_fields_to_update( $invoice ) { |
|
351 | + protected function get_special_fields_to_update($invoice) { |
|
352 | 352 | $fields_to_update = array(); |
353 | - $changed_props = $invoice->get_changes(); |
|
353 | + $changed_props = $invoice->get_changes(); |
|
354 | 354 | |
355 | 355 | // Props should be updated if they are a part of the $changed array or don't exist yet. |
356 | - foreach ( $this->database_fields_to_props as $database_field => $prop ) { |
|
357 | - if ( array_key_exists( $prop, $changed_props ) ) { |
|
358 | - $fields_to_update[ $database_field ] = $prop; |
|
356 | + foreach ($this->database_fields_to_props as $database_field => $prop) { |
|
357 | + if (array_key_exists($prop, $changed_props)) { |
|
358 | + $fields_to_update[$database_field] = $prop; |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -368,25 +368,25 @@ discard block |
||
368 | 368 | * @param WPInv_Invoice $invoice WPInv_Invoice object. |
369 | 369 | * @since 1.0.19 |
370 | 370 | */ |
371 | - protected function update_special_fields( &$invoice ) { |
|
371 | + protected function update_special_fields(&$invoice) { |
|
372 | 372 | global $wpdb; |
373 | 373 | |
374 | 374 | $updated_props = array(); |
375 | - $fields_to_update = $this->get_special_fields_to_update( $invoice ); |
|
375 | + $fields_to_update = $this->get_special_fields_to_update($invoice); |
|
376 | 376 | |
377 | - foreach ( $fields_to_update as $database_field => $prop ) { |
|
378 | - $value = $invoice->{"get_$prop"}( 'edit' ); |
|
379 | - $value = is_string( $value ) ? wp_slash( $value ) : $value; |
|
380 | - $value = is_bool( $value ) ? ( int ) $value : $value; |
|
381 | - $updated_props[ $database_field ] = maybe_serialize( $value ); |
|
377 | + foreach ($fields_to_update as $database_field => $prop) { |
|
378 | + $value = $invoice->{"get_$prop"}('edit'); |
|
379 | + $value = is_string($value) ? wp_slash($value) : $value; |
|
380 | + $value = is_bool($value) ? (int) $value : $value; |
|
381 | + $updated_props[$database_field] = maybe_serialize($value); |
|
382 | 382 | } |
383 | 383 | |
384 | - if ( ! empty( $updated_props ) ) { |
|
384 | + if (!empty($updated_props)) { |
|
385 | 385 | |
386 | 386 | $table = $wpdb->prefix . 'getpaid_invoices'; |
387 | - $wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) ); |
|
388 | - wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
389 | - do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props ); |
|
387 | + $wpdb->update($table, $updated_props, array('post_id' => $invoice->get_id())); |
|
388 | + wp_cache_delete($invoice->get_id(), 'getpaid_invoice_special_fields'); |
|
389 | + do_action("getpaid_invoice_update_database_fields", $invoice, $updated_props); |
|
390 | 390 | |
391 | 391 | } |
392 | 392 | |
@@ -398,22 +398,22 @@ discard block |
||
398 | 398 | * @param WPInv_Invoice $invoice WPInv_Invoice object. |
399 | 399 | * @since 1.0.19 |
400 | 400 | */ |
401 | - protected function insert_special_fields( &$invoice ) { |
|
401 | + protected function insert_special_fields(&$invoice) { |
|
402 | 402 | global $wpdb; |
403 | 403 | |
404 | - $updated_props = array(); |
|
404 | + $updated_props = array(); |
|
405 | 405 | |
406 | - foreach ( $this->database_fields_to_props as $database_field => $prop ) { |
|
407 | - $value = $invoice->{"get_$prop"}( 'edit' ); |
|
408 | - $value = is_string( $value ) ? wp_slash( $value ) : $value; |
|
409 | - $value = is_bool( $value ) ? ( int ) $value : $value; |
|
410 | - $updated_props[ $database_field ] = maybe_serialize( $value ); |
|
406 | + foreach ($this->database_fields_to_props as $database_field => $prop) { |
|
407 | + $value = $invoice->{"get_$prop"}('edit'); |
|
408 | + $value = is_string($value) ? wp_slash($value) : $value; |
|
409 | + $value = is_bool($value) ? (int) $value : $value; |
|
410 | + $updated_props[$database_field] = maybe_serialize($value); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | $table = $wpdb->prefix . 'getpaid_invoices'; |
414 | - $wpdb->insert( $table, $updated_props ); |
|
415 | - wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
416 | - do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props ); |
|
414 | + $wpdb->insert($table, $updated_props); |
|
415 | + wp_cache_delete($invoice->get_id(), 'getpaid_invoice_special_fields'); |
|
416 | + do_action("getpaid_invoice_insert_database_fields", $invoice, $updated_props); |
|
417 | 417 | |
418 | 418 | } |
419 | 419 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @param WPInv_Invoice $invoice Invoice object. |
424 | 424 | */ |
425 | - public function save_special_fields( & $invoice ) { |
|
425 | + public function save_special_fields(& $invoice) { |
|
426 | 426 | global $wpdb; |
427 | 427 | |
428 | 428 | // The invoices table. |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | $id = (int) $invoice->get_id(); |
431 | 431 | $invoice->maybe_set_key(); |
432 | 432 | |
433 | - if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) { |
|
433 | + if ($wpdb->get_var("SELECT `post_id` FROM $table WHERE `post_id`= $id")) { |
|
434 | 434 | |
435 | - $this->update_special_fields( $invoice ); |
|
435 | + $this->update_special_fields($invoice); |
|
436 | 436 | |
437 | 437 | } else { |
438 | 438 | |
439 | - $this->insert_special_fields( $invoice ); |
|
439 | + $this->insert_special_fields($invoice); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | |
@@ -447,43 +447,43 @@ discard block |
||
447 | 447 | * |
448 | 448 | * @param WPInv_Invoice $invoice Invoice object. |
449 | 449 | */ |
450 | - public function add_items( &$invoice ) { |
|
450 | + public function add_items(&$invoice) { |
|
451 | 451 | global $wpdb; |
452 | 452 | |
453 | 453 | // Maybe retrieve from the cache. |
454 | - $items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' ); |
|
454 | + $items = wp_cache_get($invoice->get_id(), 'getpaid_invoice_cart_details'); |
|
455 | 455 | |
456 | 456 | // If not found, retrieve from the db. |
457 | - if ( false === $items ) { |
|
458 | - $table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
457 | + if (false === $items) { |
|
458 | + $table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
459 | 459 | |
460 | 460 | $items = $wpdb->get_results( |
461 | - $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() ) |
|
461 | + $wpdb->prepare("SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id()) |
|
462 | 462 | ); |
463 | 463 | |
464 | 464 | // Update the cache with our data |
465 | - wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' ); |
|
465 | + wp_cache_set($invoice->get_id(), $items, 'getpaid_invoice_cart_details'); |
|
466 | 466 | |
467 | 467 | } |
468 | 468 | |
469 | 469 | // Abort if no items found. |
470 | - if ( empty( $items ) ) { |
|
470 | + if (empty($items)) { |
|
471 | 471 | return; |
472 | 472 | } |
473 | 473 | |
474 | - foreach ( $items as $item_data ) { |
|
475 | - $item = new GetPaid_Form_Item( $item_data->item_id ); |
|
474 | + foreach ($items as $item_data) { |
|
475 | + $item = new GetPaid_Form_Item($item_data->item_id); |
|
476 | 476 | |
477 | 477 | // Set item data. |
478 | - $item->item_tax = wpinv_sanitize_amount( $item_data->tax ); |
|
479 | - $item->item_discount = wpinv_sanitize_amount( $item_data->discount ); |
|
480 | - $item->set_name( $item_data->item_name ); |
|
481 | - $item->set_description( $item_data->item_description ); |
|
482 | - $item->set_price( $item_data->item_price ); |
|
483 | - $item->set_quantity( $item_data->quantity ); |
|
484 | - $item->set_item_meta( $item_data->meta ); |
|
485 | - |
|
486 | - $invoice->add_item( $item ); |
|
478 | + $item->item_tax = wpinv_sanitize_amount($item_data->tax); |
|
479 | + $item->item_discount = wpinv_sanitize_amount($item_data->discount); |
|
480 | + $item->set_name($item_data->item_name); |
|
481 | + $item->set_description($item_data->item_description); |
|
482 | + $item->set_price($item_data->item_price); |
|
483 | + $item->set_quantity($item_data->quantity); |
|
484 | + $item->set_item_meta($item_data->meta); |
|
485 | + |
|
486 | + $invoice->add_item($item); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | } |
@@ -493,20 +493,20 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @param WPInv_Invoice $invoice Invoice object. |
495 | 495 | */ |
496 | - public function save_items( $invoice ) { |
|
496 | + public function save_items($invoice) { |
|
497 | 497 | |
498 | 498 | // Delete previously existing items. |
499 | - $this->delete_items( $invoice ); |
|
499 | + $this->delete_items($invoice); |
|
500 | 500 | |
501 | - $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
501 | + $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
502 | 502 | |
503 | - foreach ( $invoice->get_cart_details() as $item_data ) { |
|
504 | - $item_data = array_map( 'maybe_serialize', $item_data ); |
|
505 | - $GLOBALS['wpdb']->insert( $table, $item_data ); |
|
503 | + foreach ($invoice->get_cart_details() as $item_data) { |
|
504 | + $item_data = array_map('maybe_serialize', $item_data); |
|
505 | + $GLOBALS['wpdb']->insert($table, $item_data); |
|
506 | 506 | } |
507 | 507 | |
508 | - wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' ); |
|
509 | - do_action( "getpaid_invoice_save_items", $invoice ); |
|
508 | + wp_cache_delete($invoice->get_id(), 'getpaid_invoice_cart_details'); |
|
509 | + do_action("getpaid_invoice_save_items", $invoice); |
|
510 | 510 | |
511 | 511 | } |
512 | 512 | |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @param WPInv_Invoice $invoice Invoice object. |
517 | 517 | */ |
518 | - public function delete_items( $invoice ) { |
|
519 | - $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
520 | - return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) ); |
|
518 | + public function delete_items($invoice) { |
|
519 | + $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
520 | + return $GLOBALS['wpdb']->delete($table, array('post_id' => $invoice->get_id())); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -525,9 +525,9 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @param WPInv_Invoice $invoice Invoice object. |
527 | 527 | */ |
528 | - public function delete_special_fields( $invoice ) { |
|
529 | - $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoices'; |
|
530 | - return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) ); |
|
528 | + public function delete_special_fields($invoice) { |
|
529 | + $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoices'; |
|
530 | + return $GLOBALS['wpdb']->delete($table, array('post_id' => $invoice->get_id())); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | * @param WPInv_Invoice $object GetPaid_Data object. |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - protected function get_post_status( $object ) { |
|
542 | - $object_status = $object->get_status( 'edit' ); |
|
541 | + protected function get_post_status($object) { |
|
542 | + $object_status = $object->get_status('edit'); |
|
543 | 543 | |
544 | - if ( ! $object_status ) { |
|
544 | + if (!$object_status) { |
|
545 | 545 | $object_status = $object->get_default_status(); |
546 | 546 | } |
547 | 547 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class handles subscription notificaiton emails. |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function init_hooks() { |
47 | 47 | |
48 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | - foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
48 | + add_filter('getpaid_get_email_merge_tags', array($this, 'subscription_merge_tags'), 10, 2); |
|
49 | + foreach ($this->subscription_actions as $hook => $email_type) { |
|
50 | 50 | |
51 | - $email = new GetPaid_Notification_Email( $email_type ); |
|
51 | + $email = new GetPaid_Notification_Email($email_type); |
|
52 | 52 | |
53 | - if ( ! $email->is_active() ) { |
|
53 | + if (!$email->is_active()) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - if ( method_exists( $this, $email_type ) ) { |
|
58 | - add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
57 | + if (method_exists($this, $email_type)) { |
|
58 | + add_action($hook, array($this, $email_type), 100, 2); |
|
59 | 59 | continue; |
60 | 60 | } |
61 | 61 | |
62 | - do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook ); |
|
62 | + do_action('getpaid_subscription_notification_email_register_hook', $email_type, $hook); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | * @param array $merge_tags |
72 | 72 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
73 | 73 | */ |
74 | - public function subscription_merge_tags( $merge_tags, $object ) { |
|
74 | + public function subscription_merge_tags($merge_tags, $object) { |
|
75 | 75 | |
76 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
76 | + if (is_a($object, 'WPInv_Subscription')) { |
|
77 | 77 | $merge_tags = array_merge( |
78 | 78 | $merge_tags, |
79 | - $this->get_subscription_merge_tags( $object ) |
|
79 | + $this->get_subscription_merge_tags($object) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | * @param WPInv_Subscription $subscription |
91 | 91 | * @return array |
92 | 92 | */ |
93 | - public function get_subscription_merge_tags( $subscription ) { |
|
93 | + public function get_subscription_merge_tags($subscription) { |
|
94 | 94 | |
95 | 95 | // Abort if it does not exist. |
96 | - if ( ! $subscription->get_id() ) { |
|
96 | + if (!$subscription->get_id()) { |
|
97 | 97 | return array(); |
98 | 98 | } |
99 | 99 | |
100 | - $invoice = $subscription->get_parent_invoice(); |
|
100 | + $invoice = $subscription->get_parent_invoice(); |
|
101 | 101 | return array( |
102 | - '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | - '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | - '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | - '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | - '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | - '{subscription_recurring_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
108 | - '{subscription_initial_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $invoice->get_currency() ), |
|
109 | - '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
102 | + '{subscription_renewal_date}' => getpaid_format_date_value($subscription->get_next_renewal_date(), __('Never', 'invoicing')), |
|
103 | + '{subscription_created}' => getpaid_format_date_value($subscription->get_date_created()), |
|
104 | + '{subscription_status}' => sanitize_text_field($subscription->get_status_label()), |
|
105 | + '{subscription_profile_id}' => sanitize_text_field($subscription->get_profile_id()), |
|
106 | + '{subscription_id}' => absint($subscription->get_id()), |
|
107 | + '{subscription_recurring_amount}' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
108 | + '{subscription_initial_amount}' => wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $invoice->get_currency()), |
|
109 | + '{subscription_recurring_period}' => getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''), |
|
110 | 110 | '{subscription_bill_times}' => $subscription->get_bill_times(), |
111 | - '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
111 | + '{subscription_url}' => esc_url($subscription->get_view_url()), |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - public function should_send_notification( $invoice ) { |
|
122 | + public function should_send_notification($invoice) { |
|
123 | 123 | return 0 != $invoice->get_id(); |
124 | 124 | } |
125 | 125 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * @param WPInv_Invoice $invoice |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function get_recipients( $invoice ) { |
|
133 | - $recipients = array( $invoice->get_email() ); |
|
132 | + public function get_recipients($invoice) { |
|
133 | + $recipients = array($invoice->get_email()); |
|
134 | 134 | |
135 | 135 | $cc = $invoice->get_email_cc(); |
136 | 136 | |
137 | - if ( ! empty( $cc ) ) { |
|
138 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
137 | + if (!empty($cc)) { |
|
138 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
139 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $recipients; |
@@ -150,45 +150,45 @@ discard block |
||
150 | 150 | * @param string $type |
151 | 151 | * @param array $extra_args Extra template args. |
152 | 152 | */ |
153 | - public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
153 | + public function send_email($subscription, $email, $type, $extra_args = array()) { |
|
154 | 154 | |
155 | 155 | // Abort in case the parent invoice does not exist. |
156 | 156 | $invoice = $subscription->get_parent_invoice(); |
157 | - if ( ! $this->should_send_notification( $invoice ) ) { |
|
157 | + if (!$this->should_send_notification($invoice)) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
161 | + do_action('getpaid_before_send_subscription_notification', $type, $subscription, $email); |
|
162 | 162 | |
163 | - $recipients = $this->get_recipients( $invoice ); |
|
163 | + $recipients = $this->get_recipients($invoice); |
|
164 | 164 | $mailer = new GetPaid_Notification_Email_Sender(); |
165 | 165 | $merge_tags = $email->get_merge_tags(); |
166 | - $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | - $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
166 | + $content = $email->get_content($merge_tags, $extra_args); |
|
167 | + $subject = $email->add_merge_tags($email->get_subject(), $merge_tags); |
|
168 | 168 | $attachments = $email->get_attachments(); |
169 | 169 | |
170 | 170 | $result = $mailer->send( |
171 | - apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | + apply_filters('getpaid_subscription_email_recipients', wpinv_parse_list($recipients), $email), |
|
172 | 172 | $subject, |
173 | 173 | $content, |
174 | 174 | $attachments |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Maybe send a copy to the admin. |
178 | - if ( $email->include_admin_bcc() ) { |
|
178 | + if ($email->include_admin_bcc()) { |
|
179 | 179 | $mailer->send( |
180 | 180 | wpinv_get_admin_email(), |
181 | - $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
181 | + $subject . __(' - ADMIN BCC COPY', 'invoicing'), |
|
182 | 182 | $content, |
183 | 183 | $attachments |
184 | 184 | ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( ! $result ) { |
|
188 | - $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
187 | + if (!$result) { |
|
188 | + $subscription->get_parent_invoice()->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
189 | 189 | } |
190 | 190 | |
191 | - do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
191 | + do_action('getpaid_after_send_subscription_notification', $type, $subscription, $email); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param WPInv_Subscription $subscription |
199 | 199 | */ |
200 | - public function subscription_trial( $subscription ) { |
|
200 | + public function subscription_trial($subscription) { |
|
201 | 201 | |
202 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
202 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
203 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
204 | 204 | |
205 | 205 | } |
206 | 206 | |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @param WPInv_Subscription $subscription |
211 | 211 | */ |
212 | - public function subscription_cancelled( $subscription ) { |
|
212 | + public function subscription_cancelled($subscription) { |
|
213 | 213 | |
214 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
214 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
215 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param WPInv_Subscription $subscription |
223 | 223 | */ |
224 | - public function subscription_expired( $subscription ) { |
|
224 | + public function subscription_expired($subscription) { |
|
225 | 225 | |
226 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
226 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
227 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param WPInv_Subscription $subscription |
235 | 235 | */ |
236 | - public function subscription_complete( $subscription ) { |
|
236 | + public function subscription_complete($subscription) { |
|
237 | 237 | |
238 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
238 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
239 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function renewal_reminder() { |
248 | 248 | |
249 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
249 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
250 | 250 | |
251 | 251 | // Fetch reminder days. |
252 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
252 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
253 | 253 | |
254 | 254 | // Abort if non is set. |
255 | - if ( empty( $reminder_days ) ) { |
|
255 | + if (empty($reminder_days)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | // Fetch matching subscriptions. |
260 | - $args = array( |
|
260 | + $args = array( |
|
261 | 261 | 'number' => -1, |
262 | 262 | 'count_total' => false, |
263 | 263 | 'status' => 'trialling active', |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | ), |
267 | 267 | ); |
268 | 268 | |
269 | - foreach ( $reminder_days as $days ) { |
|
270 | - $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
269 | + foreach ($reminder_days as $days) { |
|
270 | + $date = date_parse(date('Y-m-d', strtotime("+$days days", current_time('timestamp')))); |
|
271 | 271 | |
272 | 272 | $args['date_expires_query'][] = array( |
273 | 273 | 'year' => $date['year'], |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
280 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
281 | 281 | |
282 | - foreach ( $subscriptions as $subscription ) { |
|
282 | + foreach ($subscriptions as $subscription) { |
|
283 | 283 | |
284 | 284 | // Skip packages. |
285 | - if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
285 | + if (get_post_meta($subscription->get_product_id(), '_wpinv_type', true) != 'package') { |
|
286 | 286 | $email->object = $subscription; |
287 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
287 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | /** |
9 | 9 | * Main Subscriptions class. |
10 | 10 | * |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Class constructor. |
16 | 16 | */ |
17 | - public function __construct(){ |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | // Fire gateway specific hooks when a subscription changes. |
20 | - add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 ); |
|
20 | + add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3); |
|
21 | 21 | |
22 | 22 | // De-activate a subscription whenever the invoice changes payment statuses. |
23 | - add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
24 | - add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
25 | - add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
26 | - add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
23 | + add_action('getpaid_invoice_status_wpi-refunded', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
24 | + add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
25 | + add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
26 | + add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
27 | 27 | |
28 | 28 | // Handles subscription cancelations. |
29 | - add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) ); |
|
29 | + add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription')); |
|
30 | 30 | |
31 | 31 | // Create a subscription whenever an invoice is created, (and update it when it is updated). |
32 | - add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ) ); |
|
33 | - add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ) ); |
|
32 | + add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription')); |
|
33 | + add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription')); |
|
34 | 34 | |
35 | 35 | // Handles admin subscription update actions. |
36 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
37 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
38 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) ); |
|
36 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
37 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
38 | + add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription')); |
|
39 | 39 | |
40 | 40 | // Filter invoice item row actions. |
41 | - add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 ); |
|
41 | + add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | * @param WPInv_Invoice $invoice |
48 | 48 | * @return WPInv_Subscription|bool |
49 | 49 | */ |
50 | - public function get_invoice_subscription( $invoice ) { |
|
50 | + public function get_invoice_subscription($invoice) { |
|
51 | 51 | $subscription_id = $invoice->get_subscription_id(); |
52 | 52 | |
53 | 53 | // Fallback to the parent invoice if the child invoice has no subscription id. |
54 | - if ( empty( $subscription_id && $invoice->is_renewal() ) ) { |
|
54 | + if (empty($subscription_id && $invoice->is_renewal())) { |
|
55 | 55 | $subscription_id = $invoice->get_parent_payment()->get_subscription_id(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Fetch the subscription. |
59 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
59 | + $subscription = new WPInv_Subscription($subscription_id); |
|
60 | 60 | |
61 | 61 | // Return subscription or use a fallback for backwards compatibility. |
62 | - return $subscription->get_id() ? $subscription : wpinv_get_subscription( $invoice ); |
|
62 | + return $subscription->get_id() ? $subscription : wpinv_get_subscription($invoice); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Invoice $invoice |
69 | 69 | */ |
70 | - public function maybe_deactivate_invoice_subscription( $invoice ) { |
|
70 | + public function maybe_deactivate_invoice_subscription($invoice) { |
|
71 | 71 | |
72 | - $subscription = $this->get_invoice_subscription( $invoice ); |
|
72 | + $subscription = $this->get_invoice_subscription($invoice); |
|
73 | 73 | |
74 | 74 | // Abort if the subscription is missing or not active. |
75 | - if ( empty( $subscription ) || ! $subscription->is_active() ) { |
|
75 | + if (empty($subscription) || !$subscription->is_active()) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - $subscription->set_status( 'pending' ); |
|
79 | + $subscription->set_status('pending'); |
|
80 | 80 | $subscription->save(); |
81 | 81 | |
82 | 82 | } |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * @param string $from |
89 | 89 | * @param string $to |
90 | 90 | */ |
91 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
91 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
92 | 92 | |
93 | 93 | $gateway = $subscription->get_gateway(); |
94 | 94 | |
95 | - if ( ! empty( $gateway ) ) { |
|
96 | - $gateway = sanitize_key( $gateway ); |
|
97 | - $from = sanitize_key( $from ); |
|
98 | - $to = sanitize_key( $to ); |
|
99 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
95 | + if (!empty($gateway)) { |
|
96 | + $gateway = sanitize_key($gateway); |
|
97 | + $from = sanitize_key($from); |
|
98 | + $to = sanitize_key($to); |
|
99 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | } |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @deprecated |
110 | 110 | * @return mixed|string|void |
111 | 111 | */ |
112 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
113 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
112 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
113 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | * @since 1.0.0 |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - public function user_cancel_single_subscription( $data ) { |
|
123 | + public function user_cancel_single_subscription($data) { |
|
124 | 124 | |
125 | 125 | // Ensure there is a subscription to cancel. |
126 | - if ( empty( $data['subscription'] ) ) { |
|
126 | + if (empty($data['subscription'])) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
130 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
131 | 131 | |
132 | 132 | // Ensure that it exists and that it belongs to the current user. |
133 | - if ( ! $subscription->get_id() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
134 | - wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) ); |
|
133 | + if (!$subscription->get_id() || $subscription->get_customer_id() != get_current_user_id()) { |
|
134 | + wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing')); |
|
135 | 135 | |
136 | 136 | // Can it be cancelled. |
137 | - } else if ( ! $subscription->can_cancel() ) { |
|
138 | - wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) ); |
|
137 | + } else if (!$subscription->can_cancel()) { |
|
138 | + wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing')); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | // Cancel it. |
142 | 142 | } else { |
143 | 143 | |
144 | 144 | $subscription->cancel(); |
145 | - wpinv_set_error( 'cancelled', __( 'This subscription has been cancelled.', 'invoicing' ), 'info' ); |
|
145 | + wpinv_set_error('cancelled', __('This subscription has been cancelled.', 'invoicing'), 'info'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $redirect = add_query_arg( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ); |
154 | 154 | |
155 | - wp_safe_redirect( esc_url( $redirect ) ); |
|
155 | + wp_safe_redirect(esc_url($redirect)); |
|
156 | 156 | exit; |
157 | 157 | |
158 | 158 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * @param WPInv_Invoice $invoice |
165 | 165 | * @since 1.0.0 |
166 | 166 | */ |
167 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
167 | + public function maybe_create_invoice_subscription($invoice) { |
|
168 | 168 | |
169 | 169 | // Abort if it is not recurring. |
170 | - if ( $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
170 | + if ($invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $subscription = new WPInv_Subscription(); |
175 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
175 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | |
@@ -183,25 +183,25 @@ discard block |
||
183 | 183 | * @param WPInv_Invoice $invoice |
184 | 184 | * @since 1.0.19 |
185 | 185 | */ |
186 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
186 | + public function maybe_update_invoice_subscription($invoice) { |
|
187 | 187 | |
188 | 188 | // Do not process renewals. |
189 | - if ( $invoice->is_renewal() ) { |
|
189 | + if ($invoice->is_renewal()) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // (Maybe) create a new subscription. |
194 | - $subscription = $this->get_invoice_subscription( $invoice ); |
|
195 | - if ( empty( $subscription ) ) { |
|
196 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
194 | + $subscription = $this->get_invoice_subscription($invoice); |
|
195 | + if (empty($subscription)) { |
|
196 | + return $this->maybe_create_invoice_subscription($invoice); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Abort if an invoice is paid and already has a subscription. |
200 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
200 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
204 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -213,55 +213,55 @@ discard block |
||
213 | 213 | * @param WPInv_Invoice $invoice |
214 | 214 | * @since 1.0.19 |
215 | 215 | */ |
216 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
216 | + public function update_invoice_subscription($subscription, $invoice) { |
|
217 | 217 | |
218 | 218 | // Delete the subscription if an invoice is free or nolonger recurring. |
219 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
219 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
220 | 220 | return $subscription->delete(); |
221 | 221 | } |
222 | 222 | |
223 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
224 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
225 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
226 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
227 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
228 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
223 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
224 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
225 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
226 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
227 | + $subscription->set_date_created(current_time('mysql')); |
|
228 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
229 | 229 | |
230 | 230 | // Get the recurring item and abort if it does not exist. |
231 | - $subscription_item = $invoice->get_recurring( true ); |
|
232 | - if ( ! $subscription_item->get_id() ) { |
|
231 | + $subscription_item = $invoice->get_recurring(true); |
|
232 | + if (!$subscription_item->get_id()) { |
|
233 | 233 | $invoice->set_subscription_id(0); |
234 | 234 | $invoice->save(); |
235 | 235 | return $subscription->delete(); |
236 | 236 | } |
237 | 237 | |
238 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
239 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
240 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
241 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
238 | + $subscription->set_product_id($subscription_item->get_id()); |
|
239 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
240 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
241 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
242 | 242 | |
243 | 243 | // Calculate the next renewal date. |
244 | - $period = $subscription_item->get_recurring_period( true ); |
|
244 | + $period = $subscription_item->get_recurring_period(true); |
|
245 | 245 | $interval = $subscription_item->get_recurring_interval(); |
246 | 246 | |
247 | 247 | // If the subscription item has a trial period... |
248 | - if ( $subscription_item->has_free_trial() ) { |
|
249 | - $period = $subscription_item->get_trial_period( true ); |
|
248 | + if ($subscription_item->has_free_trial()) { |
|
249 | + $period = $subscription_item->get_trial_period(true); |
|
250 | 250 | $interval = $subscription_item->get_trial_interval(); |
251 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
252 | - $subscription->set_status( 'trialling' ); |
|
251 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
252 | + $subscription->set_status('trialling'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
256 | - if ( $invoice->has_free_trial() ) { |
|
257 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
258 | - $subscription->set_status( 'trialling' ); |
|
256 | + if ($invoice->has_free_trial()) { |
|
257 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
258 | + $subscription->set_status('trialling'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Calculate the next renewal date. |
262 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
262 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
263 | 263 | |
264 | - $subscription->set_next_renewal_date( $expiration ); |
|
264 | + $subscription->set_next_renewal_date($expiration); |
|
265 | 265 | return $subscription->save(); |
266 | 266 | |
267 | 267 | } |
@@ -272,21 +272,21 @@ discard block |
||
272 | 272 | * @param array $data |
273 | 273 | * @since 1.0.19 |
274 | 274 | */ |
275 | - public function admin_update_single_subscription( $args ) { |
|
275 | + public function admin_update_single_subscription($args) { |
|
276 | 276 | |
277 | 277 | // Ensure the subscription exists and that a status has been given. |
278 | - if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) { |
|
278 | + if (empty($args['subscription_id']) || empty($args['subscription_status'])) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | 282 | // Retrieve the subscriptions. |
283 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
283 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
284 | 284 | |
285 | - if ( $subscription->get_id() ) { |
|
285 | + if ($subscription->get_id()) { |
|
286 | 286 | |
287 | - $subscription->set_status( $args['subscription_status'] ); |
|
287 | + $subscription->set_status($args['subscription_status']); |
|
288 | 288 | $subscription->save(); |
289 | - getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) ); |
|
289 | + getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing')); |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
@@ -298,27 +298,27 @@ discard block |
||
298 | 298 | * @param array $data |
299 | 299 | * @since 1.0.19 |
300 | 300 | */ |
301 | - public function admin_renew_single_subscription( $args ) { |
|
301 | + public function admin_renew_single_subscription($args) { |
|
302 | 302 | |
303 | 303 | // Ensure the subscription exists and that a status has been given. |
304 | - if ( empty( $args['id'] ) ) { |
|
304 | + if (empty($args['id'])) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
308 | 308 | // Retrieve the subscriptions. |
309 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
309 | + $subscription = new WPInv_Subscription($args['id']); |
|
310 | 310 | |
311 | - if ( $subscription->get_id() ) { |
|
311 | + if ($subscription->get_id()) { |
|
312 | 312 | |
313 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
313 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
314 | 314 | |
315 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
315 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
316 | 316 | |
317 | - if ( ! $subscription->add_payment( $args ) ) { |
|
318 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
317 | + if (!$subscription->add_payment($args)) { |
|
318 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
319 | 319 | } else { |
320 | 320 | $subscription->renew(); |
321 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
321 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | wp_safe_redirect( |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | * @param array $data |
342 | 342 | * @since 1.0.19 |
343 | 343 | */ |
344 | - public function admin_delete_single_subscription( $args ) { |
|
344 | + public function admin_delete_single_subscription($args) { |
|
345 | 345 | |
346 | 346 | // Ensure the subscription exists and that a status has been given. |
347 | - if ( empty( $args['id'] ) ) { |
|
347 | + if (empty($args['id'])) { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | 351 | // Retrieve the subscriptions. |
352 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
352 | + $subscription = new WPInv_Subscription($args['id']); |
|
353 | 353 | |
354 | - if ( $subscription->delete() ) { |
|
355 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
354 | + if ($subscription->delete()) { |
|
355 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
356 | 356 | } else { |
357 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
357 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $redirected = wp_safe_redirect( |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ) |
368 | 368 | ); |
369 | 369 | |
370 | - if ( $redirected ) { |
|
370 | + if ($redirected) { |
|
371 | 371 | exit; |
372 | 372 | } |
373 | 373 | |
@@ -380,10 +380,10 @@ discard block |
||
380 | 380 | * @param WPInv_Item $item |
381 | 381 | * @param WPInv_Invoice $invoice |
382 | 382 | */ |
383 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
383 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
384 | 384 | |
385 | 385 | // Fetch item subscription. |
386 | - $args = array( |
|
386 | + $args = array( |
|
387 | 387 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
388 | 388 | 'item_in' => $item->get_id(), |
389 | 389 | 'number' => 1, |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | 'fields' => 'id', |
392 | 392 | ); |
393 | 393 | |
394 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
394 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
395 | 395 | $subscription = $subscription->get_results(); |
396 | 396 | |
397 | 397 | // In case we found a match... |
398 | - if ( ! empty( $subscription ) ) { |
|
399 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
400 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'getpaid-license-manager' ) . '</a>'; |
|
398 | + if (!empty($subscription)) { |
|
399 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
400 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'getpaid-license-manager') . '</a>'; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | return $actions; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | function wpinv_get_ip() { |
22 | 22 | $ip = $_SERVER['REMOTE_ADDR']; |
23 | 23 | |
24 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
25 | 25 | //Check ip from share internet. |
26 | 26 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
27 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | //Check ip is pass from proxy. |
29 | 29 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
30 | 30 | } |
31 | 31 | |
32 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
32 | + return apply_filters('wpinv_get_ip', $ip); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | function wpinv_get_user_agent() { |
36 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
37 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
36 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
37 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
38 | 38 | } else { |
39 | 39 | $user_agent = ''; |
40 | 40 | } |
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
42 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -47,27 +47,27 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $amount The amount to sanitize. |
49 | 49 | */ |
50 | -function wpinv_sanitize_amount( $amount ) { |
|
50 | +function wpinv_sanitize_amount($amount) { |
|
51 | 51 | |
52 | 52 | // Format decimals. |
53 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
53 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
54 | 54 | |
55 | 55 | // Remove thousands. |
56 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
56 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
57 | 57 | |
58 | 58 | // Cast the remaining to a float. |
59 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
59 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
64 | - if ( $decimals === NULL ) { |
|
63 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
64 | + if ($decimals === NULL) { |
|
65 | 65 | $decimals = wpinv_decimals(); |
66 | 66 | } |
67 | 67 | |
68 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
68 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
69 | 69 | |
70 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
70 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,32 +79,32 @@ discard block |
||
79 | 79 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
80 | 80 | * @return array |
81 | 81 | */ |
82 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
82 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
83 | 83 | |
84 | 84 | $invoice_statuses = array( |
85 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
86 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
87 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
88 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
89 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
90 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
91 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
92 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
85 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
86 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
87 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
88 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
89 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
90 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
91 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
92 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
93 | 93 | ); |
94 | 94 | |
95 | - if ( $draft ) { |
|
96 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
95 | + if ($draft) { |
|
96 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
97 | 97 | } |
98 | 98 | |
99 | - if ( $trashed ) { |
|
100 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
99 | + if ($trashed) { |
|
100 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
103 | + if ($invoice instanceof WPInv_Invoice) { |
|
104 | 104 | $invoice = $invoice->get_post_type(); |
105 | 105 | } |
106 | 106 | |
107 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
107 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @param string $status The raw status |
114 | 114 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
115 | 115 | */ |
116 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
117 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
118 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
116 | +function wpinv_status_nicename($status, $invoice = false) { |
|
117 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
118 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
119 | 119 | |
120 | - return sanitize_text_field( $status ); |
|
120 | + return sanitize_text_field($status); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param string $current |
127 | 127 | */ |
128 | -function wpinv_get_currency( $current = '' ) { |
|
128 | +function wpinv_get_currency($current = '') { |
|
129 | 129 | |
130 | - if ( empty( $current ) ) { |
|
131 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
130 | + if (empty($current)) { |
|
131 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
132 | 132 | } |
133 | 133 | |
134 | - return trim( strtoupper( $current ) ); |
|
134 | + return trim(strtoupper($current)); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param string|null $currency The currency code. Defaults to the default currency. |
141 | 141 | */ |
142 | -function wpinv_currency_symbol( $currency = null ) { |
|
142 | +function wpinv_currency_symbol($currency = null) { |
|
143 | 143 | |
144 | 144 | // Prepare the currency. |
145 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
145 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
146 | 146 | |
147 | 147 | // Fetch all symbols. |
148 | 148 | $symbols = wpinv_get_currency_symbols(); |
149 | 149 | |
150 | 150 | // Fetch this currencies symbol. |
151 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
151 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
152 | 152 | |
153 | 153 | // Filter the symbol. |
154 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
154 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_currency_position() { |
158 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
158 | + $position = wpinv_get_option('currency_position', 'left'); |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
160 | + return apply_filters('wpinv_currency_position', $position); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param $string|null $current |
167 | 167 | */ |
168 | -function wpinv_thousands_separator( $current = null ) { |
|
168 | +function wpinv_thousands_separator($current = null) { |
|
169 | 169 | |
170 | - if ( null == $current ) { |
|
171 | - $current = wpinv_get_option( 'thousands_separator', '.' ); |
|
170 | + if (null == $current) { |
|
171 | + $current = wpinv_get_option('thousands_separator', '.'); |
|
172 | 172 | } |
173 | 173 | |
174 | - return trim( $current ); |
|
174 | + return trim($current); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param $string|null $current |
181 | 181 | */ |
182 | -function wpinv_decimal_separator( $current = null ) { |
|
182 | +function wpinv_decimal_separator($current = null) { |
|
183 | 183 | |
184 | - if ( null == $current ) { |
|
185 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
184 | + if (null == $current) { |
|
185 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
186 | 186 | } |
187 | 187 | |
188 | - return trim( $current ); |
|
188 | + return trim($current); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -193,27 +193,27 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param $string|null $current |
195 | 195 | */ |
196 | -function wpinv_decimals( $current = null ) { |
|
196 | +function wpinv_decimals($current = null) { |
|
197 | 197 | |
198 | - if ( null == $current ) { |
|
199 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
198 | + if (null == $current) { |
|
199 | + $current = wpinv_get_option('decimals', 2); |
|
200 | 200 | } |
201 | 201 | |
202 | - return absint( $current ); |
|
202 | + return absint($current); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | 206 | * Retrieves a list of all supported currencies. |
207 | 207 | */ |
208 | 208 | function wpinv_get_currencies() { |
209 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
209 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * Retrieves a list of all currency symbols. |
214 | 214 | */ |
215 | 215 | function wpinv_get_currency_symbols() { |
216 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
216 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $currency_pos = wpinv_currency_position(); |
226 | 226 | $format = '%1$s%2$s'; |
227 | 227 | |
228 | - switch ( $currency_pos ) { |
|
228 | + switch ($currency_pos) { |
|
229 | 229 | case 'left': |
230 | 230 | $format = '%1$s%2$s'; |
231 | 231 | break; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | break; |
241 | 241 | } |
242 | 242 | |
243 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
243 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -250,25 +250,25 @@ discard block |
||
250 | 250 | * @param string $currency Currency. |
251 | 251 | * @return string |
252 | 252 | */ |
253 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
253 | +function wpinv_price($amount = 0, $currency = '') { |
|
254 | 254 | |
255 | 255 | // Backwards compatibility. |
256 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
256 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
257 | 257 | |
258 | 258 | // Prepare variables. |
259 | - $currency = wpinv_get_currency( $currency ); |
|
259 | + $currency = wpinv_get_currency($currency); |
|
260 | 260 | $amount = (float) $amount; |
261 | 261 | $unformatted_amount = $amount; |
262 | 262 | $negative = $amount < 0; |
263 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
264 | - $amount = wpinv_format_amount( $amount ); |
|
263 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
264 | + $amount = wpinv_format_amount($amount); |
|
265 | 265 | |
266 | 266 | // Format the amount. |
267 | 267 | $format = getpaid_get_price_format(); |
268 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
268 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
269 | 269 | |
270 | 270 | // Filter the formatting. |
271 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
271 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -279,33 +279,33 @@ discard block |
||
279 | 279 | * @param bool $calculate Whether or not to apply separators. |
280 | 280 | * @return string |
281 | 281 | */ |
282 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
282 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
283 | 283 | $thousands_sep = wpinv_thousands_separator(); |
284 | 284 | $decimal_sep = wpinv_decimal_separator(); |
285 | - $decimals = wpinv_decimals( $decimals ); |
|
285 | + $decimals = wpinv_decimals($decimals); |
|
286 | 286 | |
287 | 287 | // Format decimals. |
288 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
288 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
289 | 289 | |
290 | 290 | // Remove thousands. |
291 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
291 | + $amount = str_replace($thousands_sep, '', $amount); |
|
292 | 292 | |
293 | 293 | // Cast the remaining to a float. |
294 | - $amount = floatval( $amount ); |
|
294 | + $amount = floatval($amount); |
|
295 | 295 | |
296 | - if ( $calculate ) { |
|
296 | + if ($calculate) { |
|
297 | 297 | return $amount; |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Fomart the amount. |
301 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
301 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
302 | 302 | } |
303 | 303 | |
304 | -function wpinv_sanitize_key( $key ) { |
|
304 | +function wpinv_sanitize_key($key) { |
|
305 | 305 | $raw_key = $key; |
306 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
306 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
307 | 307 | |
308 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
308 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param $str the file whose extension should be retrieved. |
315 | 315 | */ |
316 | -function wpinv_get_file_extension( $str ) { |
|
317 | - $filetype = wp_check_filetype( $str ); |
|
316 | +function wpinv_get_file_extension($str) { |
|
317 | + $filetype = wp_check_filetype($str); |
|
318 | 318 | return $filetype['ext']; |
319 | 319 | } |
320 | 320 | |
@@ -323,16 +323,16 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param string $string |
325 | 325 | */ |
326 | -function wpinv_string_is_image_url( $string ) { |
|
327 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
328 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
326 | +function wpinv_string_is_image_url($string) { |
|
327 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
328 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Returns the current URL. |
333 | 333 | */ |
334 | 334 | function wpinv_get_current_page_url() { |
335 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
335 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -342,46 +342,46 @@ discard block |
||
342 | 342 | * @param string $name Constant name. |
343 | 343 | * @param mixed $value Value. |
344 | 344 | */ |
345 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
346 | - if ( ! defined( $name ) ) { |
|
347 | - define( $name, $value ); |
|
345 | +function getpaid_maybe_define_constant($name, $value) { |
|
346 | + if (!defined($name)) { |
|
347 | + define($name, $value); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | 351 | function wpinv_get_php_arg_separator_output() { |
352 | - return ini_get( 'arg_separator.output' ); |
|
352 | + return ini_get('arg_separator.output'); |
|
353 | 353 | } |
354 | 354 | |
355 | -function wpinv_rgb_from_hex( $color ) { |
|
356 | - $color = str_replace( '#', '', $color ); |
|
355 | +function wpinv_rgb_from_hex($color) { |
|
356 | + $color = str_replace('#', '', $color); |
|
357 | 357 | |
358 | 358 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
359 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
360 | - if ( empty( $color ) ) { |
|
359 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
360 | + if (empty($color)) { |
|
361 | 361 | return NULL; |
362 | 362 | } |
363 | 363 | |
364 | - $color = str_split( $color ); |
|
364 | + $color = str_split($color); |
|
365 | 365 | |
366 | 366 | $rgb = array(); |
367 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
368 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
369 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
367 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
368 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
369 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
370 | 370 | |
371 | 371 | return $rgb; |
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
375 | - $base = wpinv_rgb_from_hex( $color ); |
|
374 | +function wpinv_hex_darker($color, $factor = 30) { |
|
375 | + $base = wpinv_rgb_from_hex($color); |
|
376 | 376 | $color = '#'; |
377 | 377 | |
378 | - foreach ( $base as $k => $v ) { |
|
378 | + foreach ($base as $k => $v) { |
|
379 | 379 | $amount = $v / 100; |
380 | - $amount = round( $amount * $factor ); |
|
380 | + $amount = round($amount * $factor); |
|
381 | 381 | $new_decimal = $v - $amount; |
382 | 382 | |
383 | - $new_hex_component = dechex( $new_decimal ); |
|
384 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
383 | + $new_hex_component = dechex($new_decimal); |
|
384 | + if (strlen($new_hex_component) < 2) { |
|
385 | 385 | $new_hex_component = "0" . $new_hex_component; |
386 | 386 | } |
387 | 387 | $color .= $new_hex_component; |
@@ -390,18 +390,18 @@ discard block |
||
390 | 390 | return $color; |
391 | 391 | } |
392 | 392 | |
393 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
394 | - $base = wpinv_rgb_from_hex( $color ); |
|
393 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
394 | + $base = wpinv_rgb_from_hex($color); |
|
395 | 395 | $color = '#'; |
396 | 396 | |
397 | - foreach ( $base as $k => $v ) { |
|
397 | + foreach ($base as $k => $v) { |
|
398 | 398 | $amount = 255 - $v; |
399 | 399 | $amount = $amount / 100; |
400 | - $amount = round( $amount * $factor ); |
|
400 | + $amount = round($amount * $factor); |
|
401 | 401 | $new_decimal = $v + $amount; |
402 | 402 | |
403 | - $new_hex_component = dechex( $new_decimal ); |
|
404 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
403 | + $new_hex_component = dechex($new_decimal); |
|
404 | + if (strlen($new_hex_component) < 2) { |
|
405 | 405 | $new_hex_component = "0" . $new_hex_component; |
406 | 406 | } |
407 | 407 | $color .= $new_hex_component; |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | return $color; |
411 | 411 | } |
412 | 412 | |
413 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
414 | - $hex = str_replace( '#', '', $color ); |
|
413 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
414 | + $hex = str_replace('#', '', $color); |
|
415 | 415 | |
416 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
417 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
418 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
416 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
417 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
418 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
419 | 419 | |
420 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
420 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
421 | 421 | |
422 | 422 | return $brightness > 155 ? $dark : $light; |
423 | 423 | } |
424 | 424 | |
425 | -function wpinv_format_hex( $hex ) { |
|
426 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
425 | +function wpinv_format_hex($hex) { |
|
426 | + $hex = trim(str_replace('#', '', $hex)); |
|
427 | 427 | |
428 | - if ( strlen( $hex ) == 3 ) { |
|
428 | + if (strlen($hex) == 3) { |
|
429 | 429 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
430 | 430 | } |
431 | 431 | |
@@ -445,12 +445,12 @@ discard block |
||
445 | 445 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
446 | 446 | * @return string |
447 | 447 | */ |
448 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
449 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
450 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
448 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
449 | + if (function_exists('mb_strimwidth')) { |
|
450 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
451 | 451 | } |
452 | 452 | |
453 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
453 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -462,28 +462,28 @@ discard block |
||
462 | 462 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
463 | 463 | * @return int Returns the number of characters in string. |
464 | 464 | */ |
465 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
466 | - if ( function_exists( 'mb_strlen' ) ) { |
|
467 | - return mb_strlen( $str, $encoding ); |
|
465 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
466 | + if (function_exists('mb_strlen')) { |
|
467 | + return mb_strlen($str, $encoding); |
|
468 | 468 | } |
469 | 469 | |
470 | - return strlen( $str ); |
|
470 | + return strlen($str); |
|
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
474 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
475 | - return mb_strtolower( $str, $encoding ); |
|
473 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
474 | + if (function_exists('mb_strtolower')) { |
|
475 | + return mb_strtolower($str, $encoding); |
|
476 | 476 | } |
477 | 477 | |
478 | - return strtolower( $str ); |
|
478 | + return strtolower($str); |
|
479 | 479 | } |
480 | 480 | |
481 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
482 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
483 | - return mb_strtoupper( $str, $encoding ); |
|
481 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
482 | + if (function_exists('mb_strtoupper')) { |
|
483 | + return mb_strtoupper($str, $encoding); |
|
484 | 484 | } |
485 | 485 | |
486 | - return strtoupper( $str ); |
|
486 | + return strtoupper($str); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
498 | 498 | * @return int Returns the position of the first occurrence of search in the string. |
499 | 499 | */ |
500 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
501 | - if ( function_exists( 'mb_strpos' ) ) { |
|
502 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
500 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
501 | + if (function_exists('mb_strpos')) { |
|
502 | + return mb_strpos($str, $find, $offset, $encoding); |
|
503 | 503 | } |
504 | 504 | |
505 | - return strpos( $str, $find, $offset ); |
|
505 | + return strpos($str, $find, $offset); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
517 | 517 | * @return int Returns the position of the last occurrence of search. |
518 | 518 | */ |
519 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
520 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
521 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
519 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
520 | + if (function_exists('mb_strrpos')) { |
|
521 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
522 | 522 | } |
523 | 523 | |
524 | - return strrpos( $str, $find, $offset ); |
|
524 | + return strrpos($str, $find, $offset); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -536,16 +536,16 @@ discard block |
||
536 | 536 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
537 | 537 | * @return string |
538 | 538 | */ |
539 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
540 | - if ( function_exists( 'mb_substr' ) ) { |
|
541 | - if ( $length === null ) { |
|
542 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
539 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
540 | + if (function_exists('mb_substr')) { |
|
541 | + if ($length === null) { |
|
542 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
543 | 543 | } else { |
544 | - return mb_substr( $str, $start, $length, $encoding ); |
|
544 | + return mb_substr($str, $start, $length, $encoding); |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - return substr( $str, $start, $length ); |
|
548 | + return substr($str, $start, $length); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -557,48 +557,48 @@ discard block |
||
557 | 557 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
558 | 558 | * @return string The width of string. |
559 | 559 | */ |
560 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
561 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
562 | - return mb_strwidth( $str, $encoding ); |
|
560 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
561 | + if (function_exists('mb_strwidth')) { |
|
562 | + return mb_strwidth($str, $encoding); |
|
563 | 563 | } |
564 | 564 | |
565 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
565 | + return wpinv_utf8_strlen($str, $encoding); |
|
566 | 566 | } |
567 | 567 | |
568 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
569 | - if ( function_exists( 'mb_strlen' ) ) { |
|
570 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
568 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
569 | + if (function_exists('mb_strlen')) { |
|
570 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
571 | 571 | $str_end = ""; |
572 | 572 | |
573 | - if ( $lower_str_end ) { |
|
574 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
573 | + if ($lower_str_end) { |
|
574 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
575 | 575 | } else { |
576 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
576 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | return $first_letter . $str_end; |
580 | 580 | } |
581 | 581 | |
582 | - return ucfirst( $str ); |
|
582 | + return ucfirst($str); |
|
583 | 583 | } |
584 | 584 | |
585 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
586 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
587 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
585 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
586 | + if (function_exists('mb_convert_case')) { |
|
587 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
588 | 588 | } |
589 | 589 | |
590 | - return ucwords( $str ); |
|
590 | + return ucwords($str); |
|
591 | 591 | } |
592 | 592 | |
593 | -function wpinv_period_in_days( $period, $unit ) { |
|
594 | - $period = absint( $period ); |
|
593 | +function wpinv_period_in_days($period, $unit) { |
|
594 | + $period = absint($period); |
|
595 | 595 | |
596 | - if ( $period > 0 ) { |
|
597 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
596 | + if ($period > 0) { |
|
597 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
598 | 598 | $period = $period * 7; |
599 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
599 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
600 | 600 | $period = $period * 30; |
601 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
601 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
602 | 602 | $period = $period * 365; |
603 | 603 | } |
604 | 604 | } |
@@ -606,14 +606,14 @@ discard block |
||
606 | 606 | return $period; |
607 | 607 | } |
608 | 608 | |
609 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
610 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
611 | - return cal_days_in_month( $calendar, $month, $year ); |
|
609 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
610 | + if (function_exists('cal_days_in_month')) { |
|
611 | + return cal_days_in_month($calendar, $month, $year); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | // Fallback in case the calendar extension is not loaded in PHP |
615 | 615 | // Only supports Gregorian calendar |
616 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
616 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -624,12 +624,12 @@ discard block |
||
624 | 624 | * |
625 | 625 | * @return string |
626 | 626 | */ |
627 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
627 | +function wpi_help_tip($tip, $allow_html = false) { |
|
628 | 628 | |
629 | - if ( $allow_html ) { |
|
630 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
629 | + if ($allow_html) { |
|
630 | + $tip = wpi_sanitize_tooltip($tip); |
|
631 | 631 | } else { |
632 | - $tip = esc_attr( $tip ); |
|
632 | + $tip = esc_attr($tip); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -643,8 +643,8 @@ discard block |
||
643 | 643 | * @param string $var |
644 | 644 | * @return string |
645 | 645 | */ |
646 | -function wpi_sanitize_tooltip( $var ) { |
|
647 | - return wp_kses( html_entity_decode( $var ), array( |
|
646 | +function wpi_sanitize_tooltip($var) { |
|
647 | + return wp_kses(html_entity_decode($var), array( |
|
648 | 648 | 'br' => array(), |
649 | 649 | 'em' => array(), |
650 | 650 | 'strong' => array(), |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | 'li' => array(), |
656 | 656 | 'ol' => array(), |
657 | 657 | 'p' => array(), |
658 | - ) ); |
|
658 | + )); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | */ |
666 | 666 | function wpinv_get_screen_ids() { |
667 | 667 | |
668 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
668 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
669 | 669 | |
670 | 670 | $screen_ids = array( |
671 | 671 | 'toplevel_page_' . $screen_id, |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | 'invoicing_page_wpi-addons', |
684 | 684 | ); |
685 | 685 | |
686 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
686 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | * @param array|string $list List of values. |
695 | 695 | * @return array Sanitized array of values. |
696 | 696 | */ |
697 | -function wpinv_parse_list( $list ) { |
|
697 | +function wpinv_parse_list($list) { |
|
698 | 698 | |
699 | - if ( empty( $list ) ) { |
|
699 | + if (empty($list)) { |
|
700 | 700 | $list = array(); |
701 | 701 | } |
702 | 702 | |
703 | - if ( ! is_array( $list ) ) { |
|
704 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
703 | + if (!is_array($list)) { |
|
704 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | return $list; |
@@ -715,16 +715,16 @@ discard block |
||
715 | 715 | * @param string $key Type of data to fetch. |
716 | 716 | * @return mixed Fetched data. |
717 | 717 | */ |
718 | -function wpinv_get_data( $key ) { |
|
718 | +function wpinv_get_data($key) { |
|
719 | 719 | |
720 | 720 | // Try fetching it from the cache. |
721 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
722 | - if( $data ) { |
|
721 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
722 | + if ($data) { |
|
723 | 723 | return $data; |
724 | 724 | } |
725 | 725 | |
726 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
727 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
726 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
727 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
728 | 728 | |
729 | 729 | return $data; |
730 | 730 | } |
@@ -738,10 +738,10 @@ discard block |
||
738 | 738 | * @param bool $first_empty Whether or not the first item in the list should be empty |
739 | 739 | * @return mixed Fetched data. |
740 | 740 | */ |
741 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
741 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
742 | 742 | |
743 | - if ( ! empty( $options ) && $first_empty ) { |
|
744 | - return array_merge( array( '' => '' ), $options ); |
|
743 | + if (!empty($options) && $first_empty) { |
|
744 | + return array_merge(array('' => ''), $options); |
|
745 | 745 | } |
746 | 746 | return $options; |
747 | 747 | |
@@ -753,21 +753,21 @@ discard block |
||
753 | 753 | * @param mixed $var Data to sanitize. |
754 | 754 | * @return string|array |
755 | 755 | */ |
756 | -function wpinv_clean( $var ) { |
|
756 | +function wpinv_clean($var) { |
|
757 | 757 | |
758 | - if ( is_array( $var ) ) { |
|
759 | - return array_map( 'wpinv_clean', $var ); |
|
758 | + if (is_array($var)) { |
|
759 | + return array_map('wpinv_clean', $var); |
|
760 | 760 | } |
761 | 761 | |
762 | - if ( is_object( $var ) ) { |
|
763 | - $object_vars = get_object_vars( $var ); |
|
764 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
765 | - $var->$property_name = wpinv_clean( $property_value ); |
|
762 | + if (is_object($var)) { |
|
763 | + $object_vars = get_object_vars($var); |
|
764 | + foreach ($object_vars as $property_name => $property_value) { |
|
765 | + $var->$property_name = wpinv_clean($property_value); |
|
766 | 766 | } |
767 | 767 | return $var; |
768 | 768 | } |
769 | 769 | |
770 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
770 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | /** |
@@ -776,43 +776,43 @@ discard block |
||
776 | 776 | * @param string $str Data to convert. |
777 | 777 | * @return string|array |
778 | 778 | */ |
779 | -function getpaid_convert_price_string_to_options( $str ) { |
|
779 | +function getpaid_convert_price_string_to_options($str) { |
|
780 | 780 | |
781 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
782 | - $options = array(); |
|
781 | + $raw_options = array_map('trim', explode(',', $str)); |
|
782 | + $options = array(); |
|
783 | 783 | |
784 | - foreach ( $raw_options as $option ) { |
|
784 | + foreach ($raw_options as $option) { |
|
785 | 785 | |
786 | - if ( '' == $option ) { |
|
786 | + if ('' == $option) { |
|
787 | 787 | continue; |
788 | 788 | } |
789 | 789 | |
790 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
790 | + $option = array_map('trim', explode('|', $option)); |
|
791 | 791 | |
792 | 792 | $price = null; |
793 | 793 | $label = null; |
794 | 794 | |
795 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
796 | - $label = $option[0]; |
|
795 | + if (isset($option[0]) && '' != $option[0]) { |
|
796 | + $label = $option[0]; |
|
797 | 797 | } |
798 | 798 | |
799 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
799 | + if (isset($option[1]) && '' != $option[1]) { |
|
800 | 800 | $price = $option[1]; |
801 | 801 | } |
802 | 802 | |
803 | - if ( ! isset( $price ) ) { |
|
803 | + if (!isset($price)) { |
|
804 | 804 | $price = $label; |
805 | 805 | } |
806 | 806 | |
807 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
807 | + if (!isset($price) || !is_numeric($price)) { |
|
808 | 808 | continue; |
809 | 809 | } |
810 | 810 | |
811 | - if ( ! isset( $label ) ) { |
|
811 | + if (!isset($label)) { |
|
812 | 812 | $label = $price; |
813 | 813 | } |
814 | 814 | |
815 | - $options[ $price ] = $label; |
|
815 | + $options[$price] = $label; |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | return $options; |
@@ -821,22 +821,22 @@ discard block |
||
821 | 821 | /** |
822 | 822 | * Returns the help tip. |
823 | 823 | */ |
824 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
825 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
826 | - $tip = esc_attr__( $tip ); |
|
824 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
825 | + $additional_classes = sanitize_html_class($additional_classes); |
|
826 | + $tip = esc_attr__($tip); |
|
827 | 827 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
831 | 831 | * Formats a date |
832 | 832 | */ |
833 | -function getpaid_format_date( $date ) { |
|
833 | +function getpaid_format_date($date) { |
|
834 | 834 | |
835 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
835 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
836 | 836 | return ''; |
837 | 837 | } |
838 | 838 | |
839 | - return date_i18n( getpaid_date_format(), strtotime( $date ) ); |
|
839 | + return date_i18n(getpaid_date_format(), strtotime($date)); |
|
840 | 840 | |
841 | 841 | } |
842 | 842 | |
@@ -845,9 +845,9 @@ discard block |
||
845 | 845 | * |
846 | 846 | * @return string |
847 | 847 | */ |
848 | -function getpaid_format_date_value( $date, $default = "—" ) { |
|
849 | - $date = getpaid_format_date( $date ); |
|
850 | - return empty( $date ) ? $default : $date; |
|
848 | +function getpaid_format_date_value($date, $default = "—") { |
|
849 | + $date = getpaid_format_date($date); |
|
850 | + return empty($date) ? $default : $date; |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | /** |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * @return string |
857 | 857 | */ |
858 | 858 | function getpaid_date_format() { |
859 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
859 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | * @return string |
866 | 866 | */ |
867 | 867 | function getpaid_time_format() { |
868 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
868 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | * @param integer $limit Limit size in characters. |
876 | 876 | * @return string |
877 | 877 | */ |
878 | -function getpaid_limit_length( $string, $limit ) { |
|
878 | +function getpaid_limit_length($string, $limit) { |
|
879 | 879 | $str_limit = $limit - 3; |
880 | 880 | |
881 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
882 | - if ( mb_strlen( $string ) > $limit ) { |
|
883 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
881 | + if (function_exists('mb_strimwidth')) { |
|
882 | + if (mb_strlen($string) > $limit) { |
|
883 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
884 | 884 | } |
885 | 885 | } else { |
886 | - if ( strlen( $string ) > $limit ) { |
|
887 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
886 | + if (strlen($string) > $limit) { |
|
887 | + $string = substr($string, 0, $str_limit) . '...'; |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | return $string; |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | * @since 1.0.19 |
899 | 899 | */ |
900 | 900 | function getpaid_api() { |
901 | - return getpaid()->get( 'api' ); |
|
901 | + return getpaid()->get('api'); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | * @since 1.0.19 |
909 | 909 | */ |
910 | 910 | function getpaid_post_types() { |
911 | - return getpaid()->get( 'post_types' ); |
|
911 | + return getpaid()->get('post_types'); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | /** |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | * @since 1.0.19 |
919 | 919 | */ |
920 | 920 | function getpaid_session() { |
921 | - return getpaid()->get( 'session' ); |
|
921 | + return getpaid()->get('session'); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @since 1.0.19 |
929 | 929 | */ |
930 | 930 | function getpaid_notes() { |
931 | - return getpaid()->get( 'notes' ); |
|
931 | + return getpaid()->get('notes'); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | /** |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | * @return GetPaid_Admin |
938 | 938 | */ |
939 | 939 | function getpaid_admin() { |
940 | - return getpaid()->get( 'admin' ); |
|
940 | + return getpaid()->get('admin'); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | /** |
@@ -947,6 +947,6 @@ discard block |
||
947 | 947 | * @param string $base the base url |
948 | 948 | * @return string |
949 | 949 | */ |
950 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
951 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
950 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
951 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
952 | 952 | } |