@@ -117,14 +117,14 @@ |
||
117 | 117 | */ |
118 | 118 | function getpaid_doing_it_wrong( $function, $message, $version ) { |
119 | 119 | |
120 | - $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | - |
|
122 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | - } else { |
|
126 | - _doing_it_wrong( $function, $message, $version ); |
|
127 | - } |
|
120 | + $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | + |
|
122 | + if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | + do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | + error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | + } else { |
|
126 | + _doing_it_wrong( $function, $message, $version ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false |
39 | - ), |
|
39 | + ), |
|
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | - 'type' => 'text', |
|
45 | - 'desc_tip' => true, |
|
46 | - 'default' => '', |
|
47 | - 'placeholder' => __('1','invoicing'), |
|
48 | - 'advanced' => false |
|
49 | - ), |
|
50 | - |
|
51 | - 'item' => array( |
|
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | - 'type' => 'text', |
|
55 | - 'desc_tip' => true, |
|
56 | - 'default' => '', |
|
57 | - 'placeholder' => __('1','invoicing'), |
|
58 | - 'advanced' => false |
|
59 | - ), |
|
42 | + 'title' => __( 'Form', 'invoicing' ), |
|
43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | + 'type' => 'text', |
|
45 | + 'desc_tip' => true, |
|
46 | + 'default' => '', |
|
47 | + 'placeholder' => __('1','invoicing'), |
|
48 | + 'advanced' => false |
|
49 | + ), |
|
50 | + |
|
51 | + 'item' => array( |
|
52 | + 'title' => __( 'Items', 'invoicing' ), |
|
53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | + 'type' => 'text', |
|
55 | + 'desc_tip' => true, |
|
56 | + 'default' => '', |
|
57 | + 'placeholder' => __('1','invoicing'), |
|
58 | + 'advanced' => false |
|
59 | + ), |
|
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | - 'type' => 'text', |
|
65 | - 'desc_tip' => true, |
|
66 | - 'default' => '', |
|
67 | - 'advanced' => false |
|
68 | - ) |
|
62 | + 'title' => __( 'Button', 'invoicing' ), |
|
63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | + 'type' => 'text', |
|
65 | + 'desc_tip' => true, |
|
66 | + 'default' => '', |
|
67 | + 'advanced' => false |
|
68 | + ) |
|
69 | 69 | |
70 | 70 | ) |
71 | 71 | |
@@ -75,95 +75,95 @@ discard block |
||
75 | 75 | parent::__construct( $options ); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * The Super block output function. |
|
80 | - * |
|
81 | - * @param array $args |
|
82 | - * @param array $widget_args |
|
83 | - * @param string $content |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
78 | + /** |
|
79 | + * The Super block output function. |
|
80 | + * |
|
81 | + * @param array $args |
|
82 | + * @param array $widget_args |
|
83 | + * @param string $content |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
88 | 88 | |
89 | - // Is the shortcode set up correctly? |
|
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | - return aui()->alert( |
|
92 | - array( |
|
93 | - 'type' => 'warning', |
|
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - // Payment form or button? |
|
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
102 | - } else { |
|
103 | - return $this->handle_buy_item( $args ); |
|
104 | - } |
|
105 | - |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Displaying a payment form |
|
110 | - * |
|
111 | - * @return string |
|
112 | - */ |
|
89 | + // Is the shortcode set up correctly? |
|
90 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | + return aui()->alert( |
|
92 | + array( |
|
93 | + 'type' => 'warning', |
|
94 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + // Payment form or button? |
|
100 | + if ( ! empty( $args['form'] ) ) { |
|
101 | + return $this->handle_payment_form( $args ); |
|
102 | + } else { |
|
103 | + return $this->handle_buy_item( $args ); |
|
104 | + } |
|
105 | + |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Displaying a payment form |
|
110 | + * |
|
111 | + * @return string |
|
112 | + */ |
|
113 | 113 | protected function handle_payment_form( $args = array() ) { |
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
116 | - ob_start(); |
|
117 | - getpaid_display_payment_form( $args['form'] ); |
|
118 | - return ob_get_clean(); |
|
119 | - } |
|
115 | + if ( empty( $args['button'] ) ) { |
|
116 | + ob_start(); |
|
117 | + getpaid_display_payment_form( $args['form'] ); |
|
118 | + return ob_get_clean(); |
|
119 | + } |
|
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | - } |
|
121 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Displays a payment form button. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Displays a payment form button. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | protected function payment_form_button( $form, $button ) { |
130 | - return getpaid_get_payment_button( $button, $form ); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Selling an item |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
130 | + return getpaid_get_payment_button( $button, $form ); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Selling an item |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | 138 | protected function handle_buy_item( $args = array() ) { |
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
142 | - } |
|
140 | + if ( empty( $args['button'] ) ) { |
|
141 | + return $this->buy_item_form( $args['item'] ); |
|
142 | + } |
|
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Displays a buy item form. |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Displays a buy item form. |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | 153 | protected function buy_item_form( $item ) { |
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
155 | - ob_start(); |
|
156 | - getpaid_display_item_payment_form( $items ); |
|
157 | - return ob_get_clean(); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Displays a buy item button. |
|
162 | - * |
|
163 | - * @return string |
|
164 | - */ |
|
154 | + $items = getpaid_convert_items_to_array( $item ); |
|
155 | + ob_start(); |
|
156 | + getpaid_display_item_payment_form( $items ); |
|
157 | + return ob_get_clean(); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Displays a buy item button. |
|
162 | + * |
|
163 | + * @return string |
|
164 | + */ |
|
165 | 165 | protected function buy_item_button( $item, $button ) { |
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
166 | + return getpaid_get_payment_button( $button, null, $item ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -14,62 +14,62 @@ discard block |
||
14 | 14 | class GetPaid_Admin { |
15 | 15 | |
16 | 16 | /** |
17 | - * Local path to this plugins admin directory |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $admin_path; |
|
22 | - |
|
23 | - /** |
|
24 | - * Web path to this plugins admin directory |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
17 | + * Local path to this plugins admin directory |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $admin_path; |
|
22 | + |
|
23 | + /** |
|
24 | + * Web path to this plugins admin directory |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | 28 | public $admin_url; |
29 | 29 | |
30 | 30 | /** |
31 | - * Class constructor. |
|
32 | - */ |
|
33 | - public function __construct(){ |
|
31 | + * Class constructor. |
|
32 | + */ |
|
33 | + public function __construct(){ |
|
34 | 34 | |
35 | 35 | $this->admin_path = plugin_dir_path( __FILE__ ); |
36 | 36 | $this->admin_url = plugins_url( '/', __FILE__ ); |
37 | 37 | |
38 | 38 | if ( is_admin() ) { |
39 | - $this->init_admin_hooks(); |
|
39 | + $this->init_admin_hooks(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | - * Init action and filter hooks |
|
46 | - * |
|
47 | - */ |
|
48 | - private function init_admin_hooks() { |
|
45 | + * Init action and filter hooks |
|
46 | + * |
|
47 | + */ |
|
48 | + private function init_admin_hooks() { |
|
49 | 49 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
50 | 50 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
51 | 51 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
52 | 52 | add_action( 'admin_init', array( $this, 'activation_redirect') ); |
53 | 53 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
54 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
55 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
56 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
57 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
54 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
55 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
56 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
57 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | - * Register admin scripts |
|
63 | - * |
|
64 | - */ |
|
65 | - public function enqeue_scripts() { |
|
62 | + * Register admin scripts |
|
63 | + * |
|
64 | + */ |
|
65 | + public function enqeue_scripts() { |
|
66 | 66 | global $current_screen, $pagenow; |
67 | 67 | |
68 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
69 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
68 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
69 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
70 | 70 | |
71 | 71 | if ( ! empty( $current_screen->post_type ) ) { |
72 | - $page = $current_screen->post_type; |
|
72 | + $page = $current_screen->post_type; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // General styles. |
@@ -93,30 +93,30 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Payment form scripts. |
96 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
96 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
97 | 97 | $this->load_payment_form_scripts(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | if ( $page == 'wpinv-subscriptions' ) { |
101 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
102 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
103 | - } |
|
101 | + wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
102 | + wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
103 | + } |
|
104 | 104 | |
105 | - if ( $page == 'wpinv-reports' ) { |
|
106 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
107 | - } |
|
105 | + if ( $page == 'wpinv-reports' ) { |
|
106 | + wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
107 | + } |
|
108 | 108 | |
109 | - if ( $page == 'wpinv-subscriptions' ) { |
|
110 | - wp_enqueue_script( 'postbox' ); |
|
111 | - } |
|
109 | + if ( $page == 'wpinv-subscriptions' ) { |
|
110 | + wp_enqueue_script( 'postbox' ); |
|
111 | + } |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Returns admin js translations. |
|
117 | - * |
|
118 | - */ |
|
119 | - protected function get_admin_i18() { |
|
116 | + * Returns admin js translations. |
|
117 | + * |
|
118 | + */ |
|
119 | + protected function get_admin_i18() { |
|
120 | 120 | global $post; |
121 | 121 | |
122 | 122 | return array( |
@@ -157,32 +157,32 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | - * Loads payment form js. |
|
161 | - * |
|
162 | - */ |
|
163 | - protected function load_payment_form_scripts() { |
|
160 | + * Loads payment form js. |
|
161 | + * |
|
162 | + */ |
|
163 | + protected function load_payment_form_scripts() { |
|
164 | 164 | global $post; |
165 | 165 | |
166 | 166 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
167 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
168 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
167 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
168 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
169 | 169 | |
170 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
171 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
170 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
171 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
172 | 172 | |
173 | - wp_localize_script( |
|
173 | + wp_localize_script( |
|
174 | 174 | 'wpinv-admin-payment-form-script', |
175 | 175 | 'wpinvPaymentFormAdmin', |
176 | 176 | array( |
177 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
178 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
179 | - 'currency' => wpinv_currency_symbol(), |
|
180 | - 'position' => wpinv_currency_position(), |
|
181 | - 'decimals' => (int) wpinv_decimals(), |
|
182 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
183 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
184 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
185 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
177 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
178 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
179 | + 'currency' => wpinv_currency_symbol(), |
|
180 | + 'position' => wpinv_currency_position(), |
|
181 | + 'decimals' => (int) wpinv_decimals(), |
|
182 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
183 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
184 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
185 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
186 | 186 | ) |
187 | 187 | ); |
188 | 188 | |
@@ -191,20 +191,20 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | - * Add our classes to admin pages. |
|
194 | + * Add our classes to admin pages. |
|
195 | 195 | * |
196 | 196 | * @param string $classes |
197 | 197 | * @return string |
198 | - * |
|
199 | - */ |
|
198 | + * |
|
199 | + */ |
|
200 | 200 | public function admin_body_class( $classes ) { |
201 | - global $pagenow, $post, $current_screen; |
|
201 | + global $pagenow, $post, $current_screen; |
|
202 | 202 | |
203 | 203 | |
204 | 204 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
205 | 205 | |
206 | 206 | if ( ! empty( $current_screen->post_type ) ) { |
207 | - $page = $current_screen->post_type; |
|
207 | + $page = $current_screen->post_type; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -215,27 +215,27 @@ discard block |
||
215 | 215 | $classes .= ' wpinv-cpt wpinv'; |
216 | 216 | } |
217 | 217 | |
218 | - if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) { |
|
219 | - $classes .= ' wpi-editable-n'; |
|
220 | - } |
|
218 | + if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) { |
|
219 | + $classes .= ' wpi-editable-n'; |
|
220 | + } |
|
221 | 221 | |
222 | - return $classes; |
|
222 | + return $classes; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | - * Maybe show the AyeCode Connect Notice. |
|
227 | - */ |
|
228 | - public function init_ayecode_connect_helper(){ |
|
226 | + * Maybe show the AyeCode Connect Notice. |
|
227 | + */ |
|
228 | + public function init_ayecode_connect_helper(){ |
|
229 | 229 | |
230 | 230 | new AyeCode_Connect_Helper( |
231 | 231 | array( |
232 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
233 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
234 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
235 | - 'connect_button' => __("Connect Site","invoicing"), |
|
236 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
237 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
238 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
232 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
233 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
234 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
235 | + 'connect_button' => __("Connect Site","invoicing"), |
|
236 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
237 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
238 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
239 | 239 | ), |
240 | 240 | array( 'wpi-addons' ) |
241 | 241 | ); |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function activation_redirect() { |
249 | 249 | |
250 | - // Bail if no activation redirect. |
|
251 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
252 | - return; |
|
253 | - } |
|
250 | + // Bail if no activation redirect. |
|
251 | + if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
252 | + return; |
|
253 | + } |
|
254 | 254 | |
255 | - // Delete the redirect transient. |
|
256 | - delete_transient( '_wpinv_activation_redirect' ); |
|
255 | + // Delete the redirect transient. |
|
256 | + delete_transient( '_wpinv_activation_redirect' ); |
|
257 | 257 | |
258 | - // Bail if activating from network, or bulk |
|
259 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
260 | - return; |
|
261 | - } |
|
258 | + // Bail if activating from network, or bulk |
|
259 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
260 | + return; |
|
261 | + } |
|
262 | 262 | |
263 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
264 | - exit; |
|
263 | + wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
264 | + exit; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -276,150 +276,150 @@ discard block |
||
276 | 276 | |
277 | 277 | } |
278 | 278 | |
279 | - /** |
|
279 | + /** |
|
280 | 280 | * Sends a payment reminder to a customer. |
281 | - * |
|
282 | - * @param array $args |
|
281 | + * |
|
282 | + * @param array $args |
|
283 | 283 | */ |
284 | 284 | public function send_customer_invoice( $args ) { |
285 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
285 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
286 | 286 | |
287 | - if ( $sent ) { |
|
288 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
289 | - } else { |
|
290 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
291 | - } |
|
287 | + if ( $sent ) { |
|
288 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
289 | + } else { |
|
290 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
291 | + } |
|
292 | 292 | |
293 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
294 | - exit; |
|
295 | - } |
|
293 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
294 | + exit; |
|
295 | + } |
|
296 | 296 | |
297 | - /** |
|
297 | + /** |
|
298 | 298 | * Sends a payment reminder to a customer. |
299 | - * |
|
300 | - * @param array $args |
|
299 | + * |
|
300 | + * @param array $args |
|
301 | 301 | */ |
302 | 302 | public function send_customer_payment_reminder( $args ) { |
303 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
303 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
304 | 304 | |
305 | - if ( $sent ) { |
|
306 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
307 | - } else { |
|
308 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
309 | - } |
|
305 | + if ( $sent ) { |
|
306 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
307 | + } else { |
|
308 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
309 | + } |
|
310 | 310 | |
311 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
312 | - exit; |
|
313 | - } |
|
311 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
312 | + exit; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | /** |
316 | - * Returns an array of admin notices. |
|
317 | - * |
|
318 | - * @since 1.0.19 |
|
316 | + * Returns an array of admin notices. |
|
317 | + * |
|
318 | + * @since 1.0.19 |
|
319 | 319 | * @return array |
320 | - */ |
|
321 | - public function get_notices() { |
|
322 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
320 | + */ |
|
321 | + public function get_notices() { |
|
322 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
323 | 323 | return is_array( $notices ) ? $notices : array(); |
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Clears all admin notices |
|
328 | - * |
|
329 | - * @access public |
|
330 | - * @since 1.0.19 |
|
331 | - */ |
|
332 | - public function clear_notices() { |
|
333 | - delete_option( 'wpinv_admin_notices' ); |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Saves a new admin notice |
|
338 | - * |
|
339 | - * @access public |
|
340 | - * @since 1.0.19 |
|
341 | - */ |
|
342 | - public function save_notice( $type, $message ) { |
|
343 | - $notices = $this->get_notices(); |
|
344 | - |
|
345 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
346 | - $notices[ $type ] = array(); |
|
347 | - } |
|
348 | - |
|
349 | - $notices[ $type ][] = $message; |
|
350 | - |
|
351 | - update_option( 'wpinv_admin_notices', $notices ); |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Displays a success notice |
|
356 | - * |
|
357 | - * @param string $msg The message to qeue. |
|
358 | - * @access public |
|
359 | - * @since 1.0.19 |
|
360 | - */ |
|
361 | - public function show_success( $msg ) { |
|
362 | - $this->save_notice( 'success', $msg ); |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Displays a error notice |
|
367 | - * |
|
368 | - * @access public |
|
369 | - * @param string $msg The message to qeue. |
|
370 | - * @since 1.0.19 |
|
371 | - */ |
|
372 | - public function show_error( $msg ) { |
|
373 | - $this->save_notice( 'error', $msg ); |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Displays a warning notice |
|
378 | - * |
|
379 | - * @access public |
|
380 | - * @param string $msg The message to qeue. |
|
381 | - * @since 1.0.19 |
|
382 | - */ |
|
383 | - public function show_warning( $msg ) { |
|
384 | - $this->save_notice( 'warning', $msg ); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Displays a info notice |
|
389 | - * |
|
390 | - * @access public |
|
391 | - * @param string $msg The message to qeue. |
|
392 | - * @since 1.0.19 |
|
393 | - */ |
|
394 | - public function show_info( $msg ) { |
|
395 | - $this->save_notice( 'info', $msg ); |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * Show notices |
|
400 | - * |
|
401 | - * @access public |
|
402 | - * @since 1.0.19 |
|
403 | - */ |
|
404 | - public function show_notices() { |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Clears all admin notices |
|
328 | + * |
|
329 | + * @access public |
|
330 | + * @since 1.0.19 |
|
331 | + */ |
|
332 | + public function clear_notices() { |
|
333 | + delete_option( 'wpinv_admin_notices' ); |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Saves a new admin notice |
|
338 | + * |
|
339 | + * @access public |
|
340 | + * @since 1.0.19 |
|
341 | + */ |
|
342 | + public function save_notice( $type, $message ) { |
|
343 | + $notices = $this->get_notices(); |
|
344 | + |
|
345 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
346 | + $notices[ $type ] = array(); |
|
347 | + } |
|
348 | + |
|
349 | + $notices[ $type ][] = $message; |
|
350 | + |
|
351 | + update_option( 'wpinv_admin_notices', $notices ); |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Displays a success notice |
|
356 | + * |
|
357 | + * @param string $msg The message to qeue. |
|
358 | + * @access public |
|
359 | + * @since 1.0.19 |
|
360 | + */ |
|
361 | + public function show_success( $msg ) { |
|
362 | + $this->save_notice( 'success', $msg ); |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Displays a error notice |
|
367 | + * |
|
368 | + * @access public |
|
369 | + * @param string $msg The message to qeue. |
|
370 | + * @since 1.0.19 |
|
371 | + */ |
|
372 | + public function show_error( $msg ) { |
|
373 | + $this->save_notice( 'error', $msg ); |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Displays a warning notice |
|
378 | + * |
|
379 | + * @access public |
|
380 | + * @param string $msg The message to qeue. |
|
381 | + * @since 1.0.19 |
|
382 | + */ |
|
383 | + public function show_warning( $msg ) { |
|
384 | + $this->save_notice( 'warning', $msg ); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Displays a info notice |
|
389 | + * |
|
390 | + * @access public |
|
391 | + * @param string $msg The message to qeue. |
|
392 | + * @since 1.0.19 |
|
393 | + */ |
|
394 | + public function show_info( $msg ) { |
|
395 | + $this->save_notice( 'info', $msg ); |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * Show notices |
|
400 | + * |
|
401 | + * @access public |
|
402 | + * @since 1.0.19 |
|
403 | + */ |
|
404 | + public function show_notices() { |
|
405 | 405 | |
406 | 406 | $notices = $this->get_notices(); |
407 | 407 | $this->clear_notices(); |
408 | 408 | |
409 | - foreach ( $notices as $type => $messages ) { |
|
409 | + foreach ( $notices as $type => $messages ) { |
|
410 | 410 | |
411 | - if ( ! is_array( $messages ) ) { |
|
412 | - continue; |
|
413 | - } |
|
411 | + if ( ! is_array( $messages ) ) { |
|
412 | + continue; |
|
413 | + } |
|
414 | 414 | |
415 | 415 | $type = sanitize_key( $type ); |
416 | - foreach ( $messages as $message ) { |
|
416 | + foreach ( $messages as $message ) { |
|
417 | 417 | $message = wp_kses_post( $message ); |
418 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
418 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | } |
422 | 422 | |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | 425 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -175,122 +175,122 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
179 | 179 | |
180 | - // Setup possible parts |
|
181 | - $templates = array(); |
|
182 | - if ( isset( $name ) ) |
|
183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
184 | - $templates[] = $slug . '.php'; |
|
180 | + // Setup possible parts |
|
181 | + $templates = array(); |
|
182 | + if ( isset( $name ) ) |
|
183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
184 | + $templates[] = $slug . '.php'; |
|
185 | 185 | |
186 | - // Allow template parts to be filtered |
|
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
186 | + // Allow template parts to be filtered |
|
187 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | 188 | |
189 | - // Return the part that is found |
|
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
189 | + // Return the part that is found |
|
190 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
194 | - // No file found yet |
|
195 | - $located = false; |
|
194 | + // No file found yet |
|
195 | + $located = false; |
|
196 | 196 | |
197 | - // Try to find a template file |
|
198 | - foreach ( (array)$template_names as $template_name ) { |
|
197 | + // Try to find a template file |
|
198 | + foreach ( (array)$template_names as $template_name ) { |
|
199 | 199 | |
200 | - // Continue if template is empty |
|
201 | - if ( empty( $template_name ) ) |
|
202 | - continue; |
|
200 | + // Continue if template is empty |
|
201 | + if ( empty( $template_name ) ) |
|
202 | + continue; |
|
203 | 203 | |
204 | - // Trim off any slashes from the template name |
|
205 | - $template_name = ltrim( $template_name, '/' ); |
|
204 | + // Trim off any slashes from the template name |
|
205 | + $template_name = ltrim( $template_name, '/' ); |
|
206 | 206 | |
207 | - // try locating this template file by looping through the template paths |
|
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
207 | + // try locating this template file by looping through the template paths |
|
208 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
211 | - $located = $template_path . $template_name; |
|
212 | - break; |
|
213 | - } |
|
214 | - } |
|
210 | + if( file_exists( $template_path . $template_name ) ) { |
|
211 | + $located = $template_path . $template_name; |
|
212 | + break; |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
217 | - break; |
|
218 | - } |
|
219 | - } |
|
216 | + if( !empty( $located ) ) { |
|
217 | + break; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | + load_template( $located, $require_once ); |
|
223 | 223 | |
224 | - return $located; |
|
224 | + return $located; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | function wpinv_get_theme_template_paths() { |
228 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
228 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
229 | 229 | |
230 | - $file_paths = array( |
|
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
233 | - 100 => wpinv_get_templates_dir() |
|
234 | - ); |
|
230 | + $file_paths = array( |
|
231 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
233 | + 100 => wpinv_get_templates_dir() |
|
234 | + ); |
|
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
237 | 237 | |
238 | - // sort the file paths based on priority |
|
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
238 | + // sort the file paths based on priority |
|
239 | + ksort( $file_paths, SORT_NUMERIC ); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map( 'trailingslashit', $file_paths ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | - $pages = array(); |
|
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
246 | + $pages = array(); |
|
247 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | - return; |
|
254 | - } |
|
252 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | + return; |
|
254 | + } |
|
255 | 255 | |
256 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
256 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
257 | 257 | } |
258 | 258 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
259 | 259 | |
260 | 260 | function wpinv_add_body_classes( $class ) { |
261 | - $classes = (array)$class; |
|
261 | + $classes = (array)$class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
264 | - $classes[] = 'wpinv-checkout'; |
|
265 | - $classes[] = 'wpinv-page'; |
|
266 | - } |
|
263 | + if( wpinv_is_checkout() ) { |
|
264 | + $classes[] = 'wpinv-checkout'; |
|
265 | + $classes[] = 'wpinv-page'; |
|
266 | + } |
|
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
269 | - $classes[] = 'wpinv-success'; |
|
270 | - $classes[] = 'wpinv-page'; |
|
271 | - } |
|
268 | + if( wpinv_is_success_page() ) { |
|
269 | + $classes[] = 'wpinv-success'; |
|
270 | + $classes[] = 'wpinv-page'; |
|
271 | + } |
|
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
274 | - $classes[] = 'wpinv-failed-transaction'; |
|
275 | - $classes[] = 'wpinv-page'; |
|
276 | - } |
|
273 | + if( wpinv_is_failed_transaction_page() ) { |
|
274 | + $classes[] = 'wpinv-failed-transaction'; |
|
275 | + $classes[] = 'wpinv-page'; |
|
276 | + } |
|
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
279 | - $classes[] = 'wpinv-history'; |
|
280 | - $classes[] = 'wpinv-page'; |
|
281 | - } |
|
278 | + if( wpinv_is_invoice_history_page() ) { |
|
279 | + $classes[] = 'wpinv-history'; |
|
280 | + $classes[] = 'wpinv-page'; |
|
281 | + } |
|
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
284 | - $classes[] = 'wpinv-subscription'; |
|
285 | - $classes[] = 'wpinv-page'; |
|
286 | - } |
|
283 | + if( wpinv_is_subscriptions_history_page() ) { |
|
284 | + $classes[] = 'wpinv-subscription'; |
|
285 | + $classes[] = 'wpinv-page'; |
|
286 | + } |
|
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
289 | - $classes[] = 'wpinv-test-mode'; |
|
290 | - $classes[] = 'wpinv-page'; |
|
291 | - } |
|
288 | + if( wpinv_is_test_mode() ) { |
|
289 | + $classes[] = 'wpinv-test-mode'; |
|
290 | + $classes[] = 'wpinv-page'; |
|
291 | + } |
|
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique( $classes ); |
|
294 | 294 | } |
295 | 295 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
296 | 296 | |
@@ -992,21 +992,21 @@ discard block |
||
992 | 992 | |
993 | 993 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
994 | 994 | |
995 | - // Remove unavailable tags. |
|
995 | + // Remove unavailable tags. |
|
996 | 996 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
997 | 997 | |
998 | 998 | // Clean up white space. |
999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
999 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1000 | 1000 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
1001 | 1001 | |
1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1003 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1004 | 1004 | |
1005 | 1005 | // Add html breaks. |
1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1006 | + $formatted_address = implode( $separator, $formatted_address ); |
|
1007 | 1007 | |
1008 | - // We're done! |
|
1009 | - return $formatted_address; |
|
1008 | + // We're done! |
|
1009 | + return $formatted_address; |
|
1010 | 1010 | |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_empty_cart_message() { |
1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1211 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1498,10 +1498,10 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | if ( 0 == count( $form->get_items() ) ) { |
1500 | 1500 | echo aui()->alert( |
1501 | - array( |
|
1502 | - 'type' => 'warning', |
|
1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1504 | - ) |
|
1501 | + array( |
|
1502 | + 'type' => 'warning', |
|
1503 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1504 | + ) |
|
1505 | 1505 | ); |
1506 | 1506 | return; |
1507 | 1507 | } |
@@ -1517,21 +1517,21 @@ discard block |
||
1517 | 1517 | $invoice = wpinv_get_invoice( $invoice_id ); |
1518 | 1518 | |
1519 | 1519 | if ( empty( $invoice ) ) { |
1520 | - echo aui()->alert( |
|
1521 | - array( |
|
1522 | - 'type' => 'warning', |
|
1523 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | - ) |
|
1520 | + echo aui()->alert( |
|
1521 | + array( |
|
1522 | + 'type' => 'warning', |
|
1523 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | + ) |
|
1525 | 1525 | ); |
1526 | 1526 | return; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | if ( $invoice->is_paid() ) { |
1530 | - echo aui()->alert( |
|
1531 | - array( |
|
1532 | - 'type' => 'warning', |
|
1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1534 | - ) |
|
1530 | + echo aui()->alert( |
|
1531 | + array( |
|
1532 | + 'type' => 'warning', |
|
1533 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1534 | + ) |
|
1535 | 1535 | ); |
1536 | 1536 | return; |
1537 | 1537 | } |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - if ( ! empty( $items ) ) { |
|
1597 | + if ( ! empty( $items ) ) { |
|
1598 | 1598 | $items = esc_attr( $items ); |
1599 | 1599 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
1600 | 1600 | } |
@@ -14,70 +14,70 @@ discard block |
||
14 | 14 | class WPInv_Ajax { |
15 | 15 | |
16 | 16 | /** |
17 | - * Hook in ajax handlers. |
|
18 | - */ |
|
19 | - public static function init() { |
|
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | - self::add_ajax_events(); |
|
17 | + * Hook in ajax handlers. |
|
18 | + */ |
|
19 | + public static function init() { |
|
20 | + add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | + add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | + self::add_ajax_events(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Set GetPaid AJAX constant and headers. |
|
27 | - */ |
|
28 | - public static function define_ajax() { |
|
29 | - |
|
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | - } |
|
36 | - $GLOBALS['wpdb']->hide_errors(); |
|
37 | - } |
|
26 | + * Set GetPaid AJAX constant and headers. |
|
27 | + */ |
|
28 | + public static function define_ajax() { |
|
29 | + |
|
30 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | + getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | + getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | + if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | + } |
|
36 | + $GLOBALS['wpdb']->hide_errors(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Send headers for GetPaid Ajax Requests. |
|
43 | - * |
|
44 | - * @since 1.0.18 |
|
45 | - */ |
|
46 | - private static function wpinv_ajax_headers() { |
|
47 | - if ( ! headers_sent() ) { |
|
48 | - send_origin_headers(); |
|
49 | - send_nosniff_header(); |
|
50 | - nocache_headers(); |
|
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
54 | - } |
|
42 | + * Send headers for GetPaid Ajax Requests. |
|
43 | + * |
|
44 | + * @since 1.0.18 |
|
45 | + */ |
|
46 | + private static function wpinv_ajax_headers() { |
|
47 | + if ( ! headers_sent() ) { |
|
48 | + send_origin_headers(); |
|
49 | + send_nosniff_header(); |
|
50 | + nocache_headers(); |
|
51 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | + header( 'X-Robots-Tag: noindex' ); |
|
53 | + status_header( 200 ); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Check for GetPaid Ajax request and fire action. |
|
59 | - */ |
|
60 | - public static function do_wpinv_ajax() { |
|
61 | - global $wp_query; |
|
58 | + * Check for GetPaid Ajax request and fire action. |
|
59 | + */ |
|
60 | + public static function do_wpinv_ajax() { |
|
61 | + global $wp_query; |
|
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | - } |
|
63 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | + $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get( 'wpinv-ajax' ); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
70 | - self::wpinv_ajax_headers(); |
|
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
73 | - wp_die(); |
|
74 | - } |
|
69 | + if ( $action ) { |
|
70 | + self::wpinv_ajax_headers(); |
|
71 | + $action = sanitize_text_field( $action ); |
|
72 | + do_action( 'wpinv_ajax_' . $action ); |
|
73 | + wp_die(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Hook in ajax methods. |
|
80 | - */ |
|
79 | + * Hook in ajax methods. |
|
80 | + */ |
|
81 | 81 | public static function add_ajax_events() { |
82 | 82 | |
83 | 83 | // array( 'event' => is_frontend ) |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | // Is the request set up correctly? |
263 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
264 | - echo aui()->alert( |
|
265 | - array( |
|
266 | - 'type' => 'warning', |
|
267 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
268 | - ) |
|
263 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
264 | + echo aui()->alert( |
|
265 | + array( |
|
266 | + 'type' => 'warning', |
|
267 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
268 | + ) |
|
269 | 269 | ); |
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Payment form or button? |
274 | - if ( ! empty( $_GET['form'] ) ) { |
|
274 | + if ( ! empty( $_GET['form'] ) ) { |
|
275 | 275 | getpaid_display_payment_form( $_GET['form'] ); |
276 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
277 | - getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
276 | + } else if( ! empty( $_GET['invoice'] ) ) { |
|
277 | + getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
278 | 278 | } else { |
279 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
280 | - getpaid_display_item_payment_form( $items ); |
|
279 | + $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
280 | + getpaid_display_item_payment_form( $items ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | exit; |
@@ -13,128 +13,128 @@ |
||
13 | 13 | class GetPaid_Payment_Forms { |
14 | 14 | |
15 | 15 | /** |
16 | - * Class constructor |
|
17 | - * |
|
18 | - */ |
|
19 | - public function __construct() { |
|
20 | - |
|
21 | - // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
22 | - add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
23 | - add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
24 | - |
|
25 | - // Sync form amount whenever invoice statuses change. |
|
26 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
27 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
28 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
29 | - |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Increments a form's revenue whenever there is a payment. |
|
34 | - * |
|
35 | - * @param WPInv_Invoice $invoice |
|
36 | - */ |
|
37 | - public function increment_form_revenue( $invoice ) { |
|
38 | - |
|
39 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
40 | - if ( $form->get_id() ) { |
|
41 | - $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
42 | - $form->save(); |
|
43 | - } |
|
44 | - |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Decreases form revenue whenever invoice payment changes. |
|
49 | - * |
|
50 | - * @param WPInv_Invoice $invoice |
|
51 | - */ |
|
52 | - public function decrease_form_revenue( $invoice ) { |
|
53 | - |
|
54 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
55 | - if ( $form->get_id() ) { |
|
56 | - $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
57 | - $form->save(); |
|
58 | - } |
|
59 | - |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Updates a form's failed amount. |
|
64 | - * |
|
65 | - * @param WPInv_Invoice $invoice |
|
66 | - * @param string $from |
|
67 | - * @param string $to |
|
68 | - */ |
|
69 | - public function update_form_failed_amount( $invoice, $from, $to ) { |
|
70 | - |
|
71 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
72 | - if ( $form->get_id() ) { |
|
73 | - return; |
|
74 | - } |
|
75 | - |
|
76 | - if ( 'wpi-failed' == $from ) { |
|
77 | - $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
78 | - $form->save(); |
|
79 | - } |
|
80 | - |
|
81 | - if ( 'wpi-failed' == $to ) { |
|
82 | - $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
83 | - $form->save(); |
|
84 | - } |
|
85 | - |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Updates a form's refunded amount. |
|
90 | - * |
|
91 | - * @param WPInv_Invoice $invoice |
|
92 | - * @param string $from |
|
93 | - * @param string $to |
|
94 | - */ |
|
95 | - public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
96 | - |
|
97 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
98 | - if ( $form->get_id() ) { |
|
99 | - return; |
|
100 | - } |
|
101 | - |
|
102 | - if ( 'wpi-refunded' == $from ) { |
|
103 | - $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
104 | - $form->save(); |
|
105 | - } |
|
106 | - |
|
107 | - if ( 'wpi-refunded' == $to ) { |
|
108 | - $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
109 | - $form->save(); |
|
110 | - } |
|
111 | - |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Updates a form's cancelled amount. |
|
116 | - * |
|
117 | - * @param WPInv_Invoice $invoice |
|
118 | - * @param string $from |
|
119 | - * @param string $to |
|
120 | - */ |
|
121 | - public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
122 | - |
|
123 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
124 | - if ( $form->get_id() ) { |
|
125 | - return; |
|
126 | - } |
|
127 | - |
|
128 | - if ( 'wpi-cancelled' == $from ) { |
|
129 | - $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
130 | - $form->save(); |
|
131 | - } |
|
132 | - |
|
133 | - if ( 'wpi-cancelled' == $to ) { |
|
134 | - $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
135 | - $form->save(); |
|
136 | - } |
|
137 | - |
|
138 | - } |
|
16 | + * Class constructor |
|
17 | + * |
|
18 | + */ |
|
19 | + public function __construct() { |
|
20 | + |
|
21 | + // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
22 | + add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
23 | + add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
24 | + |
|
25 | + // Sync form amount whenever invoice statuses change. |
|
26 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
27 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
28 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
29 | + |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Increments a form's revenue whenever there is a payment. |
|
34 | + * |
|
35 | + * @param WPInv_Invoice $invoice |
|
36 | + */ |
|
37 | + public function increment_form_revenue( $invoice ) { |
|
38 | + |
|
39 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
40 | + if ( $form->get_id() ) { |
|
41 | + $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
42 | + $form->save(); |
|
43 | + } |
|
44 | + |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Decreases form revenue whenever invoice payment changes. |
|
49 | + * |
|
50 | + * @param WPInv_Invoice $invoice |
|
51 | + */ |
|
52 | + public function decrease_form_revenue( $invoice ) { |
|
53 | + |
|
54 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
55 | + if ( $form->get_id() ) { |
|
56 | + $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
57 | + $form->save(); |
|
58 | + } |
|
59 | + |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Updates a form's failed amount. |
|
64 | + * |
|
65 | + * @param WPInv_Invoice $invoice |
|
66 | + * @param string $from |
|
67 | + * @param string $to |
|
68 | + */ |
|
69 | + public function update_form_failed_amount( $invoice, $from, $to ) { |
|
70 | + |
|
71 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
72 | + if ( $form->get_id() ) { |
|
73 | + return; |
|
74 | + } |
|
75 | + |
|
76 | + if ( 'wpi-failed' == $from ) { |
|
77 | + $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
78 | + $form->save(); |
|
79 | + } |
|
80 | + |
|
81 | + if ( 'wpi-failed' == $to ) { |
|
82 | + $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
83 | + $form->save(); |
|
84 | + } |
|
85 | + |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Updates a form's refunded amount. |
|
90 | + * |
|
91 | + * @param WPInv_Invoice $invoice |
|
92 | + * @param string $from |
|
93 | + * @param string $to |
|
94 | + */ |
|
95 | + public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
96 | + |
|
97 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
98 | + if ( $form->get_id() ) { |
|
99 | + return; |
|
100 | + } |
|
101 | + |
|
102 | + if ( 'wpi-refunded' == $from ) { |
|
103 | + $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
104 | + $form->save(); |
|
105 | + } |
|
106 | + |
|
107 | + if ( 'wpi-refunded' == $to ) { |
|
108 | + $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
109 | + $form->save(); |
|
110 | + } |
|
111 | + |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Updates a form's cancelled amount. |
|
116 | + * |
|
117 | + * @param WPInv_Invoice $invoice |
|
118 | + * @param string $from |
|
119 | + * @param string $to |
|
120 | + */ |
|
121 | + public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
122 | + |
|
123 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
124 | + if ( $form->get_id() ) { |
|
125 | + return; |
|
126 | + } |
|
127 | + |
|
128 | + if ( 'wpi-cancelled' == $from ) { |
|
129 | + $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
130 | + $form->save(); |
|
131 | + } |
|
132 | + |
|
133 | + if ( 'wpi-cancelled' == $to ) { |
|
134 | + $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
135 | + $form->save(); |
|
136 | + } |
|
137 | + |
|
138 | + } |
|
139 | 139 | |
140 | 140 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; // Exit if accessed directly |
|
10 | + exit; // Exit if accessed directly |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | class GetPaid_Meta_Box_Payment_Form { |
17 | 17 | |
18 | 18 | /** |
19 | - * Output the metabox. |
|
20 | - * |
|
21 | - * @param WP_Post $post |
|
22 | - */ |
|
19 | + * Output the metabox. |
|
20 | + * |
|
21 | + * @param WP_Post $post |
|
22 | + */ |
|
23 | 23 | public static function output( $post ) { |
24 | 24 | ?> |
25 | 25 | <div id="wpinv-form-builder" class="bsui"> |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Save meta box data. |
|
90 | - * |
|
91 | - * @param int $post_id |
|
92 | - */ |
|
93 | - public static function save( $post_id ) { |
|
89 | + * Save meta box data. |
|
90 | + * |
|
91 | + * @param int $post_id |
|
92 | + */ |
|
93 | + public static function save( $post_id ) { |
|
94 | 94 | |
95 | 95 | // Prepare the form. |
96 | 96 | $form = new GetPaid_Payment_Form( $post_id ); |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | - * Converts an array fo form items to objects. |
|
125 | - * |
|
126 | - * @param array $items |
|
127 | - */ |
|
128 | - public static function item_to_objects( $items ) { |
|
124 | + * Converts an array fo form items to objects. |
|
125 | + * |
|
126 | + * @param array $items |
|
127 | + */ |
|
128 | + public static function item_to_objects( $items ) { |
|
129 | 129 | |
130 | 130 | $objects = array(); |
131 | 131 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Discount_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the discount. |
@@ -368,34 +368,34 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Save meta box data. |
|
372 | - * |
|
373 | - * @param int $post_id |
|
374 | - */ |
|
375 | - public static function save( $post_id ) { |
|
371 | + * Save meta box data. |
|
372 | + * |
|
373 | + * @param int $post_id |
|
374 | + */ |
|
375 | + public static function save( $post_id ) { |
|
376 | 376 | |
377 | 377 | // Prepare the discount. |
378 | 378 | $discount = new WPInv_Discount( $post_id ); |
379 | 379 | |
380 | 380 | // Load new data. |
381 | 381 | $discount->set_props( |
382 | - array( |
|
383 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
384 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
385 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
386 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
387 | - 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
382 | + array( |
|
383 | + 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
384 | + 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
385 | + 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
386 | + 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
387 | + 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
388 | 388 | 'type' => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null, |
389 | - 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
390 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(), |
|
391 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(), |
|
392 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
393 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
394 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
395 | - ) |
|
389 | + 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
390 | + 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(), |
|
391 | + 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(), |
|
392 | + 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
393 | + 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
394 | + 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
395 | + ) |
|
396 | 396 | ); |
397 | 397 | |
398 | - $discount->save(); |
|
399 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
400 | - } |
|
398 | + $discount->save(); |
|
399 | + do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
400 | + } |
|
401 | 401 | } |
@@ -12,108 +12,108 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Fees { |
14 | 14 | |
15 | - /** |
|
16 | - * The fee validation error. |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $fee_error; |
|
20 | - |
|
21 | - /** |
|
22 | - * Submission fees. |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $fees = array(); |
|
15 | + /** |
|
16 | + * The fee validation error. |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $fee_error; |
|
20 | + |
|
21 | + /** |
|
22 | + * Submission fees. |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $fees = array(); |
|
26 | + |
|
27 | + /** |
|
28 | + * Class constructor |
|
29 | + * |
|
30 | + * @param GetPaid_Payment_Form_Submission $submission |
|
31 | + */ |
|
32 | + public function __construct( $submission ) { |
|
33 | + |
|
34 | + // Process any existing invoice fees. |
|
35 | + if ( $submission->has_invoice() ) { |
|
36 | + $this->fees = $submission->get_invoice()->get_fees(); |
|
37 | + } |
|
38 | + |
|
39 | + // Process price fields. |
|
40 | + $data = $submission->get_data(); |
|
41 | + $payment_form = $submission->get_payment_form(); |
|
42 | + |
|
43 | + foreach ( $payment_form->get_elements() as $element ) { |
|
44 | + |
|
45 | + if ( 'price_input' == $element['type'] ) { |
|
46 | + $this->process_price_input( $element, $data ); |
|
47 | + } |
|
48 | + |
|
49 | + if ( 'price_select' == $element['type'] ) { |
|
50 | + $this->process_price_select( $element, $data ); |
|
51 | + } |
|
52 | + |
|
53 | + } |
|
54 | + |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Process a price input field. |
|
59 | + * |
|
60 | + * @param array $element |
|
61 | + * @param array $data |
|
62 | + */ |
|
63 | + public function process_price_input( $element, $data ) { |
|
64 | + |
|
65 | + // Abort if not passed. |
|
66 | + if ( empty( $data[ $element['id'] ] ) ) { |
|
67 | + return; |
|
68 | + } |
|
69 | + |
|
70 | + $amount = (float) wpinv_sanitize_amount( $data[ $element['id'] ] ); |
|
71 | + $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] ); |
|
72 | + |
|
73 | + if ( $amount < $minimum ) { |
|
74 | + throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) ); |
|
75 | + } |
|
76 | + |
|
77 | + $this->fees[ $element['label'] ] = array( |
|
78 | + 'name' => $element['label'], |
|
79 | + 'initial_fee' => $amount, |
|
80 | + 'recurring_fee' => 0, |
|
81 | + ); |
|
82 | + |
|
83 | + } |
|
26 | 84 | |
27 | 85 | /** |
28 | - * Class constructor |
|
29 | - * |
|
30 | - * @param GetPaid_Payment_Form_Submission $submission |
|
31 | - */ |
|
32 | - public function __construct( $submission ) { |
|
33 | - |
|
34 | - // Process any existing invoice fees. |
|
35 | - if ( $submission->has_invoice() ) { |
|
36 | - $this->fees = $submission->get_invoice()->get_fees(); |
|
37 | - } |
|
38 | - |
|
39 | - // Process price fields. |
|
40 | - $data = $submission->get_data(); |
|
41 | - $payment_form = $submission->get_payment_form(); |
|
42 | - |
|
43 | - foreach ( $payment_form->get_elements() as $element ) { |
|
44 | - |
|
45 | - if ( 'price_input' == $element['type'] ) { |
|
46 | - $this->process_price_input( $element, $data ); |
|
47 | - } |
|
48 | - |
|
49 | - if ( 'price_select' == $element['type'] ) { |
|
50 | - $this->process_price_select( $element, $data ); |
|
51 | - } |
|
52 | - |
|
53 | - } |
|
54 | - |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Process a price input field. |
|
59 | - * |
|
60 | - * @param array $element |
|
61 | - * @param array $data |
|
62 | - */ |
|
63 | - public function process_price_input( $element, $data ) { |
|
64 | - |
|
65 | - // Abort if not passed. |
|
66 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
67 | - return; |
|
68 | - } |
|
69 | - |
|
70 | - $amount = (float) wpinv_sanitize_amount( $data[ $element['id'] ] ); |
|
71 | - $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] ); |
|
72 | - |
|
73 | - if ( $amount < $minimum ) { |
|
74 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) ); |
|
75 | - } |
|
76 | - |
|
77 | - $this->fees[ $element['label'] ] = array( |
|
78 | - 'name' => $element['label'], |
|
79 | - 'initial_fee' => $amount, |
|
80 | - 'recurring_fee' => 0, |
|
81 | - ); |
|
82 | - |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Process a price select field. |
|
87 | - * |
|
88 | - * @param array $element |
|
89 | - * @param array $data |
|
90 | - */ |
|
91 | - public function process_price_select( $element, $data ) { |
|
92 | - |
|
93 | - // Abort if not passed. |
|
94 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
95 | - return; |
|
96 | - } |
|
97 | - |
|
98 | - $options = getpaid_convert_price_string_to_options( $element['options'] ); |
|
99 | - $selected = wpinv_parse_list( $data[ $element['id'] ] ); |
|
100 | - $total = 0; |
|
101 | - |
|
102 | - foreach ( $selected as $price ) { |
|
103 | - |
|
104 | - if ( ! isset( $options[ $price ] ) ) { |
|
105 | - throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) ); |
|
106 | - } |
|
107 | - |
|
108 | - $total += (float) wpinv_sanitize_amount( $price ); |
|
109 | - } |
|
110 | - |
|
111 | - $this->fees[ $element['label'] ] = array( |
|
112 | - 'name' => $element['label'], |
|
113 | - 'initial_fee' => $total, |
|
114 | - 'recurring_fee' => 0, |
|
115 | - ); |
|
116 | - |
|
117 | - } |
|
86 | + * Process a price select field. |
|
87 | + * |
|
88 | + * @param array $element |
|
89 | + * @param array $data |
|
90 | + */ |
|
91 | + public function process_price_select( $element, $data ) { |
|
92 | + |
|
93 | + // Abort if not passed. |
|
94 | + if ( empty( $data[ $element['id'] ] ) ) { |
|
95 | + return; |
|
96 | + } |
|
97 | + |
|
98 | + $options = getpaid_convert_price_string_to_options( $element['options'] ); |
|
99 | + $selected = wpinv_parse_list( $data[ $element['id'] ] ); |
|
100 | + $total = 0; |
|
101 | + |
|
102 | + foreach ( $selected as $price ) { |
|
103 | + |
|
104 | + if ( ! isset( $options[ $price ] ) ) { |
|
105 | + throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) ); |
|
106 | + } |
|
107 | + |
|
108 | + $total += (float) wpinv_sanitize_amount( $price ); |
|
109 | + } |
|
110 | + |
|
111 | + $this->fees[ $element['label'] ] = array( |
|
112 | + 'name' => $element['label'], |
|
113 | + 'initial_fee' => $total, |
|
114 | + 'recurring_fee' => 0, |
|
115 | + ); |
|
116 | + |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } |