@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @return array |
78 | 78 | */ |
79 | 79 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
80 | - $invoice_statuses = array( |
|
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
80 | + $invoice_statuses = array( |
|
81 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | 82 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
83 | 83 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
84 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | 87 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
88 | 88 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
89 | 89 | ); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | function wpinv_status_nicename( $status ) { |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @return string |
209 | 209 | */ |
210 | 210 | function getpaid_get_price_format() { |
211 | - $currency_pos = wpinv_currency_position(); |
|
212 | - $format = '%1$s%2$s'; |
|
211 | + $currency_pos = wpinv_currency_position(); |
|
212 | + $format = '%1$s%2$s'; |
|
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
215 | - case 'left': |
|
216 | - $format = '%1$s%2$s'; |
|
217 | - break; |
|
218 | - case 'right': |
|
219 | - $format = '%2$s%1$s'; |
|
220 | - break; |
|
221 | - case 'left_space': |
|
222 | - $format = '%1$s %2$s'; |
|
223 | - break; |
|
224 | - case 'right_space': |
|
225 | - $format = '%2$s %1$s'; |
|
226 | - break; |
|
227 | - } |
|
214 | + switch ( $currency_pos ) { |
|
215 | + case 'left': |
|
216 | + $format = '%1$s%2$s'; |
|
217 | + break; |
|
218 | + case 'right': |
|
219 | + $format = '%2$s%1$s'; |
|
220 | + break; |
|
221 | + case 'left_space': |
|
222 | + $format = '%1$s %2$s'; |
|
223 | + break; |
|
224 | + case 'right_space': |
|
225 | + $format = '%2$s %1$s'; |
|
226 | + break; |
|
227 | + } |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | 331 | function getpaid_maybe_define_constant( $name, $value ) { |
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
334 | - } |
|
332 | + if ( ! defined( $name ) ) { |
|
333 | + define( $name, $value ); |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get( 'arg_separator.output' ); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | function wpinv_rgb_from_hex( $color ) { |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | - } |
|
687 | + if ( ! is_array( $list ) ) { |
|
688 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | + } |
|
690 | 690 | |
691 | - return $list; |
|
691 | + return $list; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | } |
709 | 709 | |
710 | 710 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
711 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
712 | 712 | |
713 | - return $data; |
|
713 | + return $data; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -739,17 +739,17 @@ discard block |
||
739 | 739 | */ |
740 | 740 | function wpinv_clean( $var ) { |
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if ( is_array( $var ) ) { |
|
743 | + return array_map( 'wpinv_clean', $var ); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | if ( is_object( $var ) ) { |
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
747 | + $object_vars = get_object_vars( $var ); |
|
748 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | + $var->$property_name = wpinv_clean( $property_value ); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | 754 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
755 | 755 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | */ |
763 | 763 | function getpaid_convert_price_string_to_options( $str ) { |
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
765 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | 766 | $options = array(); |
767 | 767 | |
768 | 768 | foreach ( $raw_options as $option ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -862,15 +862,15 @@ discard block |
||
862 | 862 | function getpaid_limit_length( $string, $limit ) { |
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | - } |
|
869 | - } else { |
|
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | - } |
|
873 | - } |
|
865 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | + if ( mb_strlen( $string ) > $limit ) { |
|
867 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | + } |
|
869 | + } else { |
|
870 | + if ( strlen( $string ) > $limit ) { |
|
871 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | + } |
|
873 | + } |
|
874 | 874 | return $string; |
875 | 875 | |
876 | 876 | } |
@@ -12,93 +12,93 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Daily_Maintenance { |
14 | 14 | |
15 | - /** |
|
16 | - * Class constructor. |
|
17 | - */ |
|
18 | - public function __construct(){ |
|
19 | - |
|
20 | - // Clear deprecated events. |
|
21 | - add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
22 | - |
|
23 | - // (Maybe) schedule a cron that runs daily. |
|
24 | - add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
25 | - |
|
26 | - // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
|
27 | - add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
28 | - add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
29 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
30 | - |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * Schedules a cron to run every day at 7 a.m |
|
35 | - * |
|
36 | - */ |
|
37 | - public function maybe_create_scheduled_event() { |
|
38 | - |
|
39 | - if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
40 | - $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
41 | - wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
42 | - } |
|
43 | - |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Clears deprecated events. |
|
48 | - * |
|
49 | - */ |
|
50 | - public function maybe_clear_deprecated_events() { |
|
51 | - |
|
52 | - if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
53 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
54 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
55 | - update_option( 'wpinv_cleared_old_events', 1 ); |
|
56 | - } |
|
57 | - |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Fires the old hook for backwards compatibility. |
|
62 | - * |
|
63 | - */ |
|
64 | - public function backwards_compat() { |
|
65 | - do_action( 'wpinv_register_schedule_event_daily' ); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Expires expired subscriptions. |
|
70 | - * |
|
71 | - */ |
|
72 | - public function maybe_expire_subscriptions() { |
|
73 | - |
|
74 | - // Fetch expired subscriptions (skips those that expire today). |
|
75 | - $args = array( |
|
76 | - 'number' => -1, |
|
77 | - 'count_total' => false, |
|
78 | - 'status' => 'trialling active failing cancelled', |
|
79 | - 'date_expires_query' => array( |
|
80 | - 'before' => 'today', |
|
81 | - 'inclusive' => false, |
|
82 | - ), |
|
83 | - ); |
|
84 | - |
|
85 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
86 | - |
|
87 | - foreach ( $subscriptions as $subscription ) { |
|
88 | - if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) { |
|
89 | - $subscription->set_status( 'expired' ); |
|
90 | - $subscription->save(); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Logs cron runs. |
|
98 | - * |
|
99 | - */ |
|
100 | - public function log_cron_run() { |
|
101 | - wpinv_error_log( "GetPaid Daily Cron" ); |
|
102 | - } |
|
15 | + /** |
|
16 | + * Class constructor. |
|
17 | + */ |
|
18 | + public function __construct(){ |
|
19 | + |
|
20 | + // Clear deprecated events. |
|
21 | + add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
22 | + |
|
23 | + // (Maybe) schedule a cron that runs daily. |
|
24 | + add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
25 | + |
|
26 | + // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
|
27 | + add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
28 | + add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
29 | + add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
30 | + |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * Schedules a cron to run every day at 7 a.m |
|
35 | + * |
|
36 | + */ |
|
37 | + public function maybe_create_scheduled_event() { |
|
38 | + |
|
39 | + if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
40 | + $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
41 | + wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
42 | + } |
|
43 | + |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Clears deprecated events. |
|
48 | + * |
|
49 | + */ |
|
50 | + public function maybe_clear_deprecated_events() { |
|
51 | + |
|
52 | + if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
53 | + wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
54 | + wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
55 | + update_option( 'wpinv_cleared_old_events', 1 ); |
|
56 | + } |
|
57 | + |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Fires the old hook for backwards compatibility. |
|
62 | + * |
|
63 | + */ |
|
64 | + public function backwards_compat() { |
|
65 | + do_action( 'wpinv_register_schedule_event_daily' ); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Expires expired subscriptions. |
|
70 | + * |
|
71 | + */ |
|
72 | + public function maybe_expire_subscriptions() { |
|
73 | + |
|
74 | + // Fetch expired subscriptions (skips those that expire today). |
|
75 | + $args = array( |
|
76 | + 'number' => -1, |
|
77 | + 'count_total' => false, |
|
78 | + 'status' => 'trialling active failing cancelled', |
|
79 | + 'date_expires_query' => array( |
|
80 | + 'before' => 'today', |
|
81 | + 'inclusive' => false, |
|
82 | + ), |
|
83 | + ); |
|
84 | + |
|
85 | + $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
86 | + |
|
87 | + foreach ( $subscriptions as $subscription ) { |
|
88 | + if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) { |
|
89 | + $subscription->set_status( 'expired' ); |
|
90 | + $subscription->save(); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Logs cron runs. |
|
98 | + * |
|
99 | + */ |
|
100 | + public function log_cron_run() { |
|
101 | + wpinv_error_log( "GetPaid Daily Cron" ); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | } |