@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * Hook in ajax handlers. |
| 18 | 18 | */ |
| 19 | 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 ); |
|
| 20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
| 21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
| 22 | 22 | self::add_ajax_events(); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public static function define_ajax() { |
| 29 | 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 ); |
|
| 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 | 35 | } |
| 36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
| 37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * @since 1.0.18 |
| 45 | 45 | */ |
| 46 | 46 | private static function wpinv_ajax_headers() { |
| 47 | - if ( ! headers_sent() ) { |
|
| 47 | + if (!headers_sent()) { |
|
| 48 | 48 | send_origin_headers(); |
| 49 | 49 | send_nosniff_header(); |
| 50 | 50 | nocache_headers(); |
| 51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 52 | - header( 'X-Robots-Tag: noindex' ); |
|
| 53 | - status_header( 200 ); |
|
| 51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
| 52 | + header('X-Robots-Tag: noindex'); |
|
| 53 | + status_header(200); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | public static function do_wpinv_ajax() { |
| 61 | 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'] ) ) ); |
|
| 63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
| 67 | + $action = $wp_query->get('wpinv-ajax'); |
|
| 68 | 68 | |
| 69 | - if ( $action ) { |
|
| 69 | + if ($action) { |
|
| 70 | 70 | self::wpinv_ajax_headers(); |
| 71 | - $action = sanitize_text_field( $action ); |
|
| 72 | - do_action( 'wpinv_ajax_' . $action ); |
|
| 71 | + $action = sanitize_text_field($action); |
|
| 72 | + do_action('wpinv_ajax_' . $action); |
|
| 73 | 73 | wp_die(); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -101,36 +101,36 @@ discard block |
||
| 101 | 101 | 'payment_form_refresh_prices' => true, |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
| 105 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 106 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 104 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
| 105 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 106 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 107 | 107 | |
| 108 | - if ( $nopriv ) { |
|
| 109 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 110 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 111 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 108 | + if ($nopriv) { |
|
| 109 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 110 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 111 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public static function add_note() { |
| 117 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
| 117 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
| 118 | 118 | |
| 119 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 119 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 120 | 120 | die(-1); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $post_id = absint( $_POST['post_id'] ); |
|
| 124 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
| 125 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
| 123 | + $post_id = absint($_POST['post_id']); |
|
| 124 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
| 125 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
| 126 | 126 | |
| 127 | 127 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
| 128 | 128 | |
| 129 | - if ( $post_id > 0 ) { |
|
| 130 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
| 129 | + if ($post_id > 0) { |
|
| 130 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
| 131 | 131 | |
| 132 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
| 133 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
| 132 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
| 133 | + wpinv_get_invoice_note_line_item($note_id); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -138,16 +138,16 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | public static function delete_note() { |
| 141 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
| 141 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
| 142 | 142 | |
| 143 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 143 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 144 | 144 | die(-1); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $note_id = (int)$_POST['note_id']; |
|
| 147 | + $note_id = (int) $_POST['note_id']; |
|
| 148 | 148 | |
| 149 | - if ( $note_id > 0 ) { |
|
| 150 | - wp_delete_comment( $note_id, true ); |
|
| 149 | + if ($note_id > 0) { |
|
| 150 | + wp_delete_comment($note_id, true); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | die(); |
@@ -165,34 +165,34 @@ discard block |
||
| 165 | 165 | public static function get_billing_details() { |
| 166 | 166 | |
| 167 | 167 | // Verify nonce. |
| 168 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 168 | + check_ajax_referer('wpinv-nonce'); |
|
| 169 | 169 | |
| 170 | 170 | // Can the user manage the plugin? |
| 171 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 171 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 172 | 172 | die(-1); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // Do we have a user id? |
| 176 | 176 | $user_id = $_GET['user_id']; |
| 177 | 177 | |
| 178 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 178 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 179 | 179 | die(-1); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Fetch the billing details. |
| 183 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
| 184 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
| 183 | + $billing_details = wpinv_get_user_address($user_id); |
|
| 184 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
| 185 | 185 | |
| 186 | 186 | // unset the user id and email. |
| 187 | - $to_ignore = array( 'user_id', 'email' ); |
|
| 187 | + $to_ignore = array('user_id', 'email'); |
|
| 188 | 188 | |
| 189 | - foreach ( $to_ignore as $key ) { |
|
| 190 | - if ( isset( $billing_details[ $key ] ) ) { |
|
| 191 | - unset( $billing_details[ $key ] ); |
|
| 189 | + foreach ($to_ignore as $key) { |
|
| 190 | + if (isset($billing_details[$key])) { |
|
| 191 | + unset($billing_details[$key]); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - wp_send_json_success( $billing_details ); |
|
| 195 | + wp_send_json_success($billing_details); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,47 +202,47 @@ discard block |
||
| 202 | 202 | public static function check_new_user_email() { |
| 203 | 203 | |
| 204 | 204 | // Verify nonce. |
| 205 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 205 | + check_ajax_referer('wpinv-nonce'); |
|
| 206 | 206 | |
| 207 | 207 | // Can the user manage the plugin? |
| 208 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 208 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 209 | 209 | die(-1); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // We need an email address. |
| 213 | - if ( empty( $_GET['email'] ) ) { |
|
| 214 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
| 213 | + if (empty($_GET['email'])) { |
|
| 214 | + _e("Provide the new user's email address", 'invoicing'); |
|
| 215 | 215 | exit; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Ensure the email is valid. |
| 219 | - $email = sanitize_text_field( $_GET['email'] ); |
|
| 220 | - if ( ! is_email( $email ) ) { |
|
| 221 | - _e( 'Invalid email address', 'invoicing' ); |
|
| 219 | + $email = sanitize_text_field($_GET['email']); |
|
| 220 | + if (!is_email($email)) { |
|
| 221 | + _e('Invalid email address', 'invoicing'); |
|
| 222 | 222 | exit; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // And it does not exist. |
| 226 | - if ( email_exists( $email ) ) { |
|
| 227 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
| 226 | + if (email_exists($email)) { |
|
| 227 | + _e('A user with this email address already exists', 'invoicing'); |
|
| 228 | 228 | exit; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - wp_send_json_success( true ); |
|
| 231 | + wp_send_json_success(true); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | public static function run_tool() { |
| 235 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 236 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 235 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 236 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 237 | 237 | die(-1); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
| 240 | + $tool = sanitize_text_field($_POST['tool']); |
|
| 241 | 241 | |
| 242 | - do_action( 'wpinv_run_tool' ); |
|
| 242 | + do_action('wpinv_run_tool'); |
|
| 243 | 243 | |
| 244 | - if ( !empty( $tool ) ) { |
|
| 245 | - do_action( 'wpinv_tool_' . $tool ); |
|
| 244 | + if (!empty($tool)) { |
|
| 245 | + do_action('wpinv_tool_' . $tool); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -252,27 +252,27 @@ discard block |
||
| 252 | 252 | public static function get_payment_form() { |
| 253 | 253 | |
| 254 | 254 | // Check nonce. |
| 255 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 255 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 256 | 256 | |
| 257 | 257 | // Is the request set up correctly? |
| 258 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 258 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
| 259 | 259 | echo aui()->alert( |
| 260 | 260 | array( |
| 261 | 261 | 'type' => 'warning', |
| 262 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 262 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
| 263 | 263 | ) |
| 264 | 264 | ); |
| 265 | 265 | exit; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Payment form or button? |
| 269 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 270 | - getpaid_display_payment_form( urldecode( $_GET['form'] ) ); |
|
| 271 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 272 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 269 | + if (!empty($_GET['form'])) { |
|
| 270 | + getpaid_display_payment_form(urldecode($_GET['form'])); |
|
| 271 | + } else if (!empty($_GET['invoice'])) { |
|
| 272 | + getpaid_display_invoice_payment_form(urldecode($_GET['invoice'])); |
|
| 273 | 273 | } else { |
| 274 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 275 | - getpaid_display_item_payment_form( $items ); |
|
| 274 | + $items = getpaid_convert_items_to_array(urldecode($_GET['item'])); |
|
| 275 | + getpaid_display_item_payment_form($items); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | exit; |
@@ -287,17 +287,17 @@ discard block |
||
| 287 | 287 | public static function payment_form() { |
| 288 | 288 | |
| 289 | 289 | // Check nonce. |
| 290 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 290 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 291 | 291 | |
| 292 | 292 | // ... form fields... |
| 293 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 294 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
| 293 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
| 294 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
| 295 | 295 | exit; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // Process the payment form. |
| 299 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
| 300 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
| 299 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
| 300 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
| 301 | 301 | $checkout->process_checkout(); |
| 302 | 302 | |
| 303 | 303 | exit; |
@@ -310,55 +310,55 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | public static function get_payment_form_states_field() { |
| 312 | 312 | |
| 313 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
| 313 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
| 314 | 314 | exit; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $elements = getpaid_get_payment_form_elements( $_GET['form'] ); |
|
| 317 | + $elements = getpaid_get_payment_form_elements($_GET['form']); |
|
| 318 | 318 | |
| 319 | - if ( empty( $elements ) ) { |
|
| 319 | + if (empty($elements)) { |
|
| 320 | 320 | exit; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | $address_fields = array(); |
| 324 | - foreach ( $elements as $element ) { |
|
| 325 | - if ( 'address' === $element['type'] ) { |
|
| 324 | + foreach ($elements as $element) { |
|
| 325 | + if ('address' === $element['type']) { |
|
| 326 | 326 | $address_fields = $element; |
| 327 | 327 | break; |
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( empty( $address_fields ) ) { |
|
| 331 | + if (empty($address_fields)) { |
|
| 332 | 332 | exit; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
| 335 | + foreach ($address_fields['fields'] as $address_field) { |
|
| 336 | 336 | |
| 337 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
| 337 | + if ('wpinv_state' == $address_field['name']) { |
|
| 338 | 338 | |
| 339 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
| 340 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
| 341 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
| 342 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
| 343 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
| 344 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
| 339 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
| 340 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
| 341 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
| 342 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
| 343 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
| 344 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
| 345 | 345 | |
| 346 | - if ( ! empty( $address_field['required'] ) ) { |
|
| 346 | + if (!empty($address_field['required'])) { |
|
| 347 | 347 | $label .= "<span class='text-danger'> *</span>"; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - $html = getpaid_get_states_select_markup ( |
|
| 351 | - sanitize_text_field( $_GET['country'] ), |
|
| 350 | + $html = getpaid_get_states_select_markup( |
|
| 351 | + sanitize_text_field($_GET['country']), |
|
| 352 | 352 | $value, |
| 353 | 353 | $placeholder, |
| 354 | 354 | $label, |
| 355 | 355 | $description, |
| 356 | - ! empty( $address_field['required'] ), |
|
| 356 | + !empty($address_field['required']), |
|
| 357 | 357 | $wrap_class, |
| 358 | - wpinv_clean( $_GET['name'] ) |
|
| 358 | + wpinv_clean($_GET['name']) |
|
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | - wp_send_json_success( $html ); |
|
| 361 | + wp_send_json_success($html); |
|
| 362 | 362 | exit; |
| 363 | 363 | |
| 364 | 364 | } |
@@ -374,56 +374,56 @@ discard block |
||
| 374 | 374 | public static function recalculate_invoice_totals() { |
| 375 | 375 | |
| 376 | 376 | // Verify nonce. |
| 377 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 377 | + check_ajax_referer('wpinv-nonce'); |
|
| 378 | 378 | |
| 379 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 379 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 380 | 380 | exit; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // We need an invoice. |
| 384 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 384 | + if (empty($_POST['post_id'])) { |
|
| 385 | 385 | exit; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | // Fetch the invoice. |
| 389 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 389 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 390 | 390 | |
| 391 | 391 | // Ensure it exists. |
| 392 | - if ( ! $invoice->get_id() ) { |
|
| 392 | + if (!$invoice->get_id()) { |
|
| 393 | 393 | exit; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // Maybe set the country, state, currency. |
| 397 | - foreach ( array( 'country', 'state', 'currency' ) as $key ) { |
|
| 398 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 397 | + foreach (array('country', 'state', 'currency') as $key) { |
|
| 398 | + if (isset($_POST[$key])) { |
|
| 399 | 399 | $method = "set_$key"; |
| 400 | - $invoice->$method( $_POST[ $key ] ); |
|
| 400 | + $invoice->$method($_POST[$key]); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // Maybe disable taxes. |
| 405 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
| 405 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
| 406 | 406 | |
| 407 | 407 | // Recalculate totals. |
| 408 | 408 | $invoice->recalculate_total(); |
| 409 | 409 | |
| 410 | - $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
| 410 | + $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
| 411 | 411 | |
| 412 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
| 413 | - $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() ); |
|
| 414 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
| 412 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
| 413 | + $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency()); |
|
| 414 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $totals = array( |
| 418 | - 'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ), |
|
| 419 | - 'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ), |
|
| 420 | - 'tax' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ), |
|
| 418 | + 'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()), |
|
| 419 | + 'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()), |
|
| 420 | + 'tax' => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()), |
|
| 421 | 421 | 'total' => $total, |
| 422 | 422 | ); |
| 423 | 423 | |
| 424 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
| 424 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
| 425 | 425 | |
| 426 | - wp_send_json_success( compact( 'totals' ) ); |
|
| 426 | + wp_send_json_success(compact('totals')); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -432,33 +432,33 @@ discard block |
||
| 432 | 432 | public static function get_invoice_items() { |
| 433 | 433 | |
| 434 | 434 | // Verify nonce. |
| 435 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 435 | + check_ajax_referer('wpinv-nonce'); |
|
| 436 | 436 | |
| 437 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 437 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 438 | 438 | exit; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | // We need an invoice and items. |
| 442 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 442 | + if (empty($_POST['post_id'])) { |
|
| 443 | 443 | exit; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | // Fetch the invoice. |
| 447 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 447 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 448 | 448 | |
| 449 | 449 | // Ensure it exists. |
| 450 | - if ( ! $invoice->get_id() ) { |
|
| 450 | + if (!$invoice->get_id()) { |
|
| 451 | 451 | exit; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | // Return an array of invoice items. |
| 455 | 455 | $items = array(); |
| 456 | 456 | |
| 457 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
| 458 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 457 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
| 458 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - wp_send_json_success( compact( 'items' ) ); |
|
| 461 | + wp_send_json_success(compact('items')); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -467,50 +467,50 @@ discard block |
||
| 467 | 467 | public static function edit_invoice_item() { |
| 468 | 468 | |
| 469 | 469 | // Verify nonce. |
| 470 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 470 | + check_ajax_referer('wpinv-nonce'); |
|
| 471 | 471 | |
| 472 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 472 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 473 | 473 | exit; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | // We need an invoice and item details. |
| 477 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
| 477 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
| 478 | 478 | exit; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // Fetch the invoice. |
| 482 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 482 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 483 | 483 | |
| 484 | 484 | // Ensure it exists and its not been paid for. |
| 485 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 485 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 486 | 486 | exit; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | // Format the data. |
| 490 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
| 490 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
| 491 | 491 | |
| 492 | 492 | // Ensure that we have an item id. |
| 493 | - if ( empty( $data['id'] ) ) { |
|
| 493 | + if (empty($data['id'])) { |
|
| 494 | 494 | exit; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // Abort if the invoice does not have the specified item. |
| 498 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
| 498 | + $item = $invoice->get_item((int) $data['id']); |
|
| 499 | 499 | |
| 500 | - if ( empty( $item ) ) { |
|
| 500 | + if (empty($item)) { |
|
| 501 | 501 | exit; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // Update the item. |
| 505 | - $item->set_price( $data['price'] ); |
|
| 506 | - $item->set_name( $data['name'] ); |
|
| 507 | - $item->set_description( $data['description'] ); |
|
| 508 | - $item->set_quantity( $data['quantity'] ); |
|
| 505 | + $item->set_price($data['price']); |
|
| 506 | + $item->set_name($data['name']); |
|
| 507 | + $item->set_description($data['description']); |
|
| 508 | + $item->set_quantity($data['quantity']); |
|
| 509 | 509 | |
| 510 | 510 | // Add it to the invoice. |
| 511 | - $error = $invoice->add_item( $item ); |
|
| 511 | + $error = $invoice->add_item($item); |
|
| 512 | 512 | $alert = false; |
| 513 | - if ( is_wp_error( $error ) ) { |
|
| 513 | + if (is_wp_error($error)) { |
|
| 514 | 514 | $alert = $error->get_error_message(); |
| 515 | 515 | } |
| 516 | 516 | |
@@ -523,11 +523,11 @@ discard block |
||
| 523 | 523 | // Return an array of invoice items. |
| 524 | 524 | $items = array(); |
| 525 | 525 | |
| 526 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
| 527 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 526 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
| 527 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
| 530 | + wp_send_json_success(compact('items', 'alert')); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -536,33 +536,33 @@ discard block |
||
| 536 | 536 | public static function remove_invoice_item() { |
| 537 | 537 | |
| 538 | 538 | // Verify nonce. |
| 539 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 539 | + check_ajax_referer('wpinv-nonce'); |
|
| 540 | 540 | |
| 541 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 541 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 542 | 542 | exit; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | // We need an invoice and an item. |
| 546 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
| 546 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
| 547 | 547 | exit; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | // Fetch the invoice. |
| 551 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 551 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 552 | 552 | |
| 553 | 553 | // Ensure it exists and its not been paid for. |
| 554 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 554 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 555 | 555 | exit; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // Abort if the invoice does not have the specified item. |
| 559 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
| 559 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
| 560 | 560 | |
| 561 | - if ( empty( $item ) ) { |
|
| 561 | + if (empty($item)) { |
|
| 562 | 562 | exit; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
| 565 | + $invoice->remove_item((int) $_POST['item_id']); |
|
| 566 | 566 | |
| 567 | 567 | // Update totals. |
| 568 | 568 | $invoice->recalculate_total(); |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | // Return an array of invoice items. |
| 574 | 574 | $items = array(); |
| 575 | 575 | |
| 576 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
| 577 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 576 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
| 577 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - wp_send_json_success( compact( 'items' ) ); |
|
| 580 | + wp_send_json_success(compact('items')); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
@@ -586,39 +586,39 @@ discard block |
||
| 586 | 586 | public static function add_invoice_items() { |
| 587 | 587 | |
| 588 | 588 | // Verify nonce. |
| 589 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 589 | + check_ajax_referer('wpinv-nonce'); |
|
| 590 | 590 | |
| 591 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 591 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 592 | 592 | exit; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // We need an invoice and items. |
| 596 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
| 596 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
| 597 | 597 | exit; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | // Fetch the invoice. |
| 601 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 601 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 602 | 602 | $alert = false; |
| 603 | 603 | |
| 604 | 604 | // Ensure it exists and its not been paid for. |
| 605 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 605 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 606 | 606 | exit; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // Add the items. |
| 610 | - foreach ( $_POST['items'] as $data ) { |
|
| 610 | + foreach ($_POST['items'] as $data) { |
|
| 611 | 611 | |
| 612 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
| 612 | + $item = new GetPaid_Form_Item($data['id']); |
|
| 613 | 613 | |
| 614 | - if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) { |
|
| 615 | - $item->set_quantity( $data[ 'qty' ] ); |
|
| 614 | + if (is_numeric($data['qty']) && (int) $data['qty'] > 0) { |
|
| 615 | + $item->set_quantity($data['qty']); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if ( $item->get_id() > 0 ) { |
|
| 619 | - $error = $invoice->add_item( $item ); |
|
| 618 | + if ($item->get_id() > 0) { |
|
| 619 | + $error = $invoice->add_item($item); |
|
| 620 | 620 | |
| 621 | - if ( is_wp_error( $error ) ) { |
|
| 621 | + if (is_wp_error($error)) { |
|
| 622 | 622 | $alert = $error->get_error_message(); |
| 623 | 623 | } |
| 624 | 624 | |
@@ -633,11 +633,11 @@ discard block |
||
| 633 | 633 | // Return an array of invoice items. |
| 634 | 634 | $items = array(); |
| 635 | 635 | |
| 636 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
| 637 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 636 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
| 637 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
| 640 | + wp_send_json_success(compact('items', 'alert')); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -646,15 +646,15 @@ discard block |
||
| 646 | 646 | public static function get_invoicing_items() { |
| 647 | 647 | |
| 648 | 648 | // Verify nonce. |
| 649 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 649 | + check_ajax_referer('wpinv-nonce'); |
|
| 650 | 650 | |
| 651 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 651 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 652 | 652 | exit; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | // We need a search term. |
| 656 | - if ( empty( $_GET['search'] ) ) { |
|
| 657 | - wp_send_json_success( array() ); |
|
| 656 | + if (empty($_GET['search'])) { |
|
| 657 | + wp_send_json_success(array()); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | // Retrieve items. |
@@ -663,8 +663,8 @@ discard block |
||
| 663 | 663 | 'orderby' => 'title', |
| 664 | 664 | 'order' => 'ASC', |
| 665 | 665 | 'posts_per_page' => -1, |
| 666 | - 'post_status' => array( 'publish' ), |
|
| 667 | - 's' => trim( $_GET['search'] ), |
|
| 666 | + 'post_status' => array('publish'), |
|
| 667 | + 's' => trim($_GET['search']), |
|
| 668 | 668 | 'meta_query' => array( |
| 669 | 669 | array( |
| 670 | 670 | 'key' => '_wpinv_type', |
@@ -674,22 +674,22 @@ discard block |
||
| 674 | 674 | ) |
| 675 | 675 | ); |
| 676 | 676 | |
| 677 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
| 677 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
| 678 | 678 | $data = array(); |
| 679 | 679 | |
| 680 | 680 | |
| 681 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) ); |
|
| 681 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id'])); |
|
| 682 | 682 | |
| 683 | - foreach ( $items as $item ) { |
|
| 684 | - $item = new GetPaid_Form_Item( $item ); |
|
| 683 | + foreach ($items as $item) { |
|
| 684 | + $item = new GetPaid_Form_Item($item); |
|
| 685 | 685 | $data[] = array( |
| 686 | 686 | 'id' => (int) $item->get_id(), |
| 687 | - 'text' => strip_tags( $item->get_name() ), |
|
| 688 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
| 687 | + 'text' => strip_tags($item->get_name()), |
|
| 688 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
| 689 | 689 | ); |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - wp_send_json_success( $data ); |
|
| 692 | + wp_send_json_success($data); |
|
| 693 | 693 | |
| 694 | 694 | } |
| 695 | 695 | |
@@ -699,26 +699,26 @@ discard block |
||
| 699 | 699 | public static function get_aui_states_field() { |
| 700 | 700 | |
| 701 | 701 | // Verify nonce. |
| 702 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 702 | + check_ajax_referer('wpinv-nonce'); |
|
| 703 | 703 | |
| 704 | 704 | // We need a country. |
| 705 | - if ( empty( $_GET['country'] ) ) { |
|
| 705 | + if (empty($_GET['country'])) { |
|
| 706 | 706 | exit; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - $states = wpinv_get_country_states( trim( $_GET['country'] ) ); |
|
| 710 | - $state = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state(); |
|
| 709 | + $states = wpinv_get_country_states(trim($_GET['country'])); |
|
| 710 | + $state = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state(); |
|
| 711 | 711 | |
| 712 | - if ( empty( $states ) ) { |
|
| 712 | + if (empty($states)) { |
|
| 713 | 713 | |
| 714 | 714 | $html = aui()->input( |
| 715 | 715 | array( |
| 716 | 716 | 'type' => 'text', |
| 717 | 717 | 'id' => 'wpinv_state', |
| 718 | 718 | 'name' => 'wpinv_state', |
| 719 | - 'label' => __( 'State', 'invoicing' ), |
|
| 719 | + 'label' => __('State', 'invoicing'), |
|
| 720 | 720 | 'label_type' => 'vertical', |
| 721 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 721 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 722 | 722 | 'class' => 'form-control-sm', |
| 723 | 723 | 'value' => $state, |
| 724 | 724 | ) |
@@ -730,9 +730,9 @@ discard block |
||
| 730 | 730 | array( |
| 731 | 731 | 'id' => 'wpinv_state', |
| 732 | 732 | 'name' => 'wpinv_state', |
| 733 | - 'label' => __( 'State', 'invoicing' ), |
|
| 733 | + 'label' => __('State', 'invoicing'), |
|
| 734 | 734 | 'label_type' => 'vertical', |
| 735 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 735 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 736 | 736 | 'class' => 'form-control-sm', |
| 737 | 737 | 'value' => $state, |
| 738 | 738 | 'options' => $states, |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | wp_send_json_success( |
| 747 | 747 | array( |
| 748 | 748 | 'html' => $html, |
| 749 | - 'select' => ! empty ( $states ) |
|
| 749 | + 'select' => !empty ($states) |
|
| 750 | 750 | ) |
| 751 | 751 | ); |
| 752 | 752 | |
@@ -760,11 +760,11 @@ discard block |
||
| 760 | 760 | public static function payment_form_refresh_prices() { |
| 761 | 761 | |
| 762 | 762 | // Check nonce. |
| 763 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 763 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 764 | 764 | |
| 765 | 765 | // ... form fields... |
| 766 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 767 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
| 766 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
| 767 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
| 768 | 768 | exit; |
| 769 | 769 | } |
| 770 | 770 | |
@@ -772,18 +772,18 @@ discard block |
||
| 772 | 772 | $submission = new GetPaid_Payment_Form_Submission(); |
| 773 | 773 | |
| 774 | 774 | // Do we have an error? |
| 775 | - if ( ! empty( $submission->last_error ) ) { |
|
| 775 | + if (!empty($submission->last_error)) { |
|
| 776 | 776 | echo $submission->last_error; |
| 777 | 777 | exit; |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // Prepare the response. |
| 781 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
| 781 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
| 782 | 782 | |
| 783 | 783 | // Filter the response. |
| 784 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
| 784 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
| 785 | 785 | |
| 786 | - wp_send_json_success( $response ); |
|
| 786 | + wp_send_json_success($response); |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the invoice. |
| 27 | - $invoice = new WPInv_Invoice( $post ); |
|
| 27 | + $invoice = new WPInv_Invoice($post); |
|
| 28 | 28 | |
| 29 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 29 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | <div class="col-12 col-sm-6"> |
| 42 | 42 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
| 43 | 43 | <div> |
| 44 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 44 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 45 | 45 | </div> |
| 46 | 46 | <?php |
| 47 | 47 | wpinv_dropdown_users( |
| 48 | 48 | array( |
| 49 | 49 | 'name' => 'post_author_override', |
| 50 | - 'selected' => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(), |
|
| 50 | + 'selected' => $invoice->get_id() ? $invoice->get_user_id('edit') : get_current_user_id(), |
|
| 51 | 51 | 'include_selected' => true, |
| 52 | 52 | 'show' => 'display_name_with_login', |
| 53 | 53 | 'orderby' => 'user_email', |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'type' => 'text', |
| 66 | 66 | 'id' => 'getpaid-invoice-new-user-email', |
| 67 | 67 | 'name' => 'wpinv_email', |
| 68 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
| 68 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
| 69 | 69 | 'label_type' => 'vertical', |
| 70 | 70 | 'placeholder' => '[email protected]', |
| 71 | 71 | 'class' => 'form-control-sm', |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | </div> |
| 76 | 76 | </div> |
| 77 | 77 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
| 78 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
| 78 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
| 79 | 79 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
| 80 | 80 | <i aria-hidden="true" class="fa fa-refresh"></i> |
| 81 | - <?php _e( 'Fill User Details', 'invoicing' );?> |
|
| 81 | + <?php _e('Fill User Details', 'invoicing'); ?> |
|
| 82 | 82 | </a> |
| 83 | 83 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
| 84 | 84 | <i aria-hidden="true" class="fa fa-plus"></i> |
| 85 | - <?php _e( 'Add New User', 'invoicing' );?> |
|
| 85 | + <?php _e('Add New User', 'invoicing'); ?> |
|
| 86 | 86 | </a> |
| 87 | 87 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
| 88 | 88 | <i aria-hidden="true" class="fa fa-close"></i> |
| 89 | - <?php _e( 'Cancel', 'invoicing' );?> |
|
| 89 | + <?php _e('Cancel', 'invoicing'); ?> |
|
| 90 | 90 | </a> |
| 91 | 91 | <?php endif; ?> |
| 92 | 92 | </div> |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | 'type' => 'text', |
| 100 | 100 | 'id' => 'wpinv_first_name', |
| 101 | 101 | 'name' => 'wpinv_first_name', |
| 102 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 102 | + 'label' => __('First Name', 'invoicing'), |
|
| 103 | 103 | 'label_type' => 'vertical', |
| 104 | 104 | 'placeholder' => 'Jane', |
| 105 | 105 | 'class' => 'form-control-sm', |
| 106 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
| 106 | + 'value' => $invoice->get_first_name('edit'), |
|
| 107 | 107 | ) |
| 108 | 108 | ); |
| 109 | 109 | ?> |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | 'type' => 'text', |
| 116 | 116 | 'id' => 'wpinv_last_name', |
| 117 | 117 | 'name' => 'wpinv_last_name', |
| 118 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 118 | + 'label' => __('Last Name', 'invoicing'), |
|
| 119 | 119 | 'label_type' => 'vertical', |
| 120 | 120 | 'placeholder' => 'Doe', |
| 121 | 121 | 'class' => 'form-control-sm', |
| 122 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
| 122 | + 'value' => $invoice->get_last_name('edit'), |
|
| 123 | 123 | ) |
| 124 | 124 | ); |
| 125 | 125 | ?> |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | 'type' => 'text', |
| 135 | 135 | 'id' => 'wpinv_company', |
| 136 | 136 | 'name' => 'wpinv_company', |
| 137 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 137 | + 'label' => __('Company', 'invoicing'), |
|
| 138 | 138 | 'label_type' => 'vertical', |
| 139 | 139 | 'placeholder' => 'Acme Corporation', |
| 140 | 140 | 'class' => 'form-control-sm', |
| 141 | - 'value' => $invoice->get_company( 'edit' ), |
|
| 141 | + 'value' => $invoice->get_company('edit'), |
|
| 142 | 142 | ) |
| 143 | 143 | ); |
| 144 | 144 | ?> |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | 'type' => 'text', |
| 151 | 151 | 'id' => 'wpinv_vat_number', |
| 152 | 152 | 'name' => 'wpinv_vat_number', |
| 153 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
| 153 | + 'label' => __('Vat Number', 'invoicing'), |
|
| 154 | 154 | 'label_type' => 'vertical', |
| 155 | 155 | 'placeholder' => '1234567890', |
| 156 | 156 | 'class' => 'form-control-sm', |
| 157 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
| 157 | + 'value' => $invoice->get_vat_number('edit'), |
|
| 158 | 158 | ) |
| 159 | 159 | ); |
| 160 | 160 | ?> |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | 'type' => 'text', |
| 170 | 170 | 'id' => 'wpinv_address', |
| 171 | 171 | 'name' => 'wpinv_address', |
| 172 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 172 | + 'label' => __('Address', 'invoicing'), |
|
| 173 | 173 | 'label_type' => 'vertical', |
| 174 | 174 | 'placeholder' => 'Blekersdijk 295', |
| 175 | 175 | 'class' => 'form-control-sm', |
| 176 | - 'value' => $invoice->get_address( 'edit' ), |
|
| 176 | + 'value' => $invoice->get_address('edit'), |
|
| 177 | 177 | ) |
| 178 | 178 | ); |
| 179 | 179 | ?> |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | 'type' => 'text', |
| 186 | 186 | 'id' => 'wpinv_city', |
| 187 | 187 | 'name' => 'wpinv_city', |
| 188 | - 'label' => __( 'City', 'invoicing' ), |
|
| 188 | + 'label' => __('City', 'invoicing'), |
|
| 189 | 189 | 'label_type' => 'vertical', |
| 190 | 190 | 'placeholder' => 'Dolembreux', |
| 191 | 191 | 'class' => 'form-control-sm', |
| 192 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
| 192 | + 'value' => $invoice->get_vat_number('edit'), |
|
| 193 | 193 | ) |
| 194 | 194 | ); |
| 195 | 195 | ?> |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | array( |
| 204 | 204 | 'id' => 'wpinv_country', |
| 205 | 205 | 'name' => 'wpinv_country', |
| 206 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 206 | + 'label' => __('Country', 'invoicing'), |
|
| 207 | 207 | 'label_type' => 'vertical', |
| 208 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 208 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 209 | 209 | 'class' => 'form-control-sm', |
| 210 | - 'value' => $invoice->get_country( 'edit' ), |
|
| 210 | + 'value' => $invoice->get_country('edit'), |
|
| 211 | 211 | 'options' => wpinv_get_country_list(), |
| 212 | 212 | 'data-allow-clear' => 'false', |
| 213 | 213 | 'select2' => true, |
@@ -218,20 +218,20 @@ discard block |
||
| 218 | 218 | <div class="col-12 col-sm-6"> |
| 219 | 219 | <?php |
| 220 | 220 | |
| 221 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
| 221 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
| 222 | 222 | |
| 223 | - if ( empty( $states ) ) { |
|
| 223 | + if (empty($states)) { |
|
| 224 | 224 | |
| 225 | 225 | echo aui()->input( |
| 226 | 226 | array( |
| 227 | 227 | 'type' => 'text', |
| 228 | 228 | 'id' => 'wpinv_state', |
| 229 | 229 | 'name' => 'wpinv_state', |
| 230 | - 'label' => __( 'State', 'invoicing' ), |
|
| 230 | + 'label' => __('State', 'invoicing'), |
|
| 231 | 231 | 'label_type' => 'vertical', |
| 232 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 232 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 233 | 233 | 'class' => 'form-control-sm', |
| 234 | - 'value' => $invoice->get_state( 'edit' ), |
|
| 234 | + 'value' => $invoice->get_state('edit'), |
|
| 235 | 235 | ) |
| 236 | 236 | ); |
| 237 | 237 | |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | array( |
| 242 | 242 | 'id' => 'wpinv_state', |
| 243 | 243 | 'name' => 'wpinv_state', |
| 244 | - 'label' => __( 'State', 'invoicing' ), |
|
| 244 | + 'label' => __('State', 'invoicing'), |
|
| 245 | 245 | 'label_type' => 'vertical', |
| 246 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 246 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 247 | 247 | 'class' => 'form-control-sm', |
| 248 | - 'value' => $invoice->get_state( 'edit' ), |
|
| 248 | + 'value' => $invoice->get_state('edit'), |
|
| 249 | 249 | 'options' => $states, |
| 250 | 250 | 'data-allow-clear' => 'false', |
| 251 | 251 | 'select2' => true, |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | 'type' => 'text', |
| 267 | 267 | 'id' => 'wpinv_zip', |
| 268 | 268 | 'name' => 'wpinv_zip', |
| 269 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
| 269 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
| 270 | 270 | 'label_type' => 'vertical', |
| 271 | 271 | 'placeholder' => '4140', |
| 272 | 272 | 'class' => 'form-control-sm', |
| 273 | - 'value' => $invoice->get_zip( 'edit' ), |
|
| 273 | + 'value' => $invoice->get_zip('edit'), |
|
| 274 | 274 | ) |
| 275 | 275 | ); |
| 276 | 276 | ?> |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | 'type' => 'text', |
| 283 | 283 | 'id' => 'wpinv_phone', |
| 284 | 284 | 'name' => 'wpinv_phone', |
| 285 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 285 | + 'label' => __('Phone', 'invoicing'), |
|
| 286 | 286 | 'label_type' => 'vertical', |
| 287 | 287 | 'placeholder' => '0493 18 45822', |
| 288 | 288 | 'class' => 'form-control-sm', |
| 289 | - 'value' => $invoice->get_phone( 'edit' ), |
|
| 289 | + 'value' => $invoice->get_phone('edit'), |
|
| 290 | 290 | ) |
| 291 | 291 | ); |
| 292 | 292 | ?> |
@@ -302,34 +302,34 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @param int $post_id |
| 304 | 304 | */ |
| 305 | - public static function save( $post_id ) { |
|
| 305 | + public static function save($post_id) { |
|
| 306 | 306 | |
| 307 | 307 | // Prepare the invoice. |
| 308 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 308 | + $invoice = new WPInv_Invoice($post_id); |
|
| 309 | 309 | |
| 310 | 310 | // Load new data. |
| 311 | 311 | $invoice->set_props( |
| 312 | 312 | array( |
| 313 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
| 314 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
| 315 | - 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
|
| 316 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
| 317 | - 'gateway' => isset( $_POST['wpinv_gateway'] ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
| 318 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
| 319 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
| 320 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
| 321 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
| 322 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
| 323 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
| 324 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
| 325 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
| 326 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
| 327 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
| 328 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
| 329 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
| 330 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
| 331 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
| 332 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
| 313 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
| 314 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
| 315 | + 'disable_taxes' => isset($_POST['disable_taxes']), |
|
| 316 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
| 317 | + 'gateway' => isset($_POST['wpinv_gateway']) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
| 318 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
| 319 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
| 320 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
| 321 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
| 322 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
| 323 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
| 324 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
| 325 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
| 326 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
| 327 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
| 328 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
| 329 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
| 330 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
| 331 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
| 332 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
| 333 | 333 | ) |
| 334 | 334 | ); |
| 335 | 335 | |
@@ -337,17 +337,17 @@ discard block |
||
| 337 | 337 | $invoice->recalculate_total(); |
| 338 | 338 | |
| 339 | 339 | // If we're creating a new user... |
| 340 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) { |
|
| 340 | + if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) { |
|
| 341 | 341 | |
| 342 | 342 | // Attempt to create the user. |
| 343 | - $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) ); |
|
| 343 | + $user = wpinv_create_user(sanitize_email($_POST['wpinv_email'])); |
|
| 344 | 344 | |
| 345 | 345 | |
| 346 | 346 | // If successful, update the invoice author. |
| 347 | - if ( is_numeric( $user ) ) { |
|
| 348 | - $invoice->set_author( $user ); |
|
| 347 | + if (is_numeric($user)) { |
|
| 348 | + $invoice->set_author($user); |
|
| 349 | 349 | } else { |
| 350 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 350 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | $invoice->save(); |
| 356 | 356 | |
| 357 | 357 | // (Maybe) send new user notification. |
| 358 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) { |
|
| 359 | - wp_send_new_user_notifications( $user, 'user' ); |
|
| 358 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) { |
|
| 359 | + wp_send_new_user_notifications($user, 'user'); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Fires after an invoice is saved. |
| 363 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
| 363 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
| 364 | 364 | } |
| 365 | 365 | } |