@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | class GetPaid_Daily_Maintenance { |
14 | 14 | |
15 | 15 | /** |
16 | - * Class constructor. |
|
17 | - */ |
|
16 | + * Class constructor. |
|
17 | + */ |
|
18 | 18 | public function __construct(){ |
19 | 19 | |
20 | 20 | // Clear deprecated events. |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | - * Schedules a cron to run every day at 7 a.m |
|
35 | + * Schedules a cron to run every day at 7 a.m |
|
36 | 36 | * |
37 | - */ |
|
37 | + */ |
|
38 | 38 | public function maybe_create_scheduled_event() { |
39 | 39 | |
40 | 40 | if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | - * Clears deprecated events. |
|
48 | + * Clears deprecated events. |
|
49 | 49 | * |
50 | - */ |
|
50 | + */ |
|
51 | 51 | public function maybe_clear_deprecated_events() { |
52 | 52 | |
53 | 53 | if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | - * Fires the old hook for backwards compatibility. |
|
62 | + * Fires the old hook for backwards compatibility. |
|
63 | 63 | * |
64 | - */ |
|
64 | + */ |
|
65 | 65 | public function backwards_compat() { |
66 | 66 | do_action( 'wpinv_register_schedule_event_daily' ); |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | - * Expires expired subscriptions. |
|
70 | + * Expires expired subscriptions. |
|
71 | 71 | * |
72 | - */ |
|
72 | + */ |
|
73 | 73 | public function maybe_expire_subscriptions() { |
74 | 74 | |
75 | 75 | // Fetch expired subscriptions (skips those that expire today). |
76 | 76 | $args = array( |
77 | 77 | 'number' => -1, |
78 | - 'count_total' => false, |
|
79 | - 'status' => 'trialling active failing cancelled', |
|
78 | + 'count_total' => false, |
|
79 | + 'status' => 'trialling active failing cancelled', |
|
80 | 80 | 'date_expires_query' => array( |
81 | 81 | 'before' => 'today', |
82 | 82 | 'inclusive' => true, |
@@ -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 | * Daily maintenance class. |
@@ -15,19 +15,19 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Class constructor. |
17 | 17 | */ |
18 | - public function __construct(){ |
|
18 | + public function __construct() { |
|
19 | 19 | |
20 | 20 | // Clear deprecated events. |
21 | - add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
21 | + add_action('wp', array($this, 'maybe_clear_deprecated_events')); |
|
22 | 22 | |
23 | 23 | // (Maybe) schedule a cron that runs daily. |
24 | - add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
24 | + add_action('wp', array($this, 'maybe_create_scheduled_event')); |
|
25 | 25 | |
26 | 26 | // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
27 | - add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
28 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
29 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_send_upcoming_renewal_reminders' ) ); |
|
30 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_send_overdue_notices' ) ); |
|
27 | + add_action('getpaid_daily_maintenance', array($this, 'backwards_compat')); |
|
28 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions')); |
|
29 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_send_upcoming_renewal_reminders')); |
|
30 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_send_overdue_notices')); |
|
31 | 31 | |
32 | 32 | } |
33 | 33 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function maybe_create_scheduled_event() { |
39 | 39 | |
40 | - if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
41 | - $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
42 | - wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
40 | + if (!wp_next_scheduled('getpaid_daily_maintenance')) { |
|
41 | + $timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp')); |
|
42 | + wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function maybe_clear_deprecated_events() { |
52 | 52 | |
53 | - if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
54 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
55 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
56 | - update_option( 'wpinv_cleared_old_events', 1 ); |
|
53 | + if (!get_option('wpinv_cleared_old_events')) { |
|
54 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
55 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_daily'); |
|
56 | + update_option('wpinv_cleared_old_events', 1); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | */ |
65 | 65 | public function backwards_compat() { |
66 | - do_action( 'wpinv_register_schedule_event_daily' ); |
|
66 | + do_action('wpinv_register_schedule_event_daily'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function maybe_expire_subscriptions() { |
74 | 74 | |
75 | 75 | // Fetch expired subscriptions (skips those that expire today). |
76 | - $args = array( |
|
76 | + $args = array( |
|
77 | 77 | 'number' => -1, |
78 | 78 | 'count_total' => false, |
79 | 79 | 'status' => 'trialling active failing cancelled', |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | ), |
84 | 84 | ); |
85 | 85 | |
86 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
86 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
87 | 87 | |
88 | - foreach ( $subscriptions as $subscription ) { |
|
89 | - $subscription->set_status( 'expired' ); |
|
88 | + foreach ($subscriptions as $subscription) { |
|
89 | + $subscription->set_status('expired'); |
|
90 | 90 | $subscription->save(); |
91 | 91 | } |
92 | 92 |
@@ -7,190 +7,190 @@ 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 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
48 | + $page_id = absint($page_id); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option('success_page', false); |
|
55 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
62 | + $ret = $ret ? is_page($ret) : false; |
|
63 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Redirects a user the success page. |
74 | 74 | */ |
75 | -function wpinv_send_to_success_page( $args = array() ) { |
|
75 | +function wpinv_send_to_success_page($args = array()) { |
|
76 | 76 | $redirect = add_query_arg( |
77 | - wp_parse_args( $args ), |
|
77 | + wp_parse_args($args), |
|
78 | 78 | wpinv_get_success_page_uri() |
79 | 79 | ); |
80 | 80 | |
81 | - wp_redirect( $redirect ); |
|
81 | + wp_redirect($redirect); |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
85 | +function wpinv_send_to_failed_page($args = null) { |
|
86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
87 | 87 | |
88 | - if ( !empty( $args ) ) { |
|
88 | + if (!empty($args)) { |
|
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if (is_string($args)) |
|
91 | + $args = str_replace('?', '', $args); |
|
92 | 92 | |
93 | - $args = wp_parse_args( $args ); |
|
93 | + $args = wp_parse_args($args); |
|
94 | 94 | |
95 | - $redirect = add_query_arg( $args, $redirect ); |
|
95 | + $redirect = add_query_arg($args, $redirect); |
|
96 | 96 | } |
97 | 97 | |
98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
99 | 99 | |
100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
101 | - wp_redirect( $redirect ); |
|
100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
101 | + wp_redirect($redirect); |
|
102 | 102 | exit; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
105 | +function wpinv_get_checkout_uri($args = array()) { |
|
106 | + $uri = wpinv_get_option('checkout_page', false); |
|
107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
109 | + if (!empty($args)) { |
|
110 | 110 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
111 | + if (is_string($args)) |
|
112 | + $args = str_replace('?', '', $args); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args($args); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
116 | + $uri = add_query_arg($args, $uri); |
|
117 | 117 | } |
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
130 | +function wpinv_send_back_to_checkout($args = array()) { |
|
131 | 131 | $redirect = wpinv_get_checkout_uri(); |
132 | 132 | |
133 | - if ( ! empty( $args ) ) { |
|
133 | + if (!empty($args)) { |
|
134 | 134 | // Check for backward compatibility |
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
135 | + if (is_string($args)) |
|
136 | + $args = str_replace('?', '', $args); |
|
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args($args); |
|
139 | 139 | |
140 | - $redirect = add_query_arg( $args, $redirect ); |
|
140 | + $redirect = add_query_arg($args, $redirect); |
|
141 | 141 | } |
142 | 142 | |
143 | - do_action( 'wpinv_pre_send_back_to_checkout', $args ); |
|
144 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
143 | + do_action('wpinv_pre_send_back_to_checkout', $args); |
|
144 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
145 | 145 | exit; |
146 | 146 | } |
147 | 147 | |
148 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
149 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
150 | - $success_page = get_permalink( $success_page ); |
|
148 | +function wpinv_get_success_page_url($query_string = null) { |
|
149 | + $success_page = wpinv_get_option('success_page', 0); |
|
150 | + $success_page = get_permalink($success_page); |
|
151 | 151 | |
152 | - if ( $query_string ) |
|
152 | + if ($query_string) |
|
153 | 153 | $success_page .= $query_string; |
154 | 154 | |
155 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
155 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
156 | 156 | } |
157 | 157 | |
158 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
159 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
160 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
158 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
159 | + $uri = wpinv_get_option('failure_page', ''); |
|
160 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
161 | 161 | |
162 | - if ( $extras ) |
|
162 | + if ($extras) |
|
163 | 163 | $uri .= $extras; |
164 | 164 | |
165 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
165 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | function wpinv_is_failed_transaction_page() { |
169 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
170 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
169 | + $ret = wpinv_get_option('failure_page', false); |
|
170 | + $ret = isset($ret) ? is_page($ret) : false; |
|
171 | 171 | |
172 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
172 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
173 | 173 | } |
174 | 174 | |
175 | -function wpinv_transaction_query( $type = 'start' ) { |
|
175 | +function wpinv_transaction_query($type = 'start') { |
|
176 | 176 | global $wpdb; |
177 | 177 | |
178 | 178 | $wpdb->hide_errors(); |
179 | 179 | |
180 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
181 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
180 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
181 | + define('WPINV_USE_TRANSACTIONS', true); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
185 | - switch ( $type ) { |
|
184 | + if (WPINV_USE_TRANSACTIONS) { |
|
185 | + switch ($type) { |
|
186 | 186 | case 'commit' : |
187 | - $wpdb->query( 'COMMIT' ); |
|
187 | + $wpdb->query('COMMIT'); |
|
188 | 188 | break; |
189 | 189 | case 'rollback' : |
190 | - $wpdb->query( 'ROLLBACK' ); |
|
190 | + $wpdb->query('ROLLBACK'); |
|
191 | 191 | break; |
192 | 192 | default : |
193 | - $wpdb->query( 'START TRANSACTION' ); |
|
193 | + $wpdb->query('START TRANSACTION'); |
|
194 | 194 | break; |
195 | 195 | } |
196 | 196 | } |
@@ -199,142 +199,142 @@ discard block |
||
199 | 199 | function wpinv_get_prefix() { |
200 | 200 | $invoice_prefix = 'INV-'; |
201 | 201 | |
202 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
202 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | function wpinv_get_business_logo() { |
206 | - $business_logo = wpinv_get_option( 'logo' ); |
|
207 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
206 | + $business_logo = wpinv_get_option('logo'); |
|
207 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | function wpinv_get_business_name() { |
211 | 211 | $business_name = wpinv_get_option('store_name'); |
212 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
212 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function wpinv_get_blogname() { |
216 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
216 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | function wpinv_get_admin_email() { |
220 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
221 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
220 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
221 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_business_website() { |
225 | - $business_website = home_url( '/' ); |
|
226 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
225 | + $business_website = home_url('/'); |
|
226 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
227 | 227 | } |
228 | 228 | |
229 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
229 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
230 | 230 | $terms_text = ''; |
231 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
231 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | function wpinv_get_business_footer() { |
235 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
236 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
237 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
235 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
236 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
237 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | function wpinv_checkout_required_fields() { |
241 | 241 | $required_fields = array(); |
242 | 242 | |
243 | 243 | // Let payment gateways and other extensions determine if address fields should be required |
244 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
244 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
245 | 245 | |
246 | - if ( $require_billing_details ) { |
|
247 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
246 | + if ($require_billing_details) { |
|
247 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
248 | 248 | $required_fields['first_name'] = array( |
249 | 249 | 'error_id' => 'invalid_first_name', |
250 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
250 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
251 | 251 | ); |
252 | 252 | } |
253 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
253 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
254 | 254 | $required_fields['address'] = array( |
255 | 255 | 'error_id' => 'invalid_address', |
256 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
256 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
257 | 257 | ); |
258 | 258 | } |
259 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
259 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
260 | 260 | $required_fields['city'] = array( |
261 | 261 | 'error_id' => 'invalid_city', |
262 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
262 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
263 | 263 | ); |
264 | 264 | } |
265 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
265 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
266 | 266 | $required_fields['state'] = array( |
267 | 267 | 'error_id' => 'invalid_state', |
268 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
268 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
269 | 269 | ); |
270 | 270 | } |
271 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
271 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
272 | 272 | $required_fields['country'] = array( |
273 | 273 | 'error_id' => 'invalid_country', |
274 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
274 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
279 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | function wpinv_is_ssl_enforced() { |
283 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
284 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
283 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
284 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | function wpinv_schedule_event_twicedaily() { |
288 | 288 | wpinv_email_payment_reminders(); |
289 | 289 | wpinv_email_renewal_reminders(); |
290 | 290 | } |
291 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
291 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
292 | 292 | |
293 | 293 | function wpinv_require_login_to_checkout() { |
294 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
295 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
294 | + $return = wpinv_get_option('login_to_checkout', false); |
|
295 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
296 | 296 | } |
297 | 297 | |
298 | -function wpinv_sequential_number_active( $type = '' ) { |
|
299 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
300 | - if ( null !== $check ) { |
|
298 | +function wpinv_sequential_number_active($type = '') { |
|
299 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
300 | + if (null !== $check) { |
|
301 | 301 | return $check; |
302 | 302 | } |
303 | 303 | |
304 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
304 | + return wpinv_get_option('sequential_invoice_number'); |
|
305 | 305 | } |
306 | 306 | |
307 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
307 | +function wpinv_switch_to_locale($locale = NULL) { |
|
308 | 308 | global $invoicing, $wpi_switch_locale; |
309 | 309 | |
310 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
311 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
310 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
311 | + $locale = empty($locale) ? get_locale() : $locale; |
|
312 | 312 | |
313 | - switch_to_locale( $locale ); |
|
313 | + switch_to_locale($locale); |
|
314 | 314 | |
315 | 315 | $wpi_switch_locale = $locale; |
316 | 316 | |
317 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
317 | + add_filter('plugin_locale', 'get_locale'); |
|
318 | 318 | |
319 | 319 | $invoicing->load_textdomain(); |
320 | 320 | |
321 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
321 | + do_action('wpinv_switch_to_locale', $locale); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | 325 | function wpinv_restore_locale() { |
326 | 326 | global $invoicing, $wpi_switch_locale; |
327 | 327 | |
328 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
328 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
329 | 329 | restore_previous_locale(); |
330 | 330 | |
331 | 331 | $wpi_switch_locale = NULL; |
332 | 332 | |
333 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
333 | + remove_filter('plugin_locale', 'get_locale'); |
|
334 | 334 | |
335 | 335 | $invoicing->load_textdomain(); |
336 | 336 | |
337 | - do_action( 'wpinv_restore_locale' ); |
|
337 | + do_action('wpinv_restore_locale'); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
@@ -342,22 +342,22 @@ discard block |
||
342 | 342 | * Returns the default form's id. |
343 | 343 | */ |
344 | 344 | function wpinv_get_default_payment_form() { |
345 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
345 | + $form = get_option('wpinv_default_payment_form'); |
|
346 | 346 | |
347 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
347 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
348 | 348 | $form = wp_insert_post( |
349 | 349 | array( |
350 | 350 | 'post_type' => 'wpi_payment_form', |
351 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
351 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
352 | 352 | 'post_status' => 'publish', |
353 | 353 | 'meta_input' => array( |
354 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
354 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
355 | 355 | 'wpinv_form_items' => array(), |
356 | 356 | ) |
357 | 357 | ) |
358 | 358 | ); |
359 | 359 | |
360 | - update_option( 'wpinv_default_payment_form', $form ); |
|
360 | + update_option('wpinv_default_payment_form', $form); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | return $form; |