@@ -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 ) |
@@ -259,24 +259,24 @@ discard block |
||
| 259 | 259 | check_ajax_referer( 'getpaid_form_nonce' ); |
| 260 | 260 | |
| 261 | 261 | // Is the request set up correctly? |
| 262 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 263 | - echo aui()->alert( |
|
| 264 | - array( |
|
| 265 | - 'type' => 'warning', |
|
| 266 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 267 | - ) |
|
| 262 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 263 | + echo aui()->alert( |
|
| 264 | + array( |
|
| 265 | + 'type' => 'warning', |
|
| 266 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 267 | + ) |
|
| 268 | 268 | ); |
| 269 | 269 | exit; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Payment form or button? |
| 273 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 273 | + if ( ! empty( $_GET['form'] ) ) { |
|
| 274 | 274 | getpaid_display_payment_form( urldecode( $_GET['form'] ) ); |
| 275 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 276 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 275 | + } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 276 | + getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 277 | 277 | } else { |
| 278 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 279 | - getpaid_display_item_payment_form( $items ); |
|
| 278 | + $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 279 | + getpaid_display_item_payment_form( $items ); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | exit; |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | if ( is_wp_error( $error ) ) { |
| 598 | 598 | $alert = $error->get_error_message(); |
| 599 | 599 | wp_send_json_success( compact( 'alert' ) ); |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | // Update totals. |
| 603 | 603 | $invoice->recalculate_total(); |
@@ -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 | |
@@ -105,36 +105,36 @@ discard block |
||
| 105 | 105 | 'payment_form_refresh_prices' => true, |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
| 109 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 110 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 108 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
| 109 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 110 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 111 | 111 | |
| 112 | - if ( $nopriv ) { |
|
| 113 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 114 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 115 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 112 | + if ($nopriv) { |
|
| 113 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 114 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 115 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public static function add_note() { |
| 121 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
| 121 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
| 122 | 122 | |
| 123 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 123 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 124 | 124 | die(-1); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $post_id = absint( $_POST['post_id'] ); |
|
| 128 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
| 129 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
| 127 | + $post_id = absint($_POST['post_id']); |
|
| 128 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
| 129 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
| 130 | 130 | |
| 131 | 131 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
| 132 | 132 | |
| 133 | - if ( $post_id > 0 ) { |
|
| 134 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
| 133 | + if ($post_id > 0) { |
|
| 134 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
| 135 | 135 | |
| 136 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
| 137 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
| 136 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
| 137 | + wpinv_get_invoice_note_line_item($note_id); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | public static function delete_note() { |
| 145 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
| 145 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
| 146 | 146 | |
| 147 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 147 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 148 | 148 | die(-1); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $note_id = (int)$_POST['note_id']; |
|
| 151 | + $note_id = (int) $_POST['note_id']; |
|
| 152 | 152 | |
| 153 | - if ( $note_id > 0 ) { |
|
| 154 | - wp_delete_comment( $note_id, true ); |
|
| 153 | + if ($note_id > 0) { |
|
| 154 | + wp_delete_comment($note_id, true); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | die(); |
@@ -169,34 +169,34 @@ discard block |
||
| 169 | 169 | public static function get_billing_details() { |
| 170 | 170 | |
| 171 | 171 | // Verify nonce. |
| 172 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 172 | + check_ajax_referer('wpinv-nonce'); |
|
| 173 | 173 | |
| 174 | 174 | // Can the user manage the plugin? |
| 175 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 175 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 176 | 176 | die(-1); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // Do we have a user id? |
| 180 | 180 | $user_id = $_GET['user_id']; |
| 181 | 181 | |
| 182 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 182 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 183 | 183 | die(-1); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // Fetch the billing details. |
| 187 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
| 188 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
| 187 | + $billing_details = wpinv_get_user_address($user_id); |
|
| 188 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
| 189 | 189 | |
| 190 | 190 | // unset the user id and email. |
| 191 | - $to_ignore = array( 'user_id', 'email' ); |
|
| 191 | + $to_ignore = array('user_id', 'email'); |
|
| 192 | 192 | |
| 193 | - foreach ( $to_ignore as $key ) { |
|
| 194 | - if ( isset( $billing_details[ $key ] ) ) { |
|
| 195 | - unset( $billing_details[ $key ] ); |
|
| 193 | + foreach ($to_ignore as $key) { |
|
| 194 | + if (isset($billing_details[$key])) { |
|
| 195 | + unset($billing_details[$key]); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - wp_send_json_success( $billing_details ); |
|
| 199 | + wp_send_json_success($billing_details); |
|
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | |
@@ -206,47 +206,47 @@ discard block |
||
| 206 | 206 | public static function check_new_user_email() { |
| 207 | 207 | |
| 208 | 208 | // Verify nonce. |
| 209 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 209 | + check_ajax_referer('wpinv-nonce'); |
|
| 210 | 210 | |
| 211 | 211 | // Can the user manage the plugin? |
| 212 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 212 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 213 | 213 | die(-1); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // We need an email address. |
| 217 | - if ( empty( $_GET['email'] ) ) { |
|
| 218 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
| 217 | + if (empty($_GET['email'])) { |
|
| 218 | + _e("Provide the new user's email address", 'invoicing'); |
|
| 219 | 219 | exit; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // Ensure the email is valid. |
| 223 | - $email = sanitize_text_field( $_GET['email'] ); |
|
| 224 | - if ( ! is_email( $email ) ) { |
|
| 225 | - _e( 'Invalid email address', 'invoicing' ); |
|
| 223 | + $email = sanitize_text_field($_GET['email']); |
|
| 224 | + if (!is_email($email)) { |
|
| 225 | + _e('Invalid email address', 'invoicing'); |
|
| 226 | 226 | exit; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // And it does not exist. |
| 230 | - $id = email_exists( $email ); |
|
| 231 | - if ( $id ) { |
|
| 232 | - wp_send_json_success( compact( 'id' ) ); |
|
| 230 | + $id = email_exists($email); |
|
| 231 | + if ($id) { |
|
| 232 | + wp_send_json_success(compact('id')); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - wp_send_json_success( true ); |
|
| 235 | + wp_send_json_success(true); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public static function run_tool() { |
| 239 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 240 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 239 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 240 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 241 | 241 | die(-1); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
| 244 | + $tool = sanitize_text_field($_POST['tool']); |
|
| 245 | 245 | |
| 246 | - do_action( 'wpinv_run_tool' ); |
|
| 246 | + do_action('wpinv_run_tool'); |
|
| 247 | 247 | |
| 248 | - if ( !empty( $tool ) ) { |
|
| 249 | - do_action( 'wpinv_tool_' . $tool ); |
|
| 248 | + if (!empty($tool)) { |
|
| 249 | + do_action('wpinv_tool_' . $tool); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
@@ -256,27 +256,27 @@ discard block |
||
| 256 | 256 | public static function get_payment_form() { |
| 257 | 257 | |
| 258 | 258 | // Check nonce. |
| 259 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 259 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 260 | 260 | |
| 261 | 261 | // Is the request set up correctly? |
| 262 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 262 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
| 263 | 263 | echo aui()->alert( |
| 264 | 264 | array( |
| 265 | 265 | 'type' => 'warning', |
| 266 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 266 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
| 267 | 267 | ) |
| 268 | 268 | ); |
| 269 | 269 | exit; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Payment form or button? |
| 273 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 274 | - getpaid_display_payment_form( urldecode( $_GET['form'] ) ); |
|
| 275 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 276 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 273 | + if (!empty($_GET['form'])) { |
|
| 274 | + getpaid_display_payment_form(urldecode($_GET['form'])); |
|
| 275 | + } else if (!empty($_GET['invoice'])) { |
|
| 276 | + getpaid_display_invoice_payment_form(urldecode($_GET['invoice'])); |
|
| 277 | 277 | } else { |
| 278 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 279 | - getpaid_display_item_payment_form( $items ); |
|
| 278 | + $items = getpaid_convert_items_to_array(urldecode($_GET['item'])); |
|
| 279 | + getpaid_display_item_payment_form($items); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | exit; |
@@ -291,17 +291,17 @@ discard block |
||
| 291 | 291 | public static function payment_form() { |
| 292 | 292 | |
| 293 | 293 | // Check nonce. |
| 294 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 294 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 295 | 295 | |
| 296 | 296 | // ... form fields... |
| 297 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 298 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
| 297 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
| 298 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
| 299 | 299 | exit; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Process the payment form. |
| 303 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
| 304 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
| 303 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
| 304 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
| 305 | 305 | $checkout->process_checkout(); |
| 306 | 306 | |
| 307 | 307 | exit; |
@@ -314,55 +314,55 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | public static function get_payment_form_states_field() { |
| 316 | 316 | |
| 317 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
| 317 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
| 318 | 318 | exit; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $elements = getpaid_get_payment_form_elements( $_GET['form'] ); |
|
| 321 | + $elements = getpaid_get_payment_form_elements($_GET['form']); |
|
| 322 | 322 | |
| 323 | - if ( empty( $elements ) ) { |
|
| 323 | + if (empty($elements)) { |
|
| 324 | 324 | exit; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | $address_fields = array(); |
| 328 | - foreach ( $elements as $element ) { |
|
| 329 | - if ( 'address' === $element['type'] ) { |
|
| 328 | + foreach ($elements as $element) { |
|
| 329 | + if ('address' === $element['type']) { |
|
| 330 | 330 | $address_fields = $element; |
| 331 | 331 | break; |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( empty( $address_fields ) ) { |
|
| 335 | + if (empty($address_fields)) { |
|
| 336 | 336 | exit; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
| 339 | + foreach ($address_fields['fields'] as $address_field) { |
|
| 340 | 340 | |
| 341 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
| 341 | + if ('wpinv_state' == $address_field['name']) { |
|
| 342 | 342 | |
| 343 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
| 344 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
| 345 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
| 346 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
| 347 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
| 348 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
| 343 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
| 344 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
| 345 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
| 346 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
| 347 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
| 348 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
| 349 | 349 | |
| 350 | - if ( ! empty( $address_field['required'] ) ) { |
|
| 350 | + if (!empty($address_field['required'])) { |
|
| 351 | 351 | $label .= "<span class='text-danger'> *</span>"; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $html = getpaid_get_states_select_markup ( |
|
| 355 | - sanitize_text_field( $_GET['country'] ), |
|
| 354 | + $html = getpaid_get_states_select_markup( |
|
| 355 | + sanitize_text_field($_GET['country']), |
|
| 356 | 356 | $value, |
| 357 | 357 | $placeholder, |
| 358 | 358 | $label, |
| 359 | 359 | $description, |
| 360 | - ! empty( $address_field['required'] ), |
|
| 360 | + !empty($address_field['required']), |
|
| 361 | 361 | $wrap_class, |
| 362 | - wpinv_clean( $_GET['name'] ) |
|
| 362 | + wpinv_clean($_GET['name']) |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | - wp_send_json_success( $html ); |
|
| 365 | + wp_send_json_success($html); |
|
| 366 | 366 | exit; |
| 367 | 367 | |
| 368 | 368 | } |
@@ -378,66 +378,66 @@ discard block |
||
| 378 | 378 | public static function recalculate_invoice_totals() { |
| 379 | 379 | |
| 380 | 380 | // Verify nonce. |
| 381 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 381 | + check_ajax_referer('wpinv-nonce'); |
|
| 382 | 382 | |
| 383 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 383 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 384 | 384 | exit; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // We need an invoice. |
| 388 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 388 | + if (empty($_POST['post_id'])) { |
|
| 389 | 389 | exit; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // Fetch the invoice. |
| 393 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 393 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 394 | 394 | |
| 395 | 395 | // Ensure it exists. |
| 396 | - if ( ! $invoice->get_id() ) { |
|
| 396 | + if (!$invoice->get_id()) { |
|
| 397 | 397 | exit; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | // Maybe set the country, state, currency. |
| 401 | - foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) { |
|
| 402 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 401 | + foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) { |
|
| 402 | + if (isset($_POST[$key])) { |
|
| 403 | 403 | $method = "set_$key"; |
| 404 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
| 404 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // Maybe disable taxes. |
| 409 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
| 409 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
| 410 | 410 | |
| 411 | 411 | // Discount code. |
| 412 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 413 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 414 | - if ( $discount->exists() ) { |
|
| 415 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 412 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 413 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 414 | + if ($discount->exists()) { |
|
| 415 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 416 | 416 | } else { |
| 417 | - $invoice->remove_discount( 'discount_code' ); |
|
| 417 | + $invoice->remove_discount('discount_code'); |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Recalculate totals. |
| 422 | 422 | $invoice->recalculate_total(); |
| 423 | 423 | |
| 424 | - $total = wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
| 425 | - $suscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 426 | - if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
| 427 | - $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() ); |
|
| 428 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
| 424 | + $total = wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
| 425 | + $suscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 426 | + if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
| 427 | + $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency()); |
|
| 428 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $totals = array( |
| 432 | - 'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
| 433 | - 'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
| 434 | - 'tax' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
| 432 | + 'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
| 433 | + 'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
| 434 | + 'tax' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
| 435 | 435 | 'total' => $total, |
| 436 | 436 | ); |
| 437 | 437 | |
| 438 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
| 438 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
| 439 | 439 | |
| 440 | - wp_send_json_success( compact( 'totals' ) ); |
|
| 440 | + wp_send_json_success(compact('totals')); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | /** |
@@ -446,33 +446,33 @@ discard block |
||
| 446 | 446 | public static function get_invoice_items() { |
| 447 | 447 | |
| 448 | 448 | // Verify nonce. |
| 449 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 449 | + check_ajax_referer('wpinv-nonce'); |
|
| 450 | 450 | |
| 451 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 451 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 452 | 452 | exit; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // We need an invoice and items. |
| 456 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 456 | + if (empty($_POST['post_id'])) { |
|
| 457 | 457 | exit; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // Fetch the invoice. |
| 461 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 461 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 462 | 462 | |
| 463 | 463 | // Ensure it exists. |
| 464 | - if ( ! $invoice->get_id() ) { |
|
| 464 | + if (!$invoice->get_id()) { |
|
| 465 | 465 | exit; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Return an array of invoice items. |
| 469 | 469 | $items = array(); |
| 470 | 470 | |
| 471 | - foreach ( $invoice->get_items() as $item ) { |
|
| 472 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() ); |
|
| 471 | + foreach ($invoice->get_items() as $item) { |
|
| 472 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal()); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - wp_send_json_success( compact( 'items' ) ); |
|
| 475 | + wp_send_json_success(compact('items')); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
@@ -481,50 +481,50 @@ discard block |
||
| 481 | 481 | public static function edit_invoice_item() { |
| 482 | 482 | |
| 483 | 483 | // Verify nonce. |
| 484 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 484 | + check_ajax_referer('wpinv-nonce'); |
|
| 485 | 485 | |
| 486 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 486 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 487 | 487 | exit; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // We need an invoice and item details. |
| 491 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
| 491 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
| 492 | 492 | exit; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // Fetch the invoice. |
| 496 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 496 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 497 | 497 | |
| 498 | 498 | // Ensure it exists and its not been paid for. |
| 499 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 499 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 500 | 500 | exit; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | // Format the data. |
| 504 | - $data = wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ); |
|
| 504 | + $data = wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field')); |
|
| 505 | 505 | |
| 506 | 506 | // Ensure that we have an item id. |
| 507 | - if ( empty( $data['id'] ) ) { |
|
| 507 | + if (empty($data['id'])) { |
|
| 508 | 508 | exit; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | // Abort if the invoice does not have the specified item. |
| 512 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
| 512 | + $item = $invoice->get_item((int) $data['id']); |
|
| 513 | 513 | |
| 514 | - if ( empty( $item ) ) { |
|
| 514 | + if (empty($item)) { |
|
| 515 | 515 | exit; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // Update the item. |
| 519 | - $item->set_price( floatval( $data['price'] ) ); |
|
| 520 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
| 521 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
| 522 | - $item->set_quantity( floatval( $data['quantity'] ) ); |
|
| 519 | + $item->set_price(floatval($data['price'])); |
|
| 520 | + $item->set_name(sanitize_text_field($data['name'])); |
|
| 521 | + $item->set_description(wp_kses_post($data['description'])); |
|
| 522 | + $item->set_quantity(floatval($data['quantity'])); |
|
| 523 | 523 | |
| 524 | 524 | // Add it to the invoice. |
| 525 | - $error = $invoice->add_item( $item ); |
|
| 525 | + $error = $invoice->add_item($item); |
|
| 526 | 526 | $alert = false; |
| 527 | - if ( is_wp_error( $error ) ) { |
|
| 527 | + if (is_wp_error($error)) { |
|
| 528 | 528 | $alert = $error->get_error_message(); |
| 529 | 529 | } |
| 530 | 530 | |
@@ -537,11 +537,11 @@ discard block |
||
| 537 | 537 | // Return an array of invoice items. |
| 538 | 538 | $items = array(); |
| 539 | 539 | |
| 540 | - foreach ( $invoice->get_items() as $item ) { |
|
| 541 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 540 | + foreach ($invoice->get_items() as $item) { |
|
| 541 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
| 544 | + wp_send_json_success(compact('items', 'alert')); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -550,53 +550,53 @@ discard block |
||
| 550 | 550 | public static function create_invoice_item() { |
| 551 | 551 | |
| 552 | 552 | // Verify nonce. |
| 553 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 553 | + check_ajax_referer('wpinv-nonce'); |
|
| 554 | 554 | |
| 555 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 555 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 556 | 556 | exit; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | // We need an invoice and item details. |
| 560 | - if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) { |
|
| 560 | + if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) { |
|
| 561 | 561 | exit; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | // Fetch the invoice. |
| 565 | - $invoice = new WPInv_Invoice( trim( $_POST['invoice_id'] ) ); |
|
| 565 | + $invoice = new WPInv_Invoice(trim($_POST['invoice_id'])); |
|
| 566 | 566 | |
| 567 | 567 | // Ensure it exists and its not been paid for. |
| 568 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 568 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 569 | 569 | exit; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | // Format the data. |
| 573 | - $data = wp_unslash( $_POST['_wpinv_quick'] ); |
|
| 573 | + $data = wp_unslash($_POST['_wpinv_quick']); |
|
| 574 | 574 | |
| 575 | 575 | $item = new WPInv_Item(); |
| 576 | - $item->set_price( floatval( $data['price'] ) ); |
|
| 577 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
| 578 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
| 579 | - $item->set_type( sanitize_text_field( $data['type'] ) ); |
|
| 580 | - $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) ); |
|
| 581 | - $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) ); |
|
| 582 | - $item->set_status( 'publish' ); |
|
| 576 | + $item->set_price(floatval($data['price'])); |
|
| 577 | + $item->set_name(sanitize_text_field($data['name'])); |
|
| 578 | + $item->set_description(wp_kses_post($data['description'])); |
|
| 579 | + $item->set_type(sanitize_text_field($data['type'])); |
|
| 580 | + $item->set_vat_rule(sanitize_text_field($data['vat_rule'])); |
|
| 581 | + $item->set_vat_class(sanitize_text_field($data['vat_class'])); |
|
| 582 | + $item->set_status('publish'); |
|
| 583 | 583 | $item->save(); |
| 584 | 584 | |
| 585 | - if ( ! $item->exists() ) { |
|
| 586 | - $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' ); |
|
| 587 | - wp_send_json_success( compact( 'alert' ) ); |
|
| 585 | + if (!$item->exists()) { |
|
| 586 | + $alert = __('Could not create invoice item. Please try again.', 'invoicing'); |
|
| 587 | + wp_send_json_success(compact('alert')); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $item = new GetPaid_Form_Item( $item->get_id() ); |
|
| 591 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
| 590 | + $item = new GetPaid_Form_Item($item->get_id()); |
|
| 591 | + $item->set_quantity(floatval($data['qty'])); |
|
| 592 | 592 | |
| 593 | 593 | // Add it to the invoice. |
| 594 | - $error = $invoice->add_item( $item ); |
|
| 594 | + $error = $invoice->add_item($item); |
|
| 595 | 595 | $alert = false; |
| 596 | 596 | |
| 597 | - if ( is_wp_error( $error ) ) { |
|
| 597 | + if (is_wp_error($error)) { |
|
| 598 | 598 | $alert = $error->get_error_message(); |
| 599 | - wp_send_json_success( compact( 'alert' ) ); |
|
| 599 | + wp_send_json_success(compact('alert')); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | // Update totals. |
@@ -609,9 +609,9 @@ discard block |
||
| 609 | 609 | $invoice->recalculate_total(); |
| 610 | 610 | $invoice->save(); |
| 611 | 611 | ob_start(); |
| 612 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
| 612 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
| 613 | 613 | $row = ob_get_clean(); |
| 614 | - wp_send_json_success( compact( 'row' ) ); |
|
| 614 | + wp_send_json_success(compact('row')); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | /** |
@@ -620,33 +620,33 @@ discard block |
||
| 620 | 620 | public static function remove_invoice_item() { |
| 621 | 621 | |
| 622 | 622 | // Verify nonce. |
| 623 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 623 | + check_ajax_referer('wpinv-nonce'); |
|
| 624 | 624 | |
| 625 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 625 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 626 | 626 | exit; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | // We need an invoice and an item. |
| 630 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
| 630 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
| 631 | 631 | exit; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | // Fetch the invoice. |
| 635 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 635 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 636 | 636 | |
| 637 | 637 | // Ensure it exists and its not been paid for. |
| 638 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 638 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 639 | 639 | exit; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | // Abort if the invoice does not have the specified item. |
| 643 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
| 643 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
| 644 | 644 | |
| 645 | - if ( empty( $item ) ) { |
|
| 645 | + if (empty($item)) { |
|
| 646 | 646 | exit; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
| 649 | + $invoice->remove_item((int) $_POST['item_id']); |
|
| 650 | 650 | |
| 651 | 651 | // Update totals. |
| 652 | 652 | $invoice->recalculate_total(); |
@@ -657,11 +657,11 @@ discard block |
||
| 657 | 657 | // Return an array of invoice items. |
| 658 | 658 | $items = array(); |
| 659 | 659 | |
| 660 | - foreach ( $invoice->get_items() as $item ) { |
|
| 661 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 660 | + foreach ($invoice->get_items() as $item) { |
|
| 661 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - wp_send_json_success( compact( 'items' ) ); |
|
| 664 | + wp_send_json_success(compact('items')); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -670,69 +670,69 @@ discard block |
||
| 670 | 670 | public static function recalculate_full_prices() { |
| 671 | 671 | |
| 672 | 672 | // Verify nonce. |
| 673 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 673 | + check_ajax_referer('wpinv-nonce'); |
|
| 674 | 674 | |
| 675 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 675 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 676 | 676 | exit; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // We need an invoice and item. |
| 680 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 680 | + if (empty($_POST['post_id'])) { |
|
| 681 | 681 | exit; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | // Fetch the invoice. |
| 685 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 685 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 686 | 686 | $alert = false; |
| 687 | 687 | |
| 688 | 688 | // Ensure it exists and its not been paid for. |
| 689 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 689 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 690 | 690 | exit; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - $invoice->set_items( array() ); |
|
| 693 | + $invoice->set_items(array()); |
|
| 694 | 694 | |
| 695 | - if ( ! empty( $_POST['getpaid_items'] ) ) { |
|
| 695 | + if (!empty($_POST['getpaid_items'])) { |
|
| 696 | 696 | |
| 697 | - foreach ( $_POST['getpaid_items'] as $item_id => $args ) { |
|
| 698 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 697 | + foreach ($_POST['getpaid_items'] as $item_id => $args) { |
|
| 698 | + $item = new GetPaid_Form_Item($item_id); |
|
| 699 | 699 | |
| 700 | - if ( $item->exists() ) { |
|
| 701 | - $item->set_price( floatval( $args['price'] ) ); |
|
| 702 | - $item->set_quantity( floatval( $args['quantity'] ) ); |
|
| 703 | - $item->set_name( sanitize_text_field( $args['name'] ) ); |
|
| 704 | - $item->set_description( wp_kses_post( $args['description'] ) ); |
|
| 705 | - $invoice->add_item( $item ); |
|
| 700 | + if ($item->exists()) { |
|
| 701 | + $item->set_price(floatval($args['price'])); |
|
| 702 | + $item->set_quantity(floatval($args['quantity'])); |
|
| 703 | + $item->set_name(sanitize_text_field($args['name'])); |
|
| 704 | + $item->set_description(wp_kses_post($args['description'])); |
|
| 705 | + $invoice->add_item($item); |
|
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) ); |
|
| 711 | + $invoice->set_disable_taxes(!empty($_POST['disable_taxes'])); |
|
| 712 | 712 | |
| 713 | 713 | // Maybe set the country, state, currency. |
| 714 | - foreach ( array( 'country', 'state', 'currency', 'vat_number', 'wpinv_discount_code' ) as $key ) { |
|
| 715 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 716 | - $_key = str_replace( 'wpinv_', '', $key ); |
|
| 714 | + foreach (array('country', 'state', 'currency', 'vat_number', 'wpinv_discount_code') as $key) { |
|
| 715 | + if (isset($_POST[$key])) { |
|
| 716 | + $_key = str_replace('wpinv_', '', $key); |
|
| 717 | 717 | $method = "set_$_key"; |
| 718 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
| 718 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 723 | - if ( $discount->exists() ) { |
|
| 724 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 722 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 723 | + if ($discount->exists()) { |
|
| 724 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 725 | 725 | } else { |
| 726 | - $invoice->remove_discount( 'discount_code' ); |
|
| 726 | + $invoice->remove_discount('discount_code'); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // Save the invoice. |
| 730 | 730 | $invoice->recalculate_total(); |
| 731 | 731 | $invoice->save(); |
| 732 | 732 | ob_start(); |
| 733 | - GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice ); |
|
| 733 | + GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice); |
|
| 734 | 734 | $table = ob_get_clean(); |
| 735 | - wp_send_json_success( compact( 'table' ) ); |
|
| 735 | + wp_send_json_success(compact('table')); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -741,42 +741,42 @@ discard block |
||
| 741 | 741 | public static function admin_add_invoice_item() { |
| 742 | 742 | |
| 743 | 743 | // Verify nonce. |
| 744 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 744 | + check_ajax_referer('wpinv-nonce'); |
|
| 745 | 745 | |
| 746 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 746 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 747 | 747 | exit; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | // We need an invoice and item. |
| 751 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
| 751 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
| 752 | 752 | exit; |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | // Fetch the invoice. |
| 756 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 756 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 757 | 757 | $alert = false; |
| 758 | 758 | |
| 759 | 759 | // Ensure it exists and its not been paid for. |
| 760 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 760 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 761 | 761 | exit; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | // Add the item. |
| 765 | - $item = new GetPaid_Form_Item( (int) $_POST['item_id'] ); |
|
| 766 | - $error = $invoice->add_item( $item ); |
|
| 765 | + $item = new GetPaid_Form_Item((int) $_POST['item_id']); |
|
| 766 | + $error = $invoice->add_item($item); |
|
| 767 | 767 | |
| 768 | - if ( is_wp_error( $error ) ) { |
|
| 768 | + if (is_wp_error($error)) { |
|
| 769 | 769 | $alert = $error->get_error_message(); |
| 770 | - wp_send_json_success( compact( 'alert' ) ); |
|
| 770 | + wp_send_json_success(compact('alert')); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | // Save the invoice. |
| 774 | 774 | $invoice->recalculate_total(); |
| 775 | 775 | $invoice->save(); |
| 776 | 776 | ob_start(); |
| 777 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
| 777 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
| 778 | 778 | $row = ob_get_clean(); |
| 779 | - wp_send_json_success( compact( 'row' ) ); |
|
| 779 | + wp_send_json_success(compact('row')); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
@@ -785,39 +785,39 @@ discard block |
||
| 785 | 785 | public static function add_invoice_items() { |
| 786 | 786 | |
| 787 | 787 | // Verify nonce. |
| 788 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 788 | + check_ajax_referer('wpinv-nonce'); |
|
| 789 | 789 | |
| 790 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 790 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 791 | 791 | exit; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | // We need an invoice and items. |
| 795 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
| 795 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
| 796 | 796 | exit; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | // Fetch the invoice. |
| 800 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
| 800 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
| 801 | 801 | $alert = false; |
| 802 | 802 | |
| 803 | 803 | // Ensure it exists and its not been paid for. |
| 804 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 804 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 805 | 805 | exit; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | // Add the items. |
| 809 | - foreach ( $_POST['items'] as $data ) { |
|
| 809 | + foreach ($_POST['items'] as $data) { |
|
| 810 | 810 | |
| 811 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
| 811 | + $item = new GetPaid_Form_Item($data['id']); |
|
| 812 | 812 | |
| 813 | - if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) { |
|
| 814 | - $item->set_quantity( $data[ 'qty' ] ); |
|
| 813 | + if (is_numeric($data['qty']) && (float) $data['qty'] > 0) { |
|
| 814 | + $item->set_quantity($data['qty']); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - if ( $item->get_id() > 0 ) { |
|
| 818 | - $error = $invoice->add_item( $item ); |
|
| 817 | + if ($item->get_id() > 0) { |
|
| 818 | + $error = $invoice->add_item($item); |
|
| 819 | 819 | |
| 820 | - if ( is_wp_error( $error ) ) { |
|
| 820 | + if (is_wp_error($error)) { |
|
| 821 | 821 | $alert = $error->get_error_message(); |
| 822 | 822 | } |
| 823 | 823 | |
@@ -832,11 +832,11 @@ discard block |
||
| 832 | 832 | // Return an array of invoice items. |
| 833 | 833 | $items = array(); |
| 834 | 834 | |
| 835 | - foreach ( $invoice->get_items() as $item ) { |
|
| 836 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 835 | + foreach ($invoice->get_items() as $item) { |
|
| 836 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
| 839 | + wp_send_json_success(compact('items', 'alert')); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -845,15 +845,15 @@ discard block |
||
| 845 | 845 | public static function get_invoicing_items() { |
| 846 | 846 | |
| 847 | 847 | // Verify nonce. |
| 848 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 848 | + check_ajax_referer('wpinv-nonce'); |
|
| 849 | 849 | |
| 850 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 850 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 851 | 851 | exit; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | // We need a search term. |
| 855 | - if ( empty( $_GET['search'] ) ) { |
|
| 856 | - wp_send_json_success( array() ); |
|
| 855 | + if (empty($_GET['search'])) { |
|
| 856 | + wp_send_json_success(array()); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | // Retrieve items. |
@@ -862,8 +862,8 @@ discard block |
||
| 862 | 862 | 'orderby' => 'title', |
| 863 | 863 | 'order' => 'ASC', |
| 864 | 864 | 'posts_per_page' => -1, |
| 865 | - 'post_status' => array( 'publish' ), |
|
| 866 | - 's' => trim( $_GET['search'] ), |
|
| 865 | + 'post_status' => array('publish'), |
|
| 866 | + 's' => trim($_GET['search']), |
|
| 867 | 867 | 'meta_query' => array( |
| 868 | 868 | array( |
| 869 | 869 | 'key' => '_wpinv_type', |
@@ -873,21 +873,21 @@ discard block |
||
| 873 | 873 | ) |
| 874 | 874 | ); |
| 875 | 875 | |
| 876 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
| 876 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
| 877 | 877 | $data = array(); |
| 878 | 878 | |
| 879 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) ); |
|
| 879 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id'])); |
|
| 880 | 880 | |
| 881 | - foreach ( $items as $item ) { |
|
| 882 | - $item = new GetPaid_Form_Item( $item ); |
|
| 881 | + foreach ($items as $item) { |
|
| 882 | + $item = new GetPaid_Form_Item($item); |
|
| 883 | 883 | $data[] = array( |
| 884 | 884 | 'id' => (int) $item->get_id(), |
| 885 | - 'text' => strip_tags( $item->get_name() ), |
|
| 886 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
| 885 | + 'text' => strip_tags($item->get_name()), |
|
| 886 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
| 887 | 887 | ); |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - wp_send_json_success( $data ); |
|
| 890 | + wp_send_json_success($data); |
|
| 891 | 891 | |
| 892 | 892 | } |
| 893 | 893 | |
@@ -897,37 +897,37 @@ discard block |
||
| 897 | 897 | public static function get_customers() { |
| 898 | 898 | |
| 899 | 899 | // Verify nonce. |
| 900 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 900 | + check_ajax_referer('wpinv-nonce'); |
|
| 901 | 901 | |
| 902 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 902 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 903 | 903 | exit; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | // We need a search term. |
| 907 | - if ( empty( $_GET['search'] ) ) { |
|
| 908 | - wp_send_json_success( array() ); |
|
| 907 | + if (empty($_GET['search'])) { |
|
| 908 | + wp_send_json_success(array()); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | // Retrieve customers. |
| 912 | 912 | |
| 913 | 913 | $customer_args = array( |
| 914 | - 'fields' => array( 'ID', 'user_email', 'display_name' ), |
|
| 914 | + 'fields' => array('ID', 'user_email', 'display_name'), |
|
| 915 | 915 | 'orderby' => 'display_name', |
| 916 | - 'search' => '*' . sanitize_text_field( $_GET['search'] ) . '*', |
|
| 917 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
| 916 | + 'search' => '*' . sanitize_text_field($_GET['search']) . '*', |
|
| 917 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
| 918 | 918 | ); |
| 919 | 919 | |
| 920 | - $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) ); |
|
| 920 | + $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args)); |
|
| 921 | 921 | $data = array(); |
| 922 | 922 | |
| 923 | - foreach ( $customers as $customer ) { |
|
| 923 | + foreach ($customers as $customer) { |
|
| 924 | 924 | $data[] = array( |
| 925 | 925 | 'id' => (int) $customer->ID, |
| 926 | - 'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ), |
|
| 926 | + 'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)), |
|
| 927 | 927 | ); |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | - wp_send_json_success( $data ); |
|
| 930 | + wp_send_json_success($data); |
|
| 931 | 931 | |
| 932 | 932 | } |
| 933 | 933 | |
@@ -937,28 +937,28 @@ discard block |
||
| 937 | 937 | public static function get_aui_states_field() { |
| 938 | 938 | |
| 939 | 939 | // Verify nonce. |
| 940 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 940 | + check_ajax_referer('wpinv-nonce'); |
|
| 941 | 941 | |
| 942 | 942 | // We need a country. |
| 943 | - if ( empty( $_GET['country'] ) ) { |
|
| 943 | + if (empty($_GET['country'])) { |
|
| 944 | 944 | exit; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) ); |
|
| 948 | - $state = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state(); |
|
| 949 | - $name = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state'; |
|
| 950 | - $class = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm'; |
|
| 947 | + $states = wpinv_get_country_states(sanitize_text_field($_GET['country'])); |
|
| 948 | + $state = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state(); |
|
| 949 | + $name = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state'; |
|
| 950 | + $class = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm'; |
|
| 951 | 951 | |
| 952 | - if ( empty( $states ) ) { |
|
| 952 | + if (empty($states)) { |
|
| 953 | 953 | |
| 954 | 954 | $html = aui()->input( |
| 955 | 955 | array( |
| 956 | 956 | 'type' => 'text', |
| 957 | 957 | 'id' => 'wpinv_state', |
| 958 | 958 | 'name' => $name, |
| 959 | - 'label' => __( 'State', 'invoicing' ), |
|
| 959 | + 'label' => __('State', 'invoicing'), |
|
| 960 | 960 | 'label_type' => 'vertical', |
| 961 | - 'placeholder' => __( 'State', 'invoicing' ), |
|
| 961 | + 'placeholder' => __('State', 'invoicing'), |
|
| 962 | 962 | 'class' => $class, |
| 963 | 963 | 'value' => $state, |
| 964 | 964 | ) |
@@ -970,9 +970,9 @@ discard block |
||
| 970 | 970 | array( |
| 971 | 971 | 'id' => 'wpinv_state', |
| 972 | 972 | 'name' => $name, |
| 973 | - 'label' => __( 'State', 'invoicing' ), |
|
| 973 | + 'label' => __('State', 'invoicing'), |
|
| 974 | 974 | 'label_type' => 'vertical', |
| 975 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 975 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 976 | 976 | 'class' => $class, |
| 977 | 977 | 'value' => $state, |
| 978 | 978 | 'options' => $states, |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | wp_send_json_success( |
| 987 | 987 | array( |
| 988 | 988 | 'html' => $html, |
| 989 | - 'select' => ! empty ( $states ) |
|
| 989 | + 'select' => !empty ($states) |
|
| 990 | 990 | ) |
| 991 | 991 | ); |
| 992 | 992 | |
@@ -1000,11 +1000,11 @@ discard block |
||
| 1000 | 1000 | public static function payment_form_refresh_prices() { |
| 1001 | 1001 | |
| 1002 | 1002 | // Check nonce. |
| 1003 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 1003 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 1004 | 1004 | |
| 1005 | 1005 | // ... form fields... |
| 1006 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 1007 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
| 1006 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
| 1007 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
| 1008 | 1008 | exit; |
| 1009 | 1009 | } |
| 1010 | 1010 | |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | $submission = new GetPaid_Payment_Form_Submission(); |
| 1013 | 1013 | |
| 1014 | 1014 | // Do we have an error? |
| 1015 | - if ( ! empty( $submission->last_error ) ) { |
|
| 1015 | + if (!empty($submission->last_error)) { |
|
| 1016 | 1016 | wp_send_json_error( |
| 1017 | 1017 | array( |
| 1018 | 1018 | 'code' => $submission->last_error_code, |
@@ -1022,12 +1022,12 @@ discard block |
||
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | // Prepare the response. |
| 1025 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
| 1025 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
| 1026 | 1026 | |
| 1027 | 1027 | // Filter the response. |
| 1028 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
| 1028 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
| 1029 | 1029 | |
| 1030 | - wp_send_json_success( $response ); |
|
| 1030 | + wp_send_json_success($response); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | } |
@@ -7,65 +7,65 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_bulk_actions( $actions ) { |
|
| 15 | - if ( isset( $actions['edit'] ) ) { |
|
| 16 | - unset( $actions['edit'] ); |
|
| 14 | +function wpinv_bulk_actions($actions) { |
|
| 15 | + if (isset($actions['edit'])) { |
|
| 16 | + unset($actions['edit']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | return $actions; |
| 20 | 20 | } |
| 21 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 22 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
| 21 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 22 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
| 23 | 23 | |
| 24 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 24 | +function wpinv_admin_post_id($id = 0) { |
|
| 25 | 25 | global $post; |
| 26 | 26 | |
| 27 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 28 | - return (int)$id; |
|
| 29 | - } else if ( get_the_ID() ) { |
|
| 27 | + if (isset($id) && !empty($id)) { |
|
| 28 | + return (int) $id; |
|
| 29 | + } else if (get_the_ID()) { |
|
| 30 | 30 | return (int) get_the_ID(); |
| 31 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 31 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 32 | 32 | return (int) $post->ID; |
| 33 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 33 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 34 | 34 | return (int) $_GET['post']; |
| 35 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 35 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 36 | 36 | return (int) $_GET['id']; |
| 37 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 37 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 38 | 38 | return (int) $_POST['id']; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return null; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 45 | - if ( !$id ) { |
|
| 44 | +function wpinv_admin_post_type($id = 0) { |
|
| 45 | + if (!$id) { |
|
| 46 | 46 | $id = wpinv_admin_post_id(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $type = get_post_type( $id ); |
|
| 49 | + $type = get_post_type($id); |
|
| 50 | 50 | |
| 51 | - if ( !$type ) { |
|
| 52 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 51 | + if (!$type) { |
|
| 52 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 55 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function wpinv_admin_messages() { |
| 59 | - settings_errors( 'wpinv-notices' ); |
|
| 59 | + settings_errors('wpinv-notices'); |
|
| 60 | 60 | } |
| 61 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 61 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 62 | 62 | |
| 63 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
| 64 | -function wpinv_show_test_payment_gateway_notice(){ |
|
| 65 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
| 63 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
| 64 | +function wpinv_show_test_payment_gateway_notice() { |
|
| 65 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -function wpinv_test_payment_gateway_messages(){ |
|
| 68 | +function wpinv_test_payment_gateway_messages() { |
|
| 69 | 69 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 70 | 70 | $name = array(); $test_gateways = ''; |
| 71 | 71 | if ($gateways) { |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | $test_gateways = implode(', ', $name); |
| 78 | 78 | } |
| 79 | - if(isset($test_gateways) && !empty($test_gateways)){ |
|
| 79 | + if (isset($test_gateways) && !empty($test_gateways)) { |
|
| 80 | 80 | $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
| 81 | - $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link ); |
|
| 81 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
| 82 | 82 | ?> |
| 83 | 83 | <div class="notice notice-warning is-dismissible"> |
| 84 | 84 | <p><?php echo $notice; ?></p> |
@@ -95,29 +95,29 @@ discard block |
||
| 95 | 95 | global $wpdb; |
| 96 | 96 | |
| 97 | 97 | // Only do this on our settings page. |
| 98 | - if ( empty( $_GET[ 'page' ] ) || 'wpinv-settings' !== $_GET[ 'page' ] ) { |
|
| 98 | + if (empty($_GET['page']) || 'wpinv-settings' !== $_GET['page']) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Check tables. |
| 103 | - $tables = array( |
|
| 103 | + $tables = array( |
|
| 104 | 104 | "{$wpdb->prefix}wpinv_subscriptions", |
| 105 | 105 | "{$wpdb->prefix}getpaid_invoices", |
| 106 | 106 | "{$wpdb->prefix}getpaid_invoice_items", |
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | - foreach ( $tables as $table ) { |
|
| 110 | - if ( $table != $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) ) { |
|
| 109 | + foreach ($tables as $table) { |
|
| 110 | + if ($table != $wpdb->get_var("SHOW TABLES LIKE '$table'")) { |
|
| 111 | 111 | |
| 112 | - $url = esc_url( |
|
| 112 | + $url = esc_url( |
|
| 113 | 113 | wp_nonce_url( |
| 114 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 114 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
| 115 | 115 | 'getpaid-nonce', |
| 116 | 116 | 'getpaid-nonce' |
| 117 | 117 | ) |
| 118 | 118 | ); |
| 119 | - $message = __( 'Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing' ); |
|
| 120 | - $message2 = __( 'Create Tables', 'invoicing' ); |
|
| 119 | + $message = __('Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing'); |
|
| 120 | + $message2 = __('Create Tables', 'invoicing'); |
|
| 121 | 121 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
| 122 | 122 | break; |
| 123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | } |
| 128 | -add_action( 'admin_notices', 'wpinv_check_for_missing_tables' ); |
|
| 128 | +add_action('admin_notices', 'wpinv_check_for_missing_tables'); |
|
| 129 | 129 | |
| 130 | 130 | add_action('admin_init', 'wpinv_admin_search_by_invoice'); |
| 131 | 131 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | function wpinv_admin_search_by_invoice() { |
| 136 | 136 | global $typenow; |
| 137 | 137 | |
| 138 | - if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
| 138 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
| 139 | 139 | add_filter('posts_search', 'wpinv_posts_search_example_type', 10, 2); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | global $wpdb; |
| 151 | 151 | |
| 152 | 152 | if ($query->is_main_query() && !empty($query->query['s'])) { |
| 153 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
| 154 | - if ( ! empty( $search ) ) { |
|
| 155 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
| 153 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
| 154 | + if (!empty($search)) { |
|
| 155 | + $search = preg_replace('/^ AND /', '', $search); |
|
| 156 | 156 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
| 157 | 157 | } else { |
| 158 | 158 | $search = " AND ( {$conditions_str} )"; |
@@ -165,17 +165,17 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * Resets invoice counts. |
| 167 | 167 | */ |
| 168 | -function wpinv_reset_invoice_count(){ |
|
| 169 | - if ( ! empty( $_GET['reset_invoice_count'] ) && isset( $_GET['_nonce'] ) && wp_verify_nonce( $_GET['_nonce'], 'reset_invoice_count' ) ) { |
|
| 168 | +function wpinv_reset_invoice_count() { |
|
| 169 | + if (!empty($_GET['reset_invoice_count']) && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 170 | 170 | wpinv_update_option('invoice_sequence_start', 1); |
| 171 | 171 | delete_option('wpinv_last_invoice_number'); |
| 172 | - getpaid_admin()->show_success( __( 'Invoice number sequence reset successfully.', 'invoicing' ) ); |
|
| 173 | - $url = remove_query_arg( array('reset_invoice_count', '_nonce') ); |
|
| 172 | + getpaid_admin()->show_success(__('Invoice number sequence reset successfully.', 'invoicing')); |
|
| 173 | + $url = remove_query_arg(array('reset_invoice_count', '_nonce')); |
|
| 174 | 174 | wp_redirect($url); |
| 175 | 175 | exit(); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
| 178 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
| 179 | 179 | |
| 180 | 180 | /** |
| 181 | 181 | * Displays line items on the invoice edit page. |
@@ -184,29 +184,29 @@ discard block |
||
| 184 | 184 | * @param array $columns |
| 185 | 185 | * @return string |
| 186 | 186 | */ |
| 187 | -function wpinv_admin_get_line_items( $invoice, $columns ) { |
|
| 187 | +function wpinv_admin_get_line_items($invoice, $columns) { |
|
| 188 | 188 | |
| 189 | 189 | ob_start(); |
| 190 | 190 | |
| 191 | - do_action( 'getpaid_admin_before_line_items', $invoice ); |
|
| 191 | + do_action('getpaid_admin_before_line_items', $invoice); |
|
| 192 | 192 | |
| 193 | 193 | $count = 0; |
| 194 | - foreach ( $invoice->get_items() as $item ) { |
|
| 194 | + foreach ($invoice->get_items() as $item) { |
|
| 195 | 195 | |
| 196 | - $item_price = wpinv_price( $item->get_price(), $invoice->get_currency() ); |
|
| 196 | + $item_price = wpinv_price($item->get_price(), $invoice->get_currency()); |
|
| 197 | 197 | $quantity = (int) $item->get_quantity(); |
| 198 | - $item_subtotal = wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
| 199 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
| 198 | + $item_subtotal = wpinv_price($item->get_sub_total(), $invoice->get_currency()); |
|
| 199 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
| 200 | 200 | $item_tax = $item->item_tax; |
| 201 | - $tax_rate = wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2, true ) . '%';; |
|
| 202 | - $tax_rate = empty( $tax_rate ) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
| 201 | + $tax_rate = wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2, true) . '%'; ; |
|
| 202 | + $tax_rate = empty($tax_rate) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
| 203 | 203 | $line_item_tax = $item_tax . $tax_rate; |
| 204 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . esc_attr( $item->get_id() ) . '">'; |
|
| 204 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . esc_attr($item->get_id()) . '">'; |
|
| 205 | 205 | $line_item .= '<td class="id">' . (int) $item->get_id() . '</td>'; |
| 206 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item->get_id() ) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
| 206 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item->get_id()) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
| 207 | 207 | |
| 208 | - if ( $summary !== '' ) { |
|
| 209 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 208 | + if ($summary !== '') { |
|
| 209 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $line_item .= '</td>'; |
@@ -214,23 +214,23 @@ discard block |
||
| 214 | 214 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 215 | 215 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 216 | 216 | |
| 217 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
| 217 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
| 218 | 218 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | $line_item .= '<td class="action">'; |
| 222 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 222 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 223 | 223 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 224 | 224 | } |
| 225 | 225 | $line_item .= '</td>'; |
| 226 | 226 | $line_item .= '</tr>'; |
| 227 | 227 | |
| 228 | - echo apply_filters( 'getpaid_admin_line_item', $line_item, $item, $invoice ); |
|
| 228 | + echo apply_filters('getpaid_admin_line_item', $line_item, $item, $invoice); |
|
| 229 | 229 | |
| 230 | 230 | $count++; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - do_action( 'getpaid_admin_after_line_items', $invoice ); |
|
| 233 | + do_action('getpaid_admin_after_line_items', $invoice); |
|
| 234 | 234 | |
| 235 | 235 | return ob_get_clean(); |
| 236 | 236 | } |
@@ -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,13 +21,13 @@ 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 | 29 | // Nonce field. |
| 30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ; |
|
| 30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | ?> |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | <div class="bsui" style="margin-top: 1.5rem"> |
| 48 | 48 | |
| 49 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
| 50 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
| 49 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
| 50 | + <?php if (!$invoice->is_draft()) : ?> |
|
| 51 | 51 | <div class="form-group"> |
| 52 | - <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong> |
|
| 53 | - <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?> |
|
| 52 | + <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
| 53 | + <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?> |
|
| 54 | 54 | </div> |
| 55 | 55 | <?php endif; ?> |
| 56 | 56 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // Date created. |
| 60 | 60 | $label = sprintf( |
| 61 | - __( '%s Date:', 'invoicing' ), |
|
| 62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 61 | + __('%s Date:', 'invoicing'), |
|
| 62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - $info = sprintf( |
|
| 66 | - __( 'The date this %s was created.', 'invoicing' ), |
|
| 67 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
| 65 | + $info = sprintf( |
|
| 66 | + __('The date this %s was created.', 'invoicing'), |
|
| 67 | + strtolower($invoice->get_invoice_quote_type()) |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | echo aui()->input( |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | 'type' => 'datepicker', |
| 73 | 73 | 'id' => 'wpinv_date_created', |
| 74 | 74 | 'name' => 'date_created', |
| 75 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
| 75 | + 'label' => $label . getpaid_get_help_tip($info), |
|
| 76 | 76 | 'label_type' => 'vertical', |
| 77 | 77 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 78 | 78 | 'class' => 'form-control-sm', |
| 79 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
| 79 | + 'value' => $invoice->get_date_created('edit'), |
|
| 80 | 80 | 'extra_attributes' => array( |
| 81 | 81 | 'data-enable-time' => 'true', |
| 82 | 82 | 'data-time_24hr' => 'true', |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | // Date paid. |
| 90 | - $date_paid = $invoice->get_date_completed( 'edit' ); |
|
| 91 | - if ( ! empty( $date_paid ) && $invoice->is_paid() ) { |
|
| 90 | + $date_paid = $invoice->get_date_completed('edit'); |
|
| 91 | + if (!empty($date_paid) && $invoice->is_paid()) { |
|
| 92 | 92 | |
| 93 | 93 | echo aui()->input( |
| 94 | 94 | array( |
| 95 | 95 | 'type' => 'text', |
| 96 | 96 | 'id' => 'wpinv_date_completed', |
| 97 | 97 | 'name' => 'wpinv_date_completed', |
| 98 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
| 98 | + 'label' => __('Date Completed:', 'invoicing'), |
|
| 99 | 99 | 'label_type' => 'vertical', |
| 100 | 100 | 'class' => 'form-control-sm', |
| 101 | 101 | 'value' => $date_paid, |
@@ -105,18 +105,18 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Due date. |
| 108 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( ! $invoice->is_paid() || $invoice->is_draft() ) ) { |
|
| 108 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && (!$invoice->is_paid() || $invoice->is_draft())) { |
|
| 109 | 109 | |
| 110 | 110 | echo aui()->input( |
| 111 | 111 | array( |
| 112 | 112 | 'type' => 'datepicker', |
| 113 | 113 | 'id' => 'wpinv_due_date', |
| 114 | 114 | 'name' => 'wpinv_due_date', |
| 115 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
| 115 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
| 116 | 116 | 'label_type' => 'vertical', |
| 117 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
| 117 | + 'placeholder' => __('No due date', 'invoicing'), |
|
| 118 | 118 | 'class' => 'form-control-sm', |
| 119 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
| 119 | + 'value' => $invoice->get_due_date('edit'), |
|
| 120 | 120 | 'extra_attributes' => array( |
| 121 | 121 | 'data-enable-time' => 'true', |
| 122 | 122 | 'data-time_24hr' => 'true', |
@@ -128,39 +128,39 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
| 132 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
| 131 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
| 132 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
| 133 | 133 | |
| 134 | 134 | // Status. |
| 135 | 135 | $label = sprintf( |
| 136 | - __( '%s Status:', 'invoicing' ), |
|
| 137 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 136 | + __('%s Status:', 'invoicing'), |
|
| 137 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | - $status = $invoice->get_status( 'edit' ); |
|
| 140 | + $status = $invoice->get_status('edit'); |
|
| 141 | 141 | echo aui()->select( |
| 142 | 142 | array( |
| 143 | 143 | 'id' => 'wpinv_status', |
| 144 | 144 | 'name' => 'wpinv_status', |
| 145 | 145 | 'label' => $label, |
| 146 | 146 | 'label_type' => 'vertical', |
| 147 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
| 148 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
| 147 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
| 148 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
| 149 | 149 | 'select2' => true, |
| 150 | 150 | 'data-allow-clear' => 'false', |
| 151 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ) |
|
| 151 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice) |
|
| 152 | 152 | ) |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | 155 | // Invoice number. |
| 156 | 156 | $label = sprintf( |
| 157 | - __( '%s Number:', 'invoicing' ), |
|
| 158 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 157 | + __('%s Number:', 'invoicing'), |
|
| 158 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 159 | 159 | ); |
| 160 | 160 | |
| 161 | - $info = sprintf( |
|
| 162 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
| 163 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
| 161 | + $info = sprintf( |
|
| 162 | + __('Each %s number must be unique.', 'invoicing'), |
|
| 163 | + strtolower($invoice->get_invoice_quote_type()) |
|
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | echo aui()->input( |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | 'type' => 'text', |
| 169 | 169 | 'id' => 'wpinv_number', |
| 170 | 170 | 'name' => 'wpinv_number', |
| 171 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
| 171 | + 'label' => $label . getpaid_get_help_tip($info), |
|
| 172 | 172 | 'label_type' => 'vertical', |
| 173 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
| 173 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
| 174 | 174 | 'class' => 'form-control-sm', |
| 175 | - 'value' => $invoice->get_number( 'edit' ), |
|
| 175 | + 'value' => $invoice->get_number('edit'), |
|
| 176 | 176 | ) |
| 177 | 177 | ); |
| 178 | 178 | |
@@ -182,15 +182,15 @@ discard block |
||
| 182 | 182 | 'type' => 'text', |
| 183 | 183 | 'id' => 'wpinv_cc', |
| 184 | 184 | 'name' => 'wpinv_cc', |
| 185 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
| 185 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
| 186 | 186 | 'label_type' => 'vertical', |
| 187 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
| 187 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
| 188 | 188 | 'class' => 'form-control-sm', |
| 189 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
| 189 | + 'value' => $invoice->get_email_cc('edit'), |
|
| 190 | 190 | ) |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 193 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 194 | 194 | |
| 195 | 195 | // Apply a discount. |
| 196 | 196 | echo aui()->input( |
@@ -198,25 +198,25 @@ discard block |
||
| 198 | 198 | 'type' => 'text', |
| 199 | 199 | 'id' => 'wpinv_discount_code', |
| 200 | 200 | 'name' => 'wpinv_discount_code', |
| 201 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
| 202 | - 'placeholder' => __( 'Apply Discount', 'invoicing' ), |
|
| 201 | + 'label' => __('Discount Code:', 'invoicing'), |
|
| 202 | + 'placeholder' => __('Apply Discount', 'invoicing'), |
|
| 203 | 203 | 'label_type' => 'vertical', |
| 204 | 204 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
| 205 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
| 205 | + 'value' => $invoice->get_discount_code('edit'), |
|
| 206 | 206 | ) |
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | - } else if ( $invoice->get_discount_code( 'edit' ) ) { |
|
| 209 | + } else if ($invoice->get_discount_code('edit')) { |
|
| 210 | 210 | |
| 211 | 211 | echo aui()->input( |
| 212 | 212 | array( |
| 213 | 213 | 'type' => 'text', |
| 214 | 214 | 'id' => 'wpinv_discount_code', |
| 215 | 215 | 'name' => 'wpinv_discount_code', |
| 216 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
| 216 | + 'label' => __('Discount Code:', 'invoicing'), |
|
| 217 | 217 | 'label_type' => 'vertical', |
| 218 | 218 | 'class' => 'form-control-sm', |
| 219 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
| 219 | + 'value' => $invoice->get_discount_code('edit'), |
|
| 220 | 220 | 'extra_attributes' => array( |
| 221 | 221 | 'onclick' => 'this.select();', |
| 222 | 222 | 'readonly' => 'true', |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
| 229 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
| 230 | 230 | |
| 231 | 231 | // Disable taxes. |
| 232 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
| 232 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
| 233 | 233 | |
| 234 | 234 | echo aui()->input( |
| 235 | 235 | array( |
| 236 | 236 | 'id' => 'wpinv_taxable', |
| 237 | 237 | 'name' => 'disable_taxes', |
| 238 | 238 | 'type' => 'checkbox', |
| 239 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
| 239 | + 'label' => __('Disable taxes', 'invoicing'), |
|
| 240 | 240 | 'value' => '1', |
| 241 | 241 | 'checked' => (bool) $invoice->get_disable_taxes(), |
| 242 | 242 | 'class' => 'getpaid-recalculate-prices-on-change', |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( $invoice->is_type( 'invoice' ) ) { |
|
| 248 | + if ($invoice->is_type('invoice')) { |
|
| 249 | 249 | |
| 250 | 250 | // Send to customer. |
| 251 | 251 | echo aui()->input( |
@@ -253,15 +253,15 @@ discard block |
||
| 253 | 253 | 'id' => 'wpinv_send_to_customer', |
| 254 | 254 | 'name' => 'send_to_customer', |
| 255 | 255 | 'type' => 'checkbox', |
| 256 | - 'label' => __( 'Send invoice to customer after saving', 'invoicing' ), |
|
| 256 | + 'label' => __('Send invoice to customer after saving', 'invoicing'), |
|
| 257 | 257 | 'value' => '1', |
| 258 | - 'checked' => $invoice->is_draft() && (bool) wpinv_get_option( 'email_user_invoice_active', true ), |
|
| 258 | + 'checked' => $invoice->is_draft() && (bool) wpinv_get_option('email_user_invoice_active', true), |
|
| 259 | 259 | ) |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
| 264 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
| 265 | 265 | |
| 266 | 266 | ?> |
| 267 | 267 | |
@@ -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,14 +21,14 @@ 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 ); |
|
| 28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
| 29 | - $customer = new WP_User( $customer ); |
|
| 30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
| 31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 27 | + $invoice = new WPInv_Invoice($post); |
|
| 28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
| 29 | + $customer = new WP_User($customer); |
|
| 30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
| 31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 32 | 32 | |
| 33 | 33 | ?> |
| 34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | <div class="col-12 col-sm-6"> |
| 44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
| 45 | 45 | <div> |
| 46 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 46 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 47 | 47 | </div> |
| 48 | 48 | <div> |
| 49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
| 50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field( $display ); ?> </option>) |
|
| 49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
| 50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field($display); ?> </option>) |
|
| 51 | 51 | </select> |
| 52 | 52 | </div> |
| 53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'type' => 'text', |
| 61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
| 62 | 62 | 'name' => 'wpinv_email', |
| 63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
| 63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
| 64 | 64 | 'label_type' => 'vertical', |
| 65 | 65 | 'placeholder' => '[email protected]', |
| 66 | 66 | 'class' => 'form-control-sm', |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | </div> |
| 71 | 71 | </div> |
| 72 | 72 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
| 73 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
| 73 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
| 74 | 74 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
| 75 | 75 | <i aria-hidden="true" class="fa fa-refresh"></i> |
| 76 | - <?php _e( 'Fill User Details', 'invoicing' );?> |
|
| 76 | + <?php _e('Fill User Details', 'invoicing'); ?> |
|
| 77 | 77 | </a> |
| 78 | 78 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
| 79 | 79 | <i aria-hidden="true" class="fa fa-plus"></i> |
| 80 | - <?php _e( 'Add New User', 'invoicing' );?> |
|
| 80 | + <?php _e('Add New User', 'invoicing'); ?> |
|
| 81 | 81 | </a> |
| 82 | 82 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
| 83 | 83 | <i aria-hidden="true" class="fa fa-close"></i> |
| 84 | - <?php _e( 'Cancel', 'invoicing' );?> |
|
| 84 | + <?php _e('Cancel', 'invoicing'); ?> |
|
| 85 | 85 | </a> |
| 86 | 86 | <?php endif; ?> |
| 87 | 87 | </div> |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | 'type' => 'text', |
| 95 | 95 | 'id' => 'wpinv_first_name', |
| 96 | 96 | 'name' => 'wpinv_first_name', |
| 97 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 97 | + 'label' => __('First Name', 'invoicing'), |
|
| 98 | 98 | 'label_type' => 'vertical', |
| 99 | 99 | 'placeholder' => '', |
| 100 | 100 | 'class' => 'form-control-sm', |
| 101 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
| 101 | + 'value' => $invoice->get_first_name('edit'), |
|
| 102 | 102 | ) |
| 103 | 103 | ); |
| 104 | 104 | ?> |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | 'type' => 'text', |
| 111 | 111 | 'id' => 'wpinv_last_name', |
| 112 | 112 | 'name' => 'wpinv_last_name', |
| 113 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 113 | + 'label' => __('Last Name', 'invoicing'), |
|
| 114 | 114 | 'label_type' => 'vertical', |
| 115 | 115 | 'placeholder' => '', |
| 116 | 116 | 'class' => 'form-control-sm', |
| 117 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
| 117 | + 'value' => $invoice->get_last_name('edit'), |
|
| 118 | 118 | ) |
| 119 | 119 | ); |
| 120 | 120 | ?> |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | 'type' => 'text', |
| 130 | 130 | 'id' => 'wpinv_company', |
| 131 | 131 | 'name' => 'wpinv_company', |
| 132 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 132 | + 'label' => __('Company', 'invoicing'), |
|
| 133 | 133 | 'label_type' => 'vertical', |
| 134 | 134 | 'placeholder' => '', |
| 135 | 135 | 'class' => 'form-control-sm', |
| 136 | - 'value' => $invoice->get_company( 'edit' ), |
|
| 136 | + 'value' => $invoice->get_company('edit'), |
|
| 137 | 137 | ) |
| 138 | 138 | ); |
| 139 | 139 | ?> |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | 'type' => 'text', |
| 146 | 146 | 'id' => 'wpinv_vat_number', |
| 147 | 147 | 'name' => 'wpinv_vat_number', |
| 148 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
| 148 | + 'label' => __('Vat Number', 'invoicing'), |
|
| 149 | 149 | 'label_type' => 'vertical', |
| 150 | 150 | 'placeholder' => '', |
| 151 | 151 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
| 152 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
| 152 | + 'value' => $invoice->get_vat_number('edit'), |
|
| 153 | 153 | ) |
| 154 | 154 | ); |
| 155 | 155 | ?> |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | 'type' => 'text', |
| 165 | 165 | 'id' => 'wpinv_address', |
| 166 | 166 | 'name' => 'wpinv_address', |
| 167 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 167 | + 'label' => __('Address', 'invoicing'), |
|
| 168 | 168 | 'label_type' => 'vertical', |
| 169 | 169 | 'placeholder' => '', |
| 170 | 170 | 'class' => 'form-control-sm', |
| 171 | - 'value' => $invoice->get_address( 'edit' ), |
|
| 171 | + 'value' => $invoice->get_address('edit'), |
|
| 172 | 172 | ) |
| 173 | 173 | ); |
| 174 | 174 | ?> |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | 'type' => 'text', |
| 181 | 181 | 'id' => 'wpinv_city', |
| 182 | 182 | 'name' => 'wpinv_city', |
| 183 | - 'label' => __( 'City', 'invoicing' ), |
|
| 183 | + 'label' => __('City', 'invoicing'), |
|
| 184 | 184 | 'label_type' => 'vertical', |
| 185 | 185 | 'placeholder' => '', |
| 186 | 186 | 'class' => 'form-control-sm', |
| 187 | - 'value' => $invoice->get_city( 'edit' ), |
|
| 187 | + 'value' => $invoice->get_city('edit'), |
|
| 188 | 188 | ) |
| 189 | 189 | ); |
| 190 | 190 | ?> |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | array( |
| 199 | 199 | 'id' => 'wpinv_country', |
| 200 | 200 | 'name' => 'wpinv_country', |
| 201 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 201 | + 'label' => __('Country', 'invoicing'), |
|
| 202 | 202 | 'label_type' => 'vertical', |
| 203 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 203 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 204 | 204 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
| 205 | - 'value' => $invoice->get_country( 'edit' ), |
|
| 205 | + 'value' => $invoice->get_country('edit'), |
|
| 206 | 206 | 'options' => wpinv_get_country_list(), |
| 207 | 207 | 'data-allow-clear' => 'false', |
| 208 | 208 | 'select2' => true, |
@@ -213,20 +213,20 @@ discard block |
||
| 213 | 213 | <div class="col-12 col-sm-6"> |
| 214 | 214 | <?php |
| 215 | 215 | |
| 216 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
| 216 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
| 217 | 217 | |
| 218 | - if ( empty( $states ) ) { |
|
| 218 | + if (empty($states)) { |
|
| 219 | 219 | |
| 220 | 220 | echo aui()->input( |
| 221 | 221 | array( |
| 222 | 222 | 'type' => 'text', |
| 223 | 223 | 'id' => 'wpinv_state', |
| 224 | 224 | 'name' => 'wpinv_state', |
| 225 | - 'label' => __( 'State', 'invoicing' ), |
|
| 225 | + 'label' => __('State', 'invoicing'), |
|
| 226 | 226 | 'label_type' => 'vertical', |
| 227 | 227 | 'placeholder' => '', |
| 228 | 228 | 'class' => 'form-control-sm', |
| 229 | - 'value' => $invoice->get_state( 'edit' ), |
|
| 229 | + 'value' => $invoice->get_state('edit'), |
|
| 230 | 230 | ) |
| 231 | 231 | ); |
| 232 | 232 | |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | array( |
| 237 | 237 | 'id' => 'wpinv_state', |
| 238 | 238 | 'name' => 'wpinv_state', |
| 239 | - 'label' => __( 'State', 'invoicing' ), |
|
| 239 | + 'label' => __('State', 'invoicing'), |
|
| 240 | 240 | 'label_type' => 'vertical', |
| 241 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 241 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 242 | 242 | 'class' => 'form-control-sm', |
| 243 | - 'value' => $invoice->get_state( 'edit' ), |
|
| 243 | + 'value' => $invoice->get_state('edit'), |
|
| 244 | 244 | 'options' => $states, |
| 245 | 245 | 'data-allow-clear' => 'false', |
| 246 | 246 | 'select2' => true, |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | 'type' => 'text', |
| 262 | 262 | 'id' => 'wpinv_zip', |
| 263 | 263 | 'name' => 'wpinv_zip', |
| 264 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
| 264 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
| 265 | 265 | 'label_type' => 'vertical', |
| 266 | 266 | 'placeholder' => '', |
| 267 | 267 | 'class' => 'form-control-sm', |
| 268 | - 'value' => $invoice->get_zip( 'edit' ), |
|
| 268 | + 'value' => $invoice->get_zip('edit'), |
|
| 269 | 269 | ) |
| 270 | 270 | ); |
| 271 | 271 | ?> |
@@ -277,18 +277,18 @@ discard block |
||
| 277 | 277 | 'type' => 'text', |
| 278 | 278 | 'id' => 'wpinv_phone', |
| 279 | 279 | 'name' => 'wpinv_phone', |
| 280 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 280 | + 'label' => __('Phone', 'invoicing'), |
|
| 281 | 281 | 'label_type' => 'vertical', |
| 282 | 282 | 'placeholder' => '', |
| 283 | 283 | 'class' => 'form-control-sm', |
| 284 | - 'value' => $invoice->get_phone( 'edit' ), |
|
| 284 | + 'value' => $invoice->get_phone('edit'), |
|
| 285 | 285 | ) |
| 286 | 286 | ); |
| 287 | 287 | ?> |
| 288 | 288 | </div> |
| 289 | 289 | </div> |
| 290 | 290 | |
| 291 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
| 291 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
| 292 | 292 | </div> |
| 293 | 293 | <?php |
| 294 | 294 | } |
@@ -298,50 +298,50 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @param int $post_id |
| 300 | 300 | */ |
| 301 | - public static function save( $post_id ) { |
|
| 301 | + public static function save($post_id) { |
|
| 302 | 302 | |
| 303 | 303 | // Prepare the invoice. |
| 304 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 304 | + $invoice = new WPInv_Invoice($post_id); |
|
| 305 | 305 | |
| 306 | 306 | // Load new data. |
| 307 | 307 | $invoice->set_props( |
| 308 | 308 | array( |
| 309 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
| 310 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
| 311 | - 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
|
| 312 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
| 313 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
| 314 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
| 315 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
| 316 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
| 317 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
| 318 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
| 319 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
| 320 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
| 321 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
| 322 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
| 323 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
| 324 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
| 325 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
| 326 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
| 327 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
| 328 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
| 329 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
| 309 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
| 310 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
| 311 | + 'disable_taxes' => isset($_POST['disable_taxes']), |
|
| 312 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
| 313 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
| 314 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
| 315 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
| 316 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
| 317 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
| 318 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
| 319 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
| 320 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
| 321 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
| 322 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
| 323 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
| 324 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
| 325 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
| 326 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
| 327 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
| 328 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
| 329 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
| 330 | 330 | ) |
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | 333 | // Discount code. |
| 334 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 334 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 335 | 335 | |
| 336 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
| 337 | - $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) ); |
|
| 336 | + if (isset($_POST['wpinv_discount_code'])) { |
|
| 337 | + $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code'])); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 341 | - if ( $discount->exists() ) { |
|
| 342 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 340 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 341 | + if ($discount->exists()) { |
|
| 342 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 343 | 343 | } else { |
| 344 | - $invoice->remove_discount( 'discount_code' ); |
|
| 344 | + $invoice->remove_discount('discount_code'); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // Recalculate totals. |
@@ -350,17 +350,17 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // If we're creating a new user... |
| 353 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) { |
|
| 353 | + if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) { |
|
| 354 | 354 | |
| 355 | 355 | // Attempt to create the user. |
| 356 | - $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) ); |
|
| 356 | + $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email']))); |
|
| 357 | 357 | |
| 358 | 358 | |
| 359 | 359 | // If successful, update the invoice author. |
| 360 | - if ( is_numeric( $user ) ) { |
|
| 361 | - $invoice->set_author( $user ); |
|
| 360 | + if (is_numeric($user)) { |
|
| 361 | + $invoice->set_author($user); |
|
| 362 | 362 | } else { |
| 363 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 363 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | |
@@ -374,24 +374,24 @@ discard block |
||
| 374 | 374 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
| 375 | 375 | |
| 376 | 376 | // (Maybe) send new user notification. |
| 377 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
| 378 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
| 379 | - wp_send_new_user_notifications( $user, 'user' ); |
|
| 377 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
| 378 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
| 379 | + wp_send_new_user_notifications($user, 'user'); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
| 382 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
| 383 | 383 | |
| 384 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
| 384 | + $sent = getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
| 385 | 385 | |
| 386 | - if ( $sent ) { |
|
| 387 | - getpaid_admin()->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 386 | + if ($sent) { |
|
| 387 | + getpaid_admin()->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
| 388 | 388 | } else { |
| 389 | - getpaid_admin()->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
| 389 | + getpaid_admin()->show_error(__('Could not send the invoice to the customer', 'invoicing')); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // Fires after an invoice is saved. |
| 395 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
| 395 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
| 396 | 396 | } |
| 397 | 397 | } |
@@ -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 | /** |
@@ -319,10 +319,10 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
| 322 | - * Output the metabox. |
|
| 323 | - * |
|
| 324 | - * @param WP_Post $post |
|
| 325 | - */ |
|
| 322 | + * Output the metabox. |
|
| 323 | + * |
|
| 324 | + * @param WP_Post $post |
|
| 325 | + */ |
|
| 326 | 326 | public static function output2( $post ) { |
| 327 | 327 | |
| 328 | 328 | // Prepare the invoice. |
@@ -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 | |
@@ -16,67 +16,67 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
| 18 | 18 | |
| 19 | - public static function get_columns( $invoice ) { |
|
| 19 | + public static function get_columns($invoice) { |
|
| 20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
| 21 | 21 | $columns = array( |
| 22 | - 'id' => __( 'ID', 'invoicing' ), |
|
| 23 | - 'title' => __( 'Item', 'invoicing' ), |
|
| 24 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 25 | - 'qty' => __( 'Qty', 'invoicing' ), |
|
| 26 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 27 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
| 22 | + 'id' => __('ID', 'invoicing'), |
|
| 23 | + 'title' => __('Item', 'invoicing'), |
|
| 24 | + 'price' => __('Price', 'invoicing'), |
|
| 25 | + 'qty' => __('Qty', 'invoicing'), |
|
| 26 | + 'total' => __('Total', 'invoicing'), |
|
| 27 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
| 28 | 28 | 'action' => '', |
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | - if ( ! $use_taxes ) { |
|
| 32 | - unset( $columns['tax'] ); |
|
| 31 | + if (!$use_taxes) { |
|
| 32 | + unset($columns['tax']); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return $columns; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public static function output( $post, $invoice = false ) { |
|
| 38 | + public static function output($post, $invoice = false) { |
|
| 39 | 39 | |
| 40 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 41 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
| 40 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 41 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
| 42 | 42 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
| 43 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
| 44 | - $columns = self::get_columns( $invoice ); |
|
| 45 | - $cols = count( $columns ); |
|
| 43 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
| 44 | + $columns = self::get_columns($invoice); |
|
| 45 | + $cols = count($columns); |
|
| 46 | 46 | $class = ''; |
| 47 | 47 | |
| 48 | - unset( $item_types['adv'] ); |
|
| 49 | - unset( $item_types['package'] ); |
|
| 48 | + unset($item_types['adv']); |
|
| 49 | + unset($item_types['package']); |
|
| 50 | 50 | |
| 51 | - if ( $invoice->is_paid() ) { |
|
| 51 | + if ($invoice->is_paid()) { |
|
| 52 | 52 | $class .= ' wpinv-paid'; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( $invoice->is_refunded() ) { |
|
| 55 | + if ($invoice->is_refunded()) { |
|
| 56 | 56 | $class .= ' wpinv-refunded'; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ( $invoice->is_recurring() ) { |
|
| 59 | + if ($invoice->is_recurring()) { |
|
| 60 | 60 | $class .= ' wpi-recurring'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | ?> |
| 64 | 64 | |
| 65 | - <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
| 65 | + <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
| 66 | 66 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
| 67 | 67 | |
| 68 | 68 | <thead> |
| 69 | 69 | <tr> |
| 70 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 71 | - <th class="<?php echo esc_attr( $key ); ?>"><?php echo sanitize_text_field( $label ); ?></th> |
|
| 70 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 71 | + <th class="<?php echo esc_attr($key); ?>"><?php echo sanitize_text_field($label); ?></th> |
|
| 72 | 72 | <?php endforeach; ?> |
| 73 | 73 | </tr> |
| 74 | 74 | </thead> |
| 75 | 75 | |
| 76 | 76 | <tbody class="wpinv-line-items"> |
| 77 | 77 | <?php |
| 78 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
| 79 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
| 78 | + foreach ($invoice->get_items() as $int => $item) { |
|
| 79 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
| 80 | 80 | } |
| 81 | 81 | ?> |
| 82 | 82 | </tbody> |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | <div class="wp-clearfix"> |
| 94 | 94 | <label class="wpi-item-name"> |
| 95 | 95 | <span class="input-text-wrap"> |
| 96 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
| 96 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
| 97 | 97 | </span> |
| 98 | 98 | </label> |
| 99 | 99 | </div> |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | <div class="wp-clearfix"> |
| 102 | 102 | <label class="wpi-item-price"> |
| 103 | 103 | <span class="input-text-wrap"> |
| 104 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
| 105 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
| 104 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
| 105 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
| 106 | 106 | </span> |
| 107 | 107 | </label> |
| 108 | 108 | </div> |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | <div class="wp-clearfix"> |
| 111 | 111 | <label class="wpi-item-name"> |
| 112 | 112 | <span class="input-text-wrap"> |
| 113 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
| 113 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
| 114 | 114 | </span> |
| 115 | 115 | </label> |
| 116 | 116 | </div> |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | <div class="wp-clearfix"> |
| 119 | 119 | <label class="wpi-item-type"> |
| 120 | 120 | <span class="input-text-wrap"> |
| 121 | - <?php echo wpinv_html_select( array( |
|
| 121 | + <?php echo wpinv_html_select(array( |
|
| 122 | 122 | 'options' => $item_types, |
| 123 | 123 | 'name' => '_wpinv_quick[type]', |
| 124 | 124 | 'id' => '_wpinv_quick_type', |
@@ -126,19 +126,19 @@ discard block |
||
| 126 | 126 | 'show_option_all' => false, |
| 127 | 127 | 'show_option_none' => false, |
| 128 | 128 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
| 129 | - ) ); ?> |
|
| 129 | + )); ?> |
|
| 130 | 130 | </span> |
| 131 | 131 | </label> |
| 132 | 132 | </div> |
| 133 | 133 | |
| 134 | - <?php if ( $use_taxes ) : ?> |
|
| 134 | + <?php if ($use_taxes) : ?> |
|
| 135 | 135 | <div class="wp-clearfix"> |
| 136 | 136 | <label class="wpi-vat-rule"> |
| 137 | 137 | <span class="input-text-wrap"> |
| 138 | 138 | <?php |
| 139 | - echo wpinv_html_select( array( |
|
| 139 | + echo wpinv_html_select(array( |
|
| 140 | 140 | 'options' => array_merge( |
| 141 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
| 141 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
| 142 | 142 | getpaid_get_tax_rules() |
| 143 | 143 | ), |
| 144 | 144 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'show_option_all' => false, |
| 147 | 147 | 'show_option_none' => false, |
| 148 | 148 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
| 149 | - ) ); |
|
| 149 | + )); |
|
| 150 | 150 | ?> |
| 151 | 151 | </span> |
| 152 | 152 | </label> |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | <label class="wpi-vat-class"> |
| 156 | 156 | <span class="input-text-wrap"> |
| 157 | 157 | <?php |
| 158 | - echo wpinv_html_select( array( |
|
| 158 | + echo wpinv_html_select(array( |
|
| 159 | 159 | 'options' => array_merge( |
| 160 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
| 160 | + array('' => __('Select VAT Class', 'invoicing')), |
|
| 161 | 161 | getpaid_get_tax_classes() |
| 162 | 162 | ), |
| 163 | 163 | 'name' => '_wpinv_quick[vat_class]', |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | 'show_option_all' => false, |
| 166 | 166 | 'show_option_none' => false, |
| 167 | 167 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
| 168 | - ) ); |
|
| 168 | + )); |
|
| 169 | 169 | ?> |
| 170 | 170 | </span> |
| 171 | 171 | </label> |
@@ -186,29 +186,29 @@ discard block |
||
| 186 | 186 | </td> |
| 187 | 187 | </tr> |
| 188 | 188 | <tr class="totals"> |
| 189 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
| 189 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
| 190 | 190 | <td colspan="4"> |
| 191 | 191 | <table cellspacing="0" cellpadding="0"> |
| 192 | 192 | <tr class="subtotal"> |
| 193 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
| 194 | - <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
|
| 193 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
| 194 | + <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
| 195 | 195 | <td class="action"></td> |
| 196 | 196 | </tr> |
| 197 | 197 | <tr class="discount"> |
| 198 | - <td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td> |
|
| 199 | - <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
|
| 198 | + <td class="name"><?php _e('Discount:', 'invoicing'); ?></td> |
|
| 199 | + <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
| 200 | 200 | <td class="action"></td> |
| 201 | 201 | </tr> |
| 202 | - <?php if ( $use_taxes ) : ?> |
|
| 202 | + <?php if ($use_taxes) : ?> |
|
| 203 | 203 | <tr class="tax"> |
| 204 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
| 205 | - <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
|
| 204 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
| 205 | + <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
| 206 | 206 | <td class="action"></td> |
| 207 | 207 | </tr> |
| 208 | 208 | <?php endif; ?> |
| 209 | 209 | <tr class="total"> |
| 210 | - <td class="name"><?php _e( 'Total:', 'invoicing' );?></td> |
|
| 211 | - <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
|
| 210 | + <td class="name"><?php _e('Total:', 'invoicing'); ?></td> |
|
| 211 | + <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
| 212 | 212 | <td class="action"></td> |
| 213 | 213 | </tr> |
| 214 | 214 | </table> |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | </table> |
| 220 | 220 | <div class="wpinv-actions"> |
| 221 | 221 | <?php |
| 222 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 222 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 223 | 223 | echo wpinv_item_dropdown( |
| 224 | 224 | array( |
| 225 | 225 | 'name' => 'wpinv_invoice_item', |
@@ -229,61 +229,61 @@ discard block |
||
| 229 | 229 | ) |
| 230 | 230 | ); |
| 231 | 231 | |
| 232 | - echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>'; |
|
| 233 | - echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
| 234 | - echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
| 232 | + echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>'; |
|
| 233 | + echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
| 234 | + echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
| 235 | 235 | |
| 236 | 236 | } |
| 237 | 237 | ?> |
| 238 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
| 238 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
| 239 | 239 | </div> |
| 240 | 240 | </div> |
| 241 | 241 | <?php |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - public static function output_row( $columns, $item, $invoice, $class='even' ) { |
|
| 244 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
| 245 | 245 | |
| 246 | 246 | ?> |
| 247 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
| 248 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
| 249 | - <td class="<?php echo esc_attr( $column ); ?>"> |
|
| 247 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
| 248 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
| 249 | + <td class="<?php echo esc_attr($column); ?>"> |
|
| 250 | 250 | <?php |
| 251 | - switch ( $column ) { |
|
| 251 | + switch ($column) { |
|
| 252 | 252 | case 'id': |
| 253 | 253 | echo (int) $item->get_id(); |
| 254 | 254 | break; |
| 255 | 255 | case 'title': |
| 256 | 256 | printf( |
| 257 | 257 | '<a href="%s" target="_blank">%s</a>', |
| 258 | - get_edit_post_link( $item->get_id() ), |
|
| 259 | - esc_html( $item->get_raw_name() ) |
|
| 258 | + get_edit_post_link($item->get_id()), |
|
| 259 | + esc_html($item->get_raw_name()) |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
| 263 | - if ( $summary !== '' ) { |
|
| 262 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
| 263 | + if ($summary !== '') { |
|
| 264 | 264 | printf( |
| 265 | 265 | '<span class="meta">%s</span>', |
| 266 | - wpautop( wp_kses_post( $summary ) ) |
|
| 266 | + wpautop(wp_kses_post($summary)) |
|
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | printf( |
| 271 | 271 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
| 272 | - esc_attr( $item->get_raw_name() ), |
|
| 272 | + esc_attr($item->get_raw_name()), |
|
| 273 | 273 | (int) $item->get_id() |
| 274 | 274 | ); |
| 275 | 275 | |
| 276 | 276 | printf( |
| 277 | 277 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
| 278 | 278 | (int) $item->get_id(), |
| 279 | - esc_attr( $item->get_description() ) |
|
| 279 | + esc_attr($item->get_description()) |
|
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | 282 | break; |
| 283 | 283 | case 'price': |
| 284 | 284 | printf( |
| 285 | 285 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
| 286 | - esc_attr( $item->get_price() ), |
|
| 286 | + esc_attr($item->get_price()), |
|
| 287 | 287 | (int) $item->get_id() |
| 288 | 288 | ); |
| 289 | 289 | |
@@ -291,26 +291,26 @@ discard block |
||
| 291 | 291 | case 'qty': |
| 292 | 292 | printf( |
| 293 | 293 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
| 294 | - floatval( $item->get_quantity() ), |
|
| 294 | + floatval($item->get_quantity()), |
|
| 295 | 295 | (int) $item->get_id() |
| 296 | 296 | ); |
| 297 | 297 | |
| 298 | 298 | break; |
| 299 | 299 | case 'total': |
| 300 | - echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
| 300 | + echo wpinv_price($item->get_sub_total(), $invoice->get_currency()); |
|
| 301 | 301 | |
| 302 | 302 | break; |
| 303 | 303 | case 'tax': |
| 304 | - echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
| 304 | + echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
| 305 | 305 | |
| 306 | 306 | break; |
| 307 | 307 | case 'action': |
| 308 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 308 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 309 | 309 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
| 310 | 310 | } |
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
| 313 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
| 314 | 314 | ?> |
| 315 | 315 | </td> |
| 316 | 316 | <?php endforeach; ?> |
@@ -323,10 +323,10 @@ discard block |
||
| 323 | 323 | * |
| 324 | 324 | * @param WP_Post $post |
| 325 | 325 | */ |
| 326 | - public static function output2( $post ) { |
|
| 326 | + public static function output2($post) { |
|
| 327 | 327 | |
| 328 | 328 | // Prepare the invoice. |
| 329 | - $invoice = new WPInv_Invoice( $post ); |
|
| 329 | + $invoice = new WPInv_Invoice($post); |
|
| 330 | 330 | |
| 331 | 331 | // Invoice items. |
| 332 | 332 | $items = $invoice->get_items(); |
@@ -334,28 +334,28 @@ discard block |
||
| 334 | 334 | $totals = array( |
| 335 | 335 | |
| 336 | 336 | 'subtotal' => array( |
| 337 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
| 338 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
| 337 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
| 338 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
| 339 | 339 | ), |
| 340 | 340 | |
| 341 | 341 | 'discount' => array( |
| 342 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
| 343 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
| 342 | + 'label' => __('Total Discount', 'invoicing'), |
|
| 343 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
| 344 | 344 | ), |
| 345 | 345 | |
| 346 | 346 | 'tax' => array( |
| 347 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
| 348 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
| 347 | + 'label' => __('Total Tax', 'invoicing'), |
|
| 348 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
| 349 | 349 | ), |
| 350 | 350 | |
| 351 | 351 | 'total' => array( |
| 352 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
| 353 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
| 352 | + 'label' => __('Invoice Total', 'invoicing'), |
|
| 353 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
| 354 | 354 | ) |
| 355 | 355 | ); |
| 356 | 356 | |
| 357 | - if ( ! wpinv_use_taxes() ) { |
|
| 358 | - unset( $totals['tax'] ); |
|
| 357 | + if (!wpinv_use_taxes()) { |
|
| 358 | + unset($totals['tax']); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | $item_args = array( |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | 'orderby' => 'title', |
| 364 | 364 | 'order' => 'ASC', |
| 365 | 365 | 'posts_per_page' => -1, |
| 366 | - 'post_status' => array( 'publish' ), |
|
| 366 | + 'post_status' => array('publish'), |
|
| 367 | 367 | 'meta_query' => array( |
| 368 | 368 | array( |
| 369 | 369 | 'key' => '_wpinv_type', |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | } |
| 388 | 388 | </style> |
| 389 | 389 | |
| 390 | - <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class( $invoice->get_template( 'edit' ) ); ?> <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem"> |
|
| 390 | + <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class($invoice->get_template('edit')); ?> <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem"> |
|
| 391 | 391 | |
| 392 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
| 393 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
| 392 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
| 393 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
| 394 | 394 | |
| 395 | 395 | <div class="row"> |
| 396 | 396 | <div class="col-12 col-sm-6"> |
@@ -399,15 +399,15 @@ discard block |
||
| 399 | 399 | array( |
| 400 | 400 | 'id' => 'wpinv_template', |
| 401 | 401 | 'name' => 'wpinv_template', |
| 402 | - 'label' => __( 'Template', 'invoicing' ), |
|
| 402 | + 'label' => __('Template', 'invoicing'), |
|
| 403 | 403 | 'label_type' => 'vertical', |
| 404 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
| 404 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
| 405 | 405 | 'class' => 'form-control-sm', |
| 406 | - 'value' => $invoice->get_template( 'edit' ), |
|
| 406 | + 'value' => $invoice->get_template('edit'), |
|
| 407 | 407 | 'options' => array( |
| 408 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 409 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
| 410 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
| 408 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 409 | + 'hours' => __('Hours', 'invoicing'), |
|
| 410 | + 'amount' => __('Amount Only', 'invoicing'), |
|
| 411 | 411 | ), |
| 412 | 412 | 'data-allow-clear' => 'false', |
| 413 | 413 | 'select2' => true, |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | array( |
| 424 | 424 | 'id' => 'wpinv_currency', |
| 425 | 425 | 'name' => 'wpinv_currency', |
| 426 | - 'label' => __( 'Currency', 'invoicing' ), |
|
| 426 | + 'label' => __('Currency', 'invoicing'), |
|
| 427 | 427 | 'label_type' => 'vertical', |
| 428 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
| 428 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
| 429 | 429 | 'class' => 'form-control-sm', |
| 430 | - 'value' => $invoice->get_currency( 'edit' ), |
|
| 430 | + 'value' => $invoice->get_currency('edit'), |
|
| 431 | 431 | 'required' => false, |
| 432 | 432 | 'data-allow-clear' => 'false', |
| 433 | 433 | 'select2' => true, |
@@ -439,24 +439,24 @@ discard block |
||
| 439 | 439 | </div> |
| 440 | 440 | </div> |
| 441 | 441 | |
| 442 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
| 442 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
| 443 | 443 | <?php endif; ?> |
| 444 | 444 | |
| 445 | 445 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
| 446 | 446 | <thead> |
| 447 | 447 | <tr> |
| 448 | - <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th> |
|
| 448 | + <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th> |
|
| 449 | 449 | <th class="getpaid-quantity hide-if-amount text-right"> |
| 450 | - <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
|
| 451 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
|
| 450 | + <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span> |
|
| 451 | + <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span> |
|
| 452 | 452 | </th> |
| 453 | 453 | <th class="getpaid-price hide-if-amount text-right"> |
| 454 | - <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span> |
|
| 455 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span> |
|
| 454 | + <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span> |
|
| 455 | + <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span> |
|
| 456 | 456 | </th> |
| 457 | 457 | <th class="getpaid-item-subtotal text-right"> |
| 458 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span> |
|
| 459 | - <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span> |
|
| 458 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span> |
|
| 459 | + <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span> |
|
| 460 | 460 | </th> |
| 461 | 461 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
| 462 | 462 | </tr> |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | <tbody class="getpaid_invoice_line_items"> |
| 465 | 465 | <tr class="hide-if-has-items hide-if-not-editable"> |
| 466 | 466 | <td colspan="2" class="pt-4 pb-4"> |
| 467 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
| 468 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button> |
|
| 467 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button> |
|
| 468 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button> |
|
| 469 | 469 | </td> |
| 470 | 470 | <td class="hide-if-amount"> </th> |
| 471 | 471 | <td class="hide-if-amount"> </th> |
@@ -497,11 +497,11 @@ discard block |
||
| 497 | 497 | <div class="col-12 col-sm-6 offset-sm-6"> |
| 498 | 498 | <table class="getpaid-invoice-totals text-right w-100"> |
| 499 | 499 | <tbody> |
| 500 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
| 501 | - <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 502 | - <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td> |
|
| 500 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
| 501 | + <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>"> |
|
| 502 | + <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td> |
|
| 503 | 503 | <td width="1%"></td> |
| 504 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
| 504 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
| 505 | 505 | </tr> |
| 506 | 506 | <?php endforeach; ?> |
| 507 | 507 | </tbody> |
@@ -514,18 +514,18 @@ discard block |
||
| 514 | 514 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
| 515 | 515 | <div class="row"> |
| 516 | 516 | <div class="text-left col-12 col-sm-8"> |
| 517 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
| 518 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button> |
|
| 519 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
| 517 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button> |
|
| 518 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button> |
|
| 519 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
| 520 | 520 | </div> |
| 521 | 521 | <div class="text-right col-12 col-sm-4"> |
| 522 | - <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
| 522 | + <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button> |
|
| 523 | 523 | </div> |
| 524 | 524 | </div> |
| 525 | 525 | </div> |
| 526 | 526 | |
| 527 | 527 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
| 528 | - <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
| 528 | + <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
| 529 | 529 | </div> |
| 530 | 530 | |
| 531 | 531 | <!-- Add items to an invoice --> |
@@ -533,8 +533,8 @@ discard block |
||
| 533 | 533 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 534 | 534 | <div class="modal-content"> |
| 535 | 535 | <div class="modal-header"> |
| 536 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
| 537 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
| 536 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5> |
|
| 537 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
| 538 | 538 | <span aria-hidden="true">×</span> |
| 539 | 539 | </button> |
| 540 | 540 | </div> |
@@ -542,10 +542,10 @@ discard block |
||
| 542 | 542 | <table class="widefat"> |
| 543 | 543 | <thead> |
| 544 | 544 | <tr> |
| 545 | - <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th> |
|
| 545 | + <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th> |
|
| 546 | 546 | <th class="pr-0 text-right hide-if-amount"> |
| 547 | - <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
|
| 548 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
|
| 547 | + <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span> |
|
| 548 | + <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span> |
|
| 549 | 549 | </th> |
| 550 | 550 | </tr> |
| 551 | 551 | </thead> |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | <tr> |
| 554 | 554 | <td class="pl-0 text-left"> |
| 555 | 555 | <select class="regular-text getpaid-add-invoice-item-select"> |
| 556 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
| 557 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
| 558 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option> |
|
| 556 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
| 557 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
| 558 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option> |
|
| 559 | 559 | <?php endforeach; ?> |
| 560 | 560 | </select> |
| 561 | 561 | </td> |
@@ -567,8 +567,8 @@ discard block |
||
| 567 | 567 | </table> |
| 568 | 568 | </div> |
| 569 | 569 | <div class="modal-footer"> |
| 570 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
| 571 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button> |
|
| 570 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
| 571 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button> |
|
| 572 | 572 | </div> |
| 573 | 573 | </div> |
| 574 | 574 | </div> |
@@ -579,8 +579,8 @@ discard block |
||
| 579 | 579 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 580 | 580 | <div class="modal-content"> |
| 581 | 581 | <div class="modal-header"> |
| 582 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5> |
|
| 583 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
| 582 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e("Create Item", 'invoicing'); ?></h5> |
|
| 583 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
| 584 | 584 | <span aria-hidden="true">×</span> |
| 585 | 585 | </button> |
| 586 | 586 | </div> |
@@ -588,27 +588,27 @@ discard block |
||
| 588 | 588 | <div class="getpaid-create-item-div"> |
| 589 | 589 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
| 590 | 590 | <label class="form-group w-100"> |
| 591 | - <span><?php _e( 'Name', 'invoicing' ); ?></span> |
|
| 592 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
| 591 | + <span><?php _e('Name', 'invoicing'); ?></span> |
|
| 592 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
| 593 | 593 | </label> |
| 594 | 594 | <label class="form-group w-100"> |
| 595 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
|
| 596 | - <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
|
| 597 | - <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
| 595 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span> |
|
| 596 | + <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span> |
|
| 597 | + <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
| 598 | 598 | </label> |
| 599 | 599 | <label class="form-group w-100 hide-if-amount"> |
| 600 | - <span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
|
| 600 | + <span><?php _e('Quantity', 'invoicing'); ?></span> |
|
| 601 | 601 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
| 602 | 602 | </label> |
| 603 | 603 | <label class="form-group w-100"> |
| 604 | - <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
|
| 605 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
| 604 | + <span><?php _e('Item Description', 'invoicing'); ?></span> |
|
| 605 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
| 606 | 606 | </label> |
| 607 | 607 | </div> |
| 608 | 608 | </div> |
| 609 | 609 | <div class="modal-footer"> |
| 610 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
| 611 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button> |
|
| 610 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
| 611 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Create', 'invoicing'); ?></button> |
|
| 612 | 612 | </div> |
| 613 | 613 | </div> |
| 614 | 614 | </div> |
@@ -619,8 +619,8 @@ discard block |
||
| 619 | 619 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 620 | 620 | <div class="modal-content"> |
| 621 | 621 | <div class="modal-header"> |
| 622 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5> |
|
| 623 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
| 622 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5> |
|
| 623 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
| 624 | 624 | <span aria-hidden="true">×</span> |
| 625 | 625 | </button> |
| 626 | 626 | </div> |
@@ -628,27 +628,27 @@ discard block |
||
| 628 | 628 | <div class="getpaid-edit-item-div"> |
| 629 | 629 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
| 630 | 630 | <label class="form-group w-100"> |
| 631 | - <span><?php _e( 'Name', 'invoicing' ); ?></span> |
|
| 632 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
| 631 | + <span><?php _e('Name', 'invoicing'); ?></span> |
|
| 632 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
| 633 | 633 | </label> |
| 634 | 634 | <label class="form-group w-100"> |
| 635 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
|
| 636 | - <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
|
| 637 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
| 635 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span> |
|
| 636 | + <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span> |
|
| 637 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
| 638 | 638 | </label> |
| 639 | 639 | <label class="form-group w-100 hide-if-amount"> |
| 640 | - <span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
|
| 640 | + <span><?php _e('Quantity', 'invoicing'); ?></span> |
|
| 641 | 641 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
| 642 | 642 | </label> |
| 643 | 643 | <label class="form-group w-100"> |
| 644 | - <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
|
| 645 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
| 644 | + <span><?php _e('Item Description', 'invoicing'); ?></span> |
|
| 645 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
| 646 | 646 | </label> |
| 647 | 647 | </div> |
| 648 | 648 | </div> |
| 649 | 649 | <div class="modal-footer"> |
| 650 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
| 651 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button> |
|
| 650 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
| 651 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button> |
|
| 652 | 652 | </div> |
| 653 | 653 | </div> |
| 654 | 654 | </div> |