@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | - exit; |
|
| 8 | + exit; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -15,542 +15,542 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class GetPaid_Invoice_Data_Store extends GetPaid_Data_Store_WP { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Data stored in meta keys, but not considered "meta" for a discount. |
|
| 20 | - * |
|
| 21 | - * @since 1.0.19 |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $internal_meta_keys = array( |
|
| 25 | - '_wpinv_subscr_profile_id', |
|
| 26 | - '_wpinv_subscription_id', |
|
| 27 | - '_wpinv_taxes', |
|
| 28 | - '_wpinv_fees', |
|
| 29 | - '_wpinv_discounts', |
|
| 30 | - '_wpinv_submission_id', |
|
| 31 | - '_wpinv_payment_form', |
|
| 32 | - '_wpinv_is_viewed', |
|
| 33 | - '_wpinv_phone', |
|
| 34 | - '_wpinv_company_id', |
|
| 35 | - 'wpinv_email_cc', |
|
| 36 | - 'wpinv_template', |
|
| 37 | - 'wpinv_created_via' |
|
| 38 | - ); |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A map of meta keys to data props. |
|
| 42 | - * |
|
| 43 | - * @since 1.0.19 |
|
| 44 | - * |
|
| 45 | - * @var array |
|
| 46 | - */ |
|
| 47 | - protected $meta_key_to_props = array( |
|
| 48 | - '_wpinv_subscr_profile_id' => 'remote_subscription_id', |
|
| 49 | - '_wpinv_subscription_id' => 'subscription_id', |
|
| 50 | - '_wpinv_taxes' => 'taxes', |
|
| 51 | - '_wpinv_fees' => 'fees', |
|
| 52 | - '_wpinv_discounts' => 'discounts', |
|
| 53 | - '_wpinv_submission_id' => 'submission_id', |
|
| 54 | - '_wpinv_payment_form' => 'payment_form', |
|
| 55 | - '_wpinv_is_viewed' => 'is_viewed', |
|
| 56 | - 'wpinv_email_cc' => 'email_cc', |
|
| 57 | - 'wpinv_template' => 'template', |
|
| 58 | - 'wpinv_created_via' => 'created_via', |
|
| 59 | - '_wpinv_phone' => 'phone', |
|
| 60 | - '_wpinv_company_id' => 'company_id', |
|
| 61 | - ); |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * A map of database fields to data props. |
|
| 65 | - * |
|
| 66 | - * @since 1.0.19 |
|
| 67 | - * |
|
| 68 | - * @var array |
|
| 69 | - */ |
|
| 70 | - protected $database_fields_to_props = array( |
|
| 71 | - 'post_id' => 'id', |
|
| 72 | - 'number' => 'number', |
|
| 73 | - 'currency' => 'currency', |
|
| 74 | - 'key' => 'key', |
|
| 75 | - 'type' => 'type', |
|
| 76 | - 'mode' => 'mode', |
|
| 77 | - 'user_ip' => 'user_ip', |
|
| 78 | - 'first_name' => 'first_name', |
|
| 79 | - 'last_name' => 'last_name', |
|
| 80 | - 'address' => 'address', |
|
| 81 | - 'city' => 'city', |
|
| 82 | - 'state' => 'state', |
|
| 83 | - 'country' => 'country', |
|
| 84 | - 'zip' => 'zip', |
|
| 85 | - 'zip' => 'zip', |
|
| 86 | - 'adddress_confirmed' => 'address_confirmed', |
|
| 87 | - 'gateway' => 'gateway', |
|
| 88 | - 'transaction_id' => 'transaction_id', |
|
| 89 | - 'currency' => 'currency', |
|
| 90 | - 'subtotal' => 'subtotal', |
|
| 91 | - 'tax' => 'total_tax', |
|
| 92 | - 'fees_total' => 'total_fees', |
|
| 93 | - 'discount' => 'total_discount', |
|
| 94 | - 'total' => 'total', |
|
| 95 | - 'discount_code' => 'discount_code', |
|
| 96 | - 'disable_taxes' => 'disable_taxes', |
|
| 97 | - 'due_date' => 'due_date', |
|
| 98 | - 'completed_date' => 'completed_date', |
|
| 99 | - 'company' => 'company', |
|
| 100 | - 'vat_number' => 'vat_number', |
|
| 101 | - 'vat_rate' => 'vat_rate', |
|
| 102 | - ); |
|
| 103 | - |
|
| 104 | - /* |
|
| 18 | + /** |
|
| 19 | + * Data stored in meta keys, but not considered "meta" for a discount. |
|
| 20 | + * |
|
| 21 | + * @since 1.0.19 |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $internal_meta_keys = array( |
|
| 25 | + '_wpinv_subscr_profile_id', |
|
| 26 | + '_wpinv_subscription_id', |
|
| 27 | + '_wpinv_taxes', |
|
| 28 | + '_wpinv_fees', |
|
| 29 | + '_wpinv_discounts', |
|
| 30 | + '_wpinv_submission_id', |
|
| 31 | + '_wpinv_payment_form', |
|
| 32 | + '_wpinv_is_viewed', |
|
| 33 | + '_wpinv_phone', |
|
| 34 | + '_wpinv_company_id', |
|
| 35 | + 'wpinv_email_cc', |
|
| 36 | + 'wpinv_template', |
|
| 37 | + 'wpinv_created_via' |
|
| 38 | + ); |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A map of meta keys to data props. |
|
| 42 | + * |
|
| 43 | + * @since 1.0.19 |
|
| 44 | + * |
|
| 45 | + * @var array |
|
| 46 | + */ |
|
| 47 | + protected $meta_key_to_props = array( |
|
| 48 | + '_wpinv_subscr_profile_id' => 'remote_subscription_id', |
|
| 49 | + '_wpinv_subscription_id' => 'subscription_id', |
|
| 50 | + '_wpinv_taxes' => 'taxes', |
|
| 51 | + '_wpinv_fees' => 'fees', |
|
| 52 | + '_wpinv_discounts' => 'discounts', |
|
| 53 | + '_wpinv_submission_id' => 'submission_id', |
|
| 54 | + '_wpinv_payment_form' => 'payment_form', |
|
| 55 | + '_wpinv_is_viewed' => 'is_viewed', |
|
| 56 | + 'wpinv_email_cc' => 'email_cc', |
|
| 57 | + 'wpinv_template' => 'template', |
|
| 58 | + 'wpinv_created_via' => 'created_via', |
|
| 59 | + '_wpinv_phone' => 'phone', |
|
| 60 | + '_wpinv_company_id' => 'company_id', |
|
| 61 | + ); |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * A map of database fields to data props. |
|
| 65 | + * |
|
| 66 | + * @since 1.0.19 |
|
| 67 | + * |
|
| 68 | + * @var array |
|
| 69 | + */ |
|
| 70 | + protected $database_fields_to_props = array( |
|
| 71 | + 'post_id' => 'id', |
|
| 72 | + 'number' => 'number', |
|
| 73 | + 'currency' => 'currency', |
|
| 74 | + 'key' => 'key', |
|
| 75 | + 'type' => 'type', |
|
| 76 | + 'mode' => 'mode', |
|
| 77 | + 'user_ip' => 'user_ip', |
|
| 78 | + 'first_name' => 'first_name', |
|
| 79 | + 'last_name' => 'last_name', |
|
| 80 | + 'address' => 'address', |
|
| 81 | + 'city' => 'city', |
|
| 82 | + 'state' => 'state', |
|
| 83 | + 'country' => 'country', |
|
| 84 | + 'zip' => 'zip', |
|
| 85 | + 'zip' => 'zip', |
|
| 86 | + 'adddress_confirmed' => 'address_confirmed', |
|
| 87 | + 'gateway' => 'gateway', |
|
| 88 | + 'transaction_id' => 'transaction_id', |
|
| 89 | + 'currency' => 'currency', |
|
| 90 | + 'subtotal' => 'subtotal', |
|
| 91 | + 'tax' => 'total_tax', |
|
| 92 | + 'fees_total' => 'total_fees', |
|
| 93 | + 'discount' => 'total_discount', |
|
| 94 | + 'total' => 'total', |
|
| 95 | + 'discount_code' => 'discount_code', |
|
| 96 | + 'disable_taxes' => 'disable_taxes', |
|
| 97 | + 'due_date' => 'due_date', |
|
| 98 | + 'completed_date' => 'completed_date', |
|
| 99 | + 'company' => 'company', |
|
| 100 | + 'vat_number' => 'vat_number', |
|
| 101 | + 'vat_rate' => 'vat_rate', |
|
| 102 | + ); |
|
| 103 | + |
|
| 104 | + /* |
|
| 105 | 105 | |-------------------------------------------------------------------------- |
| 106 | 106 | | CRUD Methods |
| 107 | 107 | |-------------------------------------------------------------------------- |
| 108 | 108 | */ |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Method to create a new invoice in the database. |
|
| 112 | - * |
|
| 113 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 114 | - */ |
|
| 115 | - public function create( &$invoice ) { |
|
| 116 | - $invoice->set_version( WPINV_VERSION ); |
|
| 117 | - $invoice->set_date_created( current_time('mysql') ); |
|
| 118 | - |
|
| 119 | - // Create a new post. |
|
| 120 | - $id = wp_insert_post( |
|
| 121 | - apply_filters( |
|
| 122 | - 'getpaid_new_invoice_data', |
|
| 123 | - array( |
|
| 124 | - 'post_date' => $invoice->get_date_created( 'edit' ), |
|
| 125 | - 'post_type' => $invoice->get_post_type( 'edit' ), |
|
| 126 | - 'post_status' => $this->get_post_status( $invoice ), |
|
| 127 | - 'ping_status' => 'closed', |
|
| 128 | - 'post_author' => $invoice->get_user_id( 'edit' ), |
|
| 129 | - 'post_title' => $invoice->get_title( 'edit' ), |
|
| 130 | - 'post_excerpt' => $invoice->get_description( 'edit' ), |
|
| 131 | - 'post_parent' => $invoice->get_parent_id( 'edit' ), |
|
| 132 | - ) |
|
| 133 | - ), |
|
| 134 | - true |
|
| 135 | - ); |
|
| 136 | - |
|
| 137 | - if ( $id && ! is_wp_error( $id ) ) { |
|
| 138 | - |
|
| 139 | - // Update the new id and regenerate a title. |
|
| 140 | - $invoice->set_id( $id ); |
|
| 141 | - |
|
| 142 | - $invoice->maybe_set_number(); |
|
| 143 | - |
|
| 144 | - wp_update_post( |
|
| 145 | - array( |
|
| 146 | - 'ID' => $invoice->get_id(), |
|
| 147 | - 'post_title' => $invoice->get_number( 'edit' ), |
|
| 148 | - 'post_name' => $invoice->get_path( 'edit' ) |
|
| 149 | - ) |
|
| 150 | - ); |
|
| 151 | - |
|
| 152 | - // Save special fields and items. |
|
| 153 | - $this->save_special_fields( $invoice ); |
|
| 154 | - $this->save_items( $invoice ); |
|
| 155 | - |
|
| 156 | - // Update meta data. |
|
| 157 | - $this->update_post_meta( $invoice ); |
|
| 158 | - $invoice->save_meta_data(); |
|
| 159 | - |
|
| 160 | - // Apply changes. |
|
| 161 | - $invoice->apply_changes(); |
|
| 162 | - $this->clear_caches( $invoice ); |
|
| 163 | - |
|
| 164 | - // Fires after a new invoice is created. |
|
| 165 | - do_action( 'getpaid_new_invoice', $invoice ); |
|
| 166 | - return true; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - if ( is_wp_error( $id ) ) { |
|
| 170 | - $invoice->last_error = $id->get_error_message(); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return false; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Method to read an invoice from the database. |
|
| 178 | - * |
|
| 179 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | - * |
|
| 181 | - */ |
|
| 182 | - public function read( &$invoice ) { |
|
| 183 | - |
|
| 184 | - $invoice->set_defaults(); |
|
| 185 | - $invoice_object = get_post( $invoice->get_id() ); |
|
| 186 | - |
|
| 187 | - if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) { |
|
| 188 | - $invoice->last_error = __( 'Invalid invoice.', 'invoicing' ); |
|
| 189 | - $invoice->set_id( 0 ); |
|
| 190 | - return false; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - $invoice->set_props( |
|
| 194 | - array( |
|
| 195 | - 'date_created' => 0 < $invoice_object->post_date ? $invoice_object->post_date : null, |
|
| 196 | - 'date_modified' => 0 < $invoice_object->post_modified ? $invoice_object->post_modified : null, |
|
| 197 | - 'status' => $invoice_object->post_status, |
|
| 198 | - 'author' => $invoice_object->post_author, |
|
| 199 | - 'description' => $invoice_object->post_excerpt, |
|
| 200 | - 'parent_id' => $invoice_object->post_parent, |
|
| 201 | - 'name' => $invoice_object->post_title, |
|
| 202 | - 'path' => $invoice_object->post_name, |
|
| 203 | - 'post_type' => $invoice_object->post_type, |
|
| 204 | - ) |
|
| 205 | - ); |
|
| 206 | - |
|
| 207 | - $invoice->set_type( $invoice_object->post_type ); |
|
| 208 | - |
|
| 209 | - $this->read_object_data( $invoice, $invoice_object ); |
|
| 210 | - $this->add_special_fields( $invoice ); |
|
| 211 | - $this->add_items( $invoice ); |
|
| 212 | - $invoice->read_meta_data(); |
|
| 213 | - $invoice->set_object_read( true ); |
|
| 214 | - do_action( 'getpaid_read_invoice', $invoice ); |
|
| 215 | - |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Method to update an invoice in the database. |
|
| 220 | - * |
|
| 221 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 222 | - */ |
|
| 223 | - public function update( &$invoice ) { |
|
| 224 | - $invoice->save_meta_data(); |
|
| 225 | - $invoice->set_version( WPINV_VERSION ); |
|
| 226 | - |
|
| 227 | - if ( null === $invoice->get_date_created( 'edit' ) ) { |
|
| 228 | - $invoice->set_date_created( current_time('mysql') ); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - // Ensure both the key and number are set. |
|
| 232 | - $invoice->get_path(); |
|
| 233 | - |
|
| 234 | - // Grab the current status so we can compare. |
|
| 235 | - $previous_status = get_post_status( $invoice->get_id() ); |
|
| 236 | - |
|
| 237 | - $changes = $invoice->get_changes(); |
|
| 238 | - |
|
| 239 | - // Only update the post when the post data changes. |
|
| 240 | - if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) { |
|
| 241 | - $post_data = array( |
|
| 242 | - 'post_date' => $invoice->get_date_created( 'edit' ), |
|
| 243 | - 'post_date_gmt' => $invoice->get_date_created_gmt( 'edit' ), |
|
| 244 | - 'post_status' => $invoice->get_status( 'edit' ), |
|
| 245 | - 'post_title' => $invoice->get_name( 'edit' ), |
|
| 246 | - 'post_author' => $invoice->get_user_id( 'edit' ), |
|
| 247 | - 'post_modified' => $invoice->get_date_modified( 'edit' ), |
|
| 248 | - 'post_excerpt' => $invoice->get_description( 'edit' ), |
|
| 249 | - 'post_parent' => $invoice->get_parent_id( 'edit' ), |
|
| 250 | - 'post_name' => $invoice->get_path( 'edit' ), |
|
| 251 | - 'post_type' => $invoice->get_post_type( 'edit' ), |
|
| 252 | - ); |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * When updating this object, to prevent infinite loops, use $wpdb |
|
| 256 | - * to update data, since wp_update_post spawns more calls to the |
|
| 257 | - * save_post action. |
|
| 258 | - * |
|
| 259 | - * This ensures hooks are fired by either WP itself (admin screen save), |
|
| 260 | - * or an update purely from CRUD. |
|
| 261 | - */ |
|
| 262 | - if ( doing_action( 'save_post' ) ) { |
|
| 263 | - $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) ); |
|
| 264 | - clean_post_cache( $invoice->get_id() ); |
|
| 265 | - } else { |
|
| 266 | - wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) ); |
|
| 267 | - } |
|
| 268 | - $invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - // Update meta data. |
|
| 272 | - $this->update_post_meta( $invoice ); |
|
| 273 | - |
|
| 274 | - // Save special fields and items. |
|
| 275 | - $this->save_special_fields( $invoice ); |
|
| 276 | - $this->save_items( $invoice ); |
|
| 277 | - |
|
| 278 | - // Apply the changes. |
|
| 279 | - $invoice->apply_changes(); |
|
| 280 | - |
|
| 281 | - // Clear caches. |
|
| 282 | - $this->clear_caches( $invoice ); |
|
| 283 | - |
|
| 284 | - // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
|
| 285 | - $new_status = $invoice->get_status( 'edit' ); |
|
| 286 | - |
|
| 287 | - if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
| 288 | - do_action( 'getpaid_new_invoice', $invoice ); |
|
| 289 | - } else { |
|
| 290 | - do_action( 'getpaid_update_invoice', $invoice ); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /* |
|
| 110 | + /** |
|
| 111 | + * Method to create a new invoice in the database. |
|
| 112 | + * |
|
| 113 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 114 | + */ |
|
| 115 | + public function create( &$invoice ) { |
|
| 116 | + $invoice->set_version( WPINV_VERSION ); |
|
| 117 | + $invoice->set_date_created( current_time('mysql') ); |
|
| 118 | + |
|
| 119 | + // Create a new post. |
|
| 120 | + $id = wp_insert_post( |
|
| 121 | + apply_filters( |
|
| 122 | + 'getpaid_new_invoice_data', |
|
| 123 | + array( |
|
| 124 | + 'post_date' => $invoice->get_date_created( 'edit' ), |
|
| 125 | + 'post_type' => $invoice->get_post_type( 'edit' ), |
|
| 126 | + 'post_status' => $this->get_post_status( $invoice ), |
|
| 127 | + 'ping_status' => 'closed', |
|
| 128 | + 'post_author' => $invoice->get_user_id( 'edit' ), |
|
| 129 | + 'post_title' => $invoice->get_title( 'edit' ), |
|
| 130 | + 'post_excerpt' => $invoice->get_description( 'edit' ), |
|
| 131 | + 'post_parent' => $invoice->get_parent_id( 'edit' ), |
|
| 132 | + ) |
|
| 133 | + ), |
|
| 134 | + true |
|
| 135 | + ); |
|
| 136 | + |
|
| 137 | + if ( $id && ! is_wp_error( $id ) ) { |
|
| 138 | + |
|
| 139 | + // Update the new id and regenerate a title. |
|
| 140 | + $invoice->set_id( $id ); |
|
| 141 | + |
|
| 142 | + $invoice->maybe_set_number(); |
|
| 143 | + |
|
| 144 | + wp_update_post( |
|
| 145 | + array( |
|
| 146 | + 'ID' => $invoice->get_id(), |
|
| 147 | + 'post_title' => $invoice->get_number( 'edit' ), |
|
| 148 | + 'post_name' => $invoice->get_path( 'edit' ) |
|
| 149 | + ) |
|
| 150 | + ); |
|
| 151 | + |
|
| 152 | + // Save special fields and items. |
|
| 153 | + $this->save_special_fields( $invoice ); |
|
| 154 | + $this->save_items( $invoice ); |
|
| 155 | + |
|
| 156 | + // Update meta data. |
|
| 157 | + $this->update_post_meta( $invoice ); |
|
| 158 | + $invoice->save_meta_data(); |
|
| 159 | + |
|
| 160 | + // Apply changes. |
|
| 161 | + $invoice->apply_changes(); |
|
| 162 | + $this->clear_caches( $invoice ); |
|
| 163 | + |
|
| 164 | + // Fires after a new invoice is created. |
|
| 165 | + do_action( 'getpaid_new_invoice', $invoice ); |
|
| 166 | + return true; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + if ( is_wp_error( $id ) ) { |
|
| 170 | + $invoice->last_error = $id->get_error_message(); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return false; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Method to read an invoice from the database. |
|
| 178 | + * |
|
| 179 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | + * |
|
| 181 | + */ |
|
| 182 | + public function read( &$invoice ) { |
|
| 183 | + |
|
| 184 | + $invoice->set_defaults(); |
|
| 185 | + $invoice_object = get_post( $invoice->get_id() ); |
|
| 186 | + |
|
| 187 | + if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) { |
|
| 188 | + $invoice->last_error = __( 'Invalid invoice.', 'invoicing' ); |
|
| 189 | + $invoice->set_id( 0 ); |
|
| 190 | + return false; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + $invoice->set_props( |
|
| 194 | + array( |
|
| 195 | + 'date_created' => 0 < $invoice_object->post_date ? $invoice_object->post_date : null, |
|
| 196 | + 'date_modified' => 0 < $invoice_object->post_modified ? $invoice_object->post_modified : null, |
|
| 197 | + 'status' => $invoice_object->post_status, |
|
| 198 | + 'author' => $invoice_object->post_author, |
|
| 199 | + 'description' => $invoice_object->post_excerpt, |
|
| 200 | + 'parent_id' => $invoice_object->post_parent, |
|
| 201 | + 'name' => $invoice_object->post_title, |
|
| 202 | + 'path' => $invoice_object->post_name, |
|
| 203 | + 'post_type' => $invoice_object->post_type, |
|
| 204 | + ) |
|
| 205 | + ); |
|
| 206 | + |
|
| 207 | + $invoice->set_type( $invoice_object->post_type ); |
|
| 208 | + |
|
| 209 | + $this->read_object_data( $invoice, $invoice_object ); |
|
| 210 | + $this->add_special_fields( $invoice ); |
|
| 211 | + $this->add_items( $invoice ); |
|
| 212 | + $invoice->read_meta_data(); |
|
| 213 | + $invoice->set_object_read( true ); |
|
| 214 | + do_action( 'getpaid_read_invoice', $invoice ); |
|
| 215 | + |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Method to update an invoice in the database. |
|
| 220 | + * |
|
| 221 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 222 | + */ |
|
| 223 | + public function update( &$invoice ) { |
|
| 224 | + $invoice->save_meta_data(); |
|
| 225 | + $invoice->set_version( WPINV_VERSION ); |
|
| 226 | + |
|
| 227 | + if ( null === $invoice->get_date_created( 'edit' ) ) { |
|
| 228 | + $invoice->set_date_created( current_time('mysql') ); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + // Ensure both the key and number are set. |
|
| 232 | + $invoice->get_path(); |
|
| 233 | + |
|
| 234 | + // Grab the current status so we can compare. |
|
| 235 | + $previous_status = get_post_status( $invoice->get_id() ); |
|
| 236 | + |
|
| 237 | + $changes = $invoice->get_changes(); |
|
| 238 | + |
|
| 239 | + // Only update the post when the post data changes. |
|
| 240 | + if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) { |
|
| 241 | + $post_data = array( |
|
| 242 | + 'post_date' => $invoice->get_date_created( 'edit' ), |
|
| 243 | + 'post_date_gmt' => $invoice->get_date_created_gmt( 'edit' ), |
|
| 244 | + 'post_status' => $invoice->get_status( 'edit' ), |
|
| 245 | + 'post_title' => $invoice->get_name( 'edit' ), |
|
| 246 | + 'post_author' => $invoice->get_user_id( 'edit' ), |
|
| 247 | + 'post_modified' => $invoice->get_date_modified( 'edit' ), |
|
| 248 | + 'post_excerpt' => $invoice->get_description( 'edit' ), |
|
| 249 | + 'post_parent' => $invoice->get_parent_id( 'edit' ), |
|
| 250 | + 'post_name' => $invoice->get_path( 'edit' ), |
|
| 251 | + 'post_type' => $invoice->get_post_type( 'edit' ), |
|
| 252 | + ); |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * When updating this object, to prevent infinite loops, use $wpdb |
|
| 256 | + * to update data, since wp_update_post spawns more calls to the |
|
| 257 | + * save_post action. |
|
| 258 | + * |
|
| 259 | + * This ensures hooks are fired by either WP itself (admin screen save), |
|
| 260 | + * or an update purely from CRUD. |
|
| 261 | + */ |
|
| 262 | + if ( doing_action( 'save_post' ) ) { |
|
| 263 | + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) ); |
|
| 264 | + clean_post_cache( $invoice->get_id() ); |
|
| 265 | + } else { |
|
| 266 | + wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) ); |
|
| 267 | + } |
|
| 268 | + $invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + // Update meta data. |
|
| 272 | + $this->update_post_meta( $invoice ); |
|
| 273 | + |
|
| 274 | + // Save special fields and items. |
|
| 275 | + $this->save_special_fields( $invoice ); |
|
| 276 | + $this->save_items( $invoice ); |
|
| 277 | + |
|
| 278 | + // Apply the changes. |
|
| 279 | + $invoice->apply_changes(); |
|
| 280 | + |
|
| 281 | + // Clear caches. |
|
| 282 | + $this->clear_caches( $invoice ); |
|
| 283 | + |
|
| 284 | + // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
|
| 285 | + $new_status = $invoice->get_status( 'edit' ); |
|
| 286 | + |
|
| 287 | + if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
| 288 | + do_action( 'getpaid_new_invoice', $invoice ); |
|
| 289 | + } else { |
|
| 290 | + do_action( 'getpaid_update_invoice', $invoice ); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /* |
|
| 296 | 296 | |-------------------------------------------------------------------------- |
| 297 | 297 | | Additional Methods |
| 298 | 298 | |-------------------------------------------------------------------------- |
| 299 | 299 | */ |
| 300 | 300 | |
| 301 | - /** |
|
| 301 | + /** |
|
| 302 | 302 | * Retrieves special fields and adds to the invoice. |
| 303 | - * |
|
| 304 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 303 | + * |
|
| 304 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 305 | 305 | */ |
| 306 | 306 | public function add_special_fields( &$invoice ) { |
| 307 | - global $wpdb; |
|
| 307 | + global $wpdb; |
|
| 308 | 308 | |
| 309 | - // Maybe retrieve from the cache. |
|
| 310 | - $data = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
| 309 | + // Maybe retrieve from the cache. |
|
| 310 | + $data = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
| 311 | 311 | |
| 312 | - // If not found, retrieve from the db. |
|
| 313 | - if ( false === $data ) { |
|
| 314 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 312 | + // If not found, retrieve from the db. |
|
| 313 | + if ( false === $data ) { |
|
| 314 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 315 | 315 | |
| 316 | - $data = $wpdb->get_row( |
|
| 317 | - $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ), |
|
| 318 | - ARRAY_A |
|
| 319 | - ); |
|
| 316 | + $data = $wpdb->get_row( |
|
| 317 | + $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ), |
|
| 318 | + ARRAY_A |
|
| 319 | + ); |
|
| 320 | 320 | |
| 321 | - // Update the cache with our data |
|
| 322 | - wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' ); |
|
| 321 | + // Update the cache with our data |
|
| 322 | + wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' ); |
|
| 323 | 323 | |
| 324 | - } |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - // Abort if the data does not exist. |
|
| 327 | - if ( empty( $data ) ) { |
|
| 328 | - $invoice->set_object_read( true ); |
|
| 329 | - $invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) ); |
|
| 330 | - return; |
|
| 331 | - } |
|
| 326 | + // Abort if the data does not exist. |
|
| 327 | + if ( empty( $data ) ) { |
|
| 328 | + $invoice->set_object_read( true ); |
|
| 329 | + $invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) ); |
|
| 330 | + return; |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - $props = array(); |
|
| 333 | + $props = array(); |
|
| 334 | 334 | |
| 335 | - foreach ( $this->database_fields_to_props as $db_field => $prop ) { |
|
| 335 | + foreach ( $this->database_fields_to_props as $db_field => $prop ) { |
|
| 336 | 336 | |
| 337 | - if ( $db_field == 'post_id' ) { |
|
| 338 | - continue; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - $props[ $prop ] = $data[ $db_field ]; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - $invoice->set_props( $props ); |
|
| 345 | - |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * Gets a list of special fields that need updated based on change state |
|
| 350 | - * or if they are present in the database or not. |
|
| 351 | - * |
|
| 352 | - * @param WPInv_Invoice $invoice The Invoice object. |
|
| 353 | - * @return array A mapping of field keys => prop names, filtered by ones that should be updated. |
|
| 354 | - */ |
|
| 355 | - protected function get_special_fields_to_update( $invoice ) { |
|
| 356 | - $fields_to_update = array(); |
|
| 357 | - $changed_props = $invoice->get_changes(); |
|
| 358 | - |
|
| 359 | - // Props should be updated if they are a part of the $changed array or don't exist yet. |
|
| 360 | - foreach ( $this->database_fields_to_props as $database_field => $prop ) { |
|
| 361 | - if ( array_key_exists( $prop, $changed_props ) ) { |
|
| 362 | - $fields_to_update[ $database_field ] = $prop; |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - return $fields_to_update; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Helper method that updates all the database fields for an invoice based on it's settings in the WPInv_Invoice class. |
|
| 371 | - * |
|
| 372 | - * @param WPInv_Invoice $invoice WPInv_Invoice object. |
|
| 373 | - * @since 1.0.19 |
|
| 374 | - */ |
|
| 375 | - protected function update_special_fields( &$invoice ) { |
|
| 376 | - global $wpdb; |
|
| 377 | - |
|
| 378 | - $updated_props = array(); |
|
| 379 | - $fields_to_update = $this->get_special_fields_to_update( $invoice ); |
|
| 380 | - |
|
| 381 | - foreach ( $fields_to_update as $database_field => $prop ) { |
|
| 382 | - $value = $invoice->{"get_$prop"}( 'edit' ); |
|
| 383 | - $value = is_string( $value ) ? wp_slash( $value ) : $value; |
|
| 384 | - $value = is_bool( $value ) ? ( int ) $value : $value; |
|
| 385 | - $updated_props[ $database_field ] = maybe_serialize( $value ); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if ( ! empty( $updated_props ) ) { |
|
| 389 | - |
|
| 390 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 391 | - $wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) ); |
|
| 392 | - wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
| 393 | - do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props ); |
|
| 394 | - |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Helper method that inserts special fields to the database. |
|
| 401 | - * |
|
| 402 | - * @param WPInv_Invoice $invoice WPInv_Invoice object. |
|
| 403 | - * @since 1.0.19 |
|
| 404 | - */ |
|
| 405 | - protected function insert_special_fields( &$invoice ) { |
|
| 406 | - global $wpdb; |
|
| 407 | - |
|
| 408 | - $updated_props = array(); |
|
| 409 | - |
|
| 410 | - foreach ( $this->database_fields_to_props as $database_field => $prop ) { |
|
| 411 | - $value = $invoice->{"get_$prop"}( 'edit' ); |
|
| 412 | - $value = is_string( $value ) ? wp_slash( $value ) : $value; |
|
| 413 | - $value = is_bool( $value ) ? ( int ) $value : $value; |
|
| 414 | - $updated_props[ $database_field ] = maybe_serialize( $value ); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 418 | - $wpdb->insert( $table, $updated_props ); |
|
| 419 | - wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
| 420 | - do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props ); |
|
| 421 | - |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 337 | + if ( $db_field == 'post_id' ) { |
|
| 338 | + continue; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + $props[ $prop ] = $data[ $db_field ]; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + $invoice->set_props( $props ); |
|
| 345 | + |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * Gets a list of special fields that need updated based on change state |
|
| 350 | + * or if they are present in the database or not. |
|
| 351 | + * |
|
| 352 | + * @param WPInv_Invoice $invoice The Invoice object. |
|
| 353 | + * @return array A mapping of field keys => prop names, filtered by ones that should be updated. |
|
| 354 | + */ |
|
| 355 | + protected function get_special_fields_to_update( $invoice ) { |
|
| 356 | + $fields_to_update = array(); |
|
| 357 | + $changed_props = $invoice->get_changes(); |
|
| 358 | + |
|
| 359 | + // Props should be updated if they are a part of the $changed array or don't exist yet. |
|
| 360 | + foreach ( $this->database_fields_to_props as $database_field => $prop ) { |
|
| 361 | + if ( array_key_exists( $prop, $changed_props ) ) { |
|
| 362 | + $fields_to_update[ $database_field ] = $prop; |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + return $fields_to_update; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Helper method that updates all the database fields for an invoice based on it's settings in the WPInv_Invoice class. |
|
| 371 | + * |
|
| 372 | + * @param WPInv_Invoice $invoice WPInv_Invoice object. |
|
| 373 | + * @since 1.0.19 |
|
| 374 | + */ |
|
| 375 | + protected function update_special_fields( &$invoice ) { |
|
| 376 | + global $wpdb; |
|
| 377 | + |
|
| 378 | + $updated_props = array(); |
|
| 379 | + $fields_to_update = $this->get_special_fields_to_update( $invoice ); |
|
| 380 | + |
|
| 381 | + foreach ( $fields_to_update as $database_field => $prop ) { |
|
| 382 | + $value = $invoice->{"get_$prop"}( 'edit' ); |
|
| 383 | + $value = is_string( $value ) ? wp_slash( $value ) : $value; |
|
| 384 | + $value = is_bool( $value ) ? ( int ) $value : $value; |
|
| 385 | + $updated_props[ $database_field ] = maybe_serialize( $value ); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if ( ! empty( $updated_props ) ) { |
|
| 389 | + |
|
| 390 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 391 | + $wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) ); |
|
| 392 | + wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
| 393 | + do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props ); |
|
| 394 | + |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Helper method that inserts special fields to the database. |
|
| 401 | + * |
|
| 402 | + * @param WPInv_Invoice $invoice WPInv_Invoice object. |
|
| 403 | + * @since 1.0.19 |
|
| 404 | + */ |
|
| 405 | + protected function insert_special_fields( &$invoice ) { |
|
| 406 | + global $wpdb; |
|
| 407 | + |
|
| 408 | + $updated_props = array(); |
|
| 409 | + |
|
| 410 | + foreach ( $this->database_fields_to_props as $database_field => $prop ) { |
|
| 411 | + $value = $invoice->{"get_$prop"}( 'edit' ); |
|
| 412 | + $value = is_string( $value ) ? wp_slash( $value ) : $value; |
|
| 413 | + $value = is_bool( $value ) ? ( int ) $value : $value; |
|
| 414 | + $updated_props[ $database_field ] = maybe_serialize( $value ); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 418 | + $wpdb->insert( $table, $updated_props ); |
|
| 419 | + wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' ); |
|
| 420 | + do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props ); |
|
| 421 | + |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | 425 | * Saves all special fields. |
| 426 | - * |
|
| 427 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 426 | + * |
|
| 427 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 428 | 428 | */ |
| 429 | 429 | public function save_special_fields( & $invoice ) { |
| 430 | - global $wpdb; |
|
| 430 | + global $wpdb; |
|
| 431 | 431 | |
| 432 | - // The invoices table. |
|
| 433 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 434 | - $id = (int) $invoice->get_id(); |
|
| 435 | - $invoice->maybe_set_key(); |
|
| 432 | + // The invoices table. |
|
| 433 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 434 | + $id = (int) $invoice->get_id(); |
|
| 435 | + $invoice->maybe_set_key(); |
|
| 436 | 436 | |
| 437 | - if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) { |
|
| 437 | + if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) { |
|
| 438 | 438 | |
| 439 | - $this->update_special_fields( $invoice ); |
|
| 439 | + $this->update_special_fields( $invoice ); |
|
| 440 | 440 | |
| 441 | - } else { |
|
| 441 | + } else { |
|
| 442 | 442 | |
| 443 | - $this->insert_special_fields( $invoice ); |
|
| 443 | + $this->insert_special_fields( $invoice ); |
|
| 444 | 444 | |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | - } |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - /** |
|
| 449 | + /** |
|
| 450 | 450 | * Set's up cart details. |
| 451 | - * |
|
| 452 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 451 | + * |
|
| 452 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 453 | 453 | */ |
| 454 | 454 | public function add_items( &$invoice ) { |
| 455 | - global $wpdb; |
|
| 455 | + global $wpdb; |
|
| 456 | 456 | |
| 457 | - // Maybe retrieve from the cache. |
|
| 458 | - $items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' ); |
|
| 457 | + // Maybe retrieve from the cache. |
|
| 458 | + $items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' ); |
|
| 459 | 459 | |
| 460 | - // If not found, retrieve from the db. |
|
| 461 | - if ( false === $items ) { |
|
| 462 | - $table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
| 460 | + // If not found, retrieve from the db. |
|
| 461 | + if ( false === $items ) { |
|
| 462 | + $table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
| 463 | 463 | |
| 464 | - $items = $wpdb->get_results( |
|
| 465 | - $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() ) |
|
| 466 | - ); |
|
| 464 | + $items = $wpdb->get_results( |
|
| 465 | + $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() ) |
|
| 466 | + ); |
|
| 467 | 467 | |
| 468 | - // Update the cache with our data |
|
| 469 | - wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' ); |
|
| 468 | + // Update the cache with our data |
|
| 469 | + wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' ); |
|
| 470 | 470 | |
| 471 | - } |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | - // Abort if no items found. |
|
| 473 | + // Abort if no items found. |
|
| 474 | 474 | if ( empty( $items ) ) { |
| 475 | 475 | return; |
| 476 | - } |
|
| 477 | - |
|
| 478 | - $_items = array(); |
|
| 479 | - foreach ( $items as $item_data ) { |
|
| 480 | - $item = new GetPaid_Form_Item( $item_data->item_id ); |
|
| 481 | - |
|
| 482 | - // Set item data. |
|
| 483 | - $item->item_tax = wpinv_sanitize_amount( $item_data->tax ); |
|
| 484 | - $item->item_discount = wpinv_sanitize_amount( $item_data->discount ); |
|
| 485 | - $item->set_name( $item_data->item_name ); |
|
| 486 | - $item->set_description( $item_data->item_description ); |
|
| 487 | - $item->set_price( $item_data->item_price ); |
|
| 488 | - $item->set_quantity( $item_data->quantity ); |
|
| 489 | - $item->set_item_meta( $item_data->meta ); |
|
| 490 | - $_items[] = $item; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - $invoice->set_items( $_items ); |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - /** |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + $_items = array(); |
|
| 479 | + foreach ( $items as $item_data ) { |
|
| 480 | + $item = new GetPaid_Form_Item( $item_data->item_id ); |
|
| 481 | + |
|
| 482 | + // Set item data. |
|
| 483 | + $item->item_tax = wpinv_sanitize_amount( $item_data->tax ); |
|
| 484 | + $item->item_discount = wpinv_sanitize_amount( $item_data->discount ); |
|
| 485 | + $item->set_name( $item_data->item_name ); |
|
| 486 | + $item->set_description( $item_data->item_description ); |
|
| 487 | + $item->set_price( $item_data->item_price ); |
|
| 488 | + $item->set_quantity( $item_data->quantity ); |
|
| 489 | + $item->set_item_meta( $item_data->meta ); |
|
| 490 | + $_items[] = $item; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + $invoice->set_items( $_items ); |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | 497 | * Saves cart details. |
| 498 | - * |
|
| 499 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 498 | + * |
|
| 499 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 500 | 500 | */ |
| 501 | 501 | public function save_items( $invoice ) { |
| 502 | 502 | |
| 503 | - // Delete previously existing items. |
|
| 504 | - $this->delete_items( $invoice ); |
|
| 503 | + // Delete previously existing items. |
|
| 504 | + $this->delete_items( $invoice ); |
|
| 505 | 505 | |
| 506 | - $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
| 506 | + $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
| 507 | 507 | |
| 508 | - foreach ( $invoice->get_cart_details() as $item_data ) { |
|
| 509 | - $item_data = array_map( 'maybe_serialize', $item_data ); |
|
| 510 | - $GLOBALS['wpdb']->insert( $table, $item_data ); |
|
| 511 | - } |
|
| 508 | + foreach ( $invoice->get_cart_details() as $item_data ) { |
|
| 509 | + $item_data = array_map( 'maybe_serialize', $item_data ); |
|
| 510 | + $GLOBALS['wpdb']->insert( $table, $item_data ); |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | - wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' ); |
|
| 514 | - do_action( "getpaid_invoice_save_items", $invoice ); |
|
| 513 | + wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' ); |
|
| 514 | + do_action( "getpaid_invoice_save_items", $invoice ); |
|
| 515 | 515 | |
| 516 | - } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - /** |
|
| 518 | + /** |
|
| 519 | 519 | * Deletes an invoice's cart details from the database. |
| 520 | - * |
|
| 521 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 520 | + * |
|
| 521 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 522 | 522 | */ |
| 523 | 523 | public function delete_items( $invoice ) { |
| 524 | - $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
| 525 | - return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) ); |
|
| 526 | - } |
|
| 524 | + $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items'; |
|
| 525 | + return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) ); |
|
| 526 | + } |
|
| 527 | 527 | |
| 528 | - /** |
|
| 528 | + /** |
|
| 529 | 529 | * Deletes an invoice's special fields from the database. |
| 530 | - * |
|
| 531 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 530 | + * |
|
| 531 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 532 | 532 | */ |
| 533 | 533 | public function delete_special_fields( $invoice ) { |
| 534 | - $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoices'; |
|
| 535 | - return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) ); |
|
| 536 | - } |
|
| 534 | + $table = $GLOBALS['wpdb']->prefix . 'getpaid_invoices'; |
|
| 535 | + return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) ); |
|
| 536 | + } |
|
| 537 | 537 | |
| 538 | - /** |
|
| 539 | - * Get the status to save to the post object. |
|
| 540 | - * |
|
| 541 | - * |
|
| 542 | - * @since 1.0.19 |
|
| 543 | - * @param WPInv_Invoice $object GetPaid_Data object. |
|
| 544 | - * @return string |
|
| 545 | - */ |
|
| 546 | - protected function get_post_status( $object ) { |
|
| 547 | - $object_status = $object->get_status( 'edit' ); |
|
| 548 | - |
|
| 549 | - if ( ! $object_status ) { |
|
| 550 | - $object_status = $object->get_default_status(); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - return $object_status; |
|
| 554 | - } |
|
| 538 | + /** |
|
| 539 | + * Get the status to save to the post object. |
|
| 540 | + * |
|
| 541 | + * |
|
| 542 | + * @since 1.0.19 |
|
| 543 | + * @param WPInv_Invoice $object GetPaid_Data object. |
|
| 544 | + * @return string |
|
| 545 | + */ |
|
| 546 | + protected function get_post_status( $object ) { |
|
| 547 | + $object_status = $object->get_status( 'edit' ); |
|
| 548 | + |
|
| 549 | + if ( ! $object_status ) { |
|
| 550 | + $object_status = $object->get_default_status(); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + return $object_status; |
|
| 554 | + } |
|
| 555 | 555 | |
| 556 | 556 | } |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | class WPInv_Invoice extends GetPaid_Data { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Which data store to load. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 17 | + * Which data store to load. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | 21 | protected $data_store_name = 'invoice'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * This is the name of this object type. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 24 | + * This is the name of this object type. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $object_type = 'invoice'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.19 |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $data = array( |
|
| 37 | - 'parent_id' => 0, |
|
| 38 | - 'status' => 'wpi-pending', |
|
| 39 | - 'version' => '', |
|
| 40 | - 'date_created' => null, |
|
| 31 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.19 |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $data = array( |
|
| 37 | + 'parent_id' => 0, |
|
| 38 | + 'status' => 'wpi-pending', |
|
| 39 | + 'version' => '', |
|
| 40 | + 'date_created' => null, |
|
| 41 | 41 | 'date_modified' => null, |
| 42 | 42 | 'due_date' => null, |
| 43 | 43 | 'completed_date' => null, |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'state' => null, |
| 61 | 61 | 'zip' => null, |
| 62 | 62 | 'company' => null, |
| 63 | - 'company_id' => null, |
|
| 63 | + 'company_id' => null, |
|
| 64 | 64 | 'vat_number' => null, |
| 65 | 65 | 'vat_rate' => null, |
| 66 | 66 | 'address' => null, |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | 'subtotal' => 0, |
| 69 | 69 | 'total_discount' => 0, |
| 70 | 70 | 'total_tax' => 0, |
| 71 | - 'total_fees' => 0, |
|
| 72 | - 'total' => 0, |
|
| 71 | + 'total_fees' => 0, |
|
| 72 | + 'total' => 0, |
|
| 73 | 73 | 'fees' => array(), |
| 74 | 74 | 'discounts' => array(), |
| 75 | 75 | 'taxes' => array(), |
@@ -81,22 +81,22 @@ discard block |
||
| 81 | 81 | 'transaction_id' => '', |
| 82 | 82 | 'currency' => '', |
| 83 | 83 | 'disable_taxes' => false, |
| 84 | - 'subscription_id' => null, |
|
| 85 | - 'remote_subscription_id' => null, |
|
| 86 | - 'is_viewed' => false, |
|
| 87 | - 'email_cc' => '', |
|
| 88 | - 'template' => 'quantity', // hours, amount only |
|
| 89 | - 'created_via' => null, |
|
| 84 | + 'subscription_id' => null, |
|
| 85 | + 'remote_subscription_id' => null, |
|
| 86 | + 'is_viewed' => false, |
|
| 87 | + 'email_cc' => '', |
|
| 88 | + 'template' => 'quantity', // hours, amount only |
|
| 89 | + 'created_via' => null, |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * Stores meta in cache for future reads. |
|
| 94 | - * |
|
| 95 | - * A group must be set to to enable caching. |
|
| 96 | - * |
|
| 97 | - * @var string |
|
| 98 | - */ |
|
| 99 | - protected $cache_group = 'getpaid_invoices'; |
|
| 93 | + * Stores meta in cache for future reads. |
|
| 94 | + * |
|
| 95 | + * A group must be set to to enable caching. |
|
| 96 | + * |
|
| 97 | + * @var string |
|
| 98 | + */ |
|
| 99 | + protected $cache_group = 'getpaid_invoices'; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Stores a reference to the original WP_Post object |
@@ -110,111 +110,111 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @var int |
| 112 | 112 | */ |
| 113 | - protected $recurring_item = null; |
|
| 113 | + protected $recurring_item = null; |
|
| 114 | 114 | |
| 115 | - /** |
|
| 115 | + /** |
|
| 116 | 116 | * Stores an array of item totals. |
| 117 | - * |
|
| 118 | - * e.g $totals['discount'] = array( |
|
| 119 | - * 'initial' => 10, |
|
| 120 | - * 'recurring' => 10, |
|
| 121 | - * ) |
|
| 117 | + * |
|
| 118 | + * e.g $totals['discount'] = array( |
|
| 119 | + * 'initial' => 10, |
|
| 120 | + * 'recurring' => 10, |
|
| 121 | + * ) |
|
| 122 | 122 | * |
| 123 | 123 | * @var array |
| 124 | 124 | */ |
| 125 | - protected $totals = array(); |
|
| 125 | + protected $totals = array(); |
|
| 126 | 126 | |
| 127 | - /** |
|
| 127 | + /** |
|
| 128 | 128 | * Tax rate. |
| 129 | - * |
|
| 129 | + * |
|
| 130 | 130 | * @var float |
| 131 | 131 | */ |
| 132 | - protected $tax_rate = 0; |
|
| 132 | + protected $tax_rate = 0; |
|
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Stores the status transition information. |
|
| 136 | - * |
|
| 137 | - * @since 1.0.19 |
|
| 138 | - * @var bool|array |
|
| 139 | - */ |
|
| 140 | - protected $status_transition = false; |
|
| 134 | + /** |
|
| 135 | + * Stores the status transition information. |
|
| 136 | + * |
|
| 137 | + * @since 1.0.19 |
|
| 138 | + * @var bool|array |
|
| 139 | + */ |
|
| 140 | + protected $status_transition = false; |
|
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 144 | - * |
|
| 145 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 146 | - */ |
|
| 143 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 144 | + * |
|
| 145 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 146 | + */ |
|
| 147 | 147 | public function __construct( $invoice = 0 ) { |
| 148 | 148 | |
| 149 | 149 | parent::__construct( $invoice ); |
| 150 | 150 | |
| 151 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 152 | - $this->set_id( (int) $invoice ); |
|
| 153 | - } elseif ( $invoice instanceof self ) { |
|
| 154 | - $this->set_id( $invoice->get_id() ); |
|
| 155 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 156 | - $this->set_id( $invoice->ID ); |
|
| 157 | - } elseif ( is_array( $invoice ) ) { |
|
| 158 | - $this->set_props( $invoice ); |
|
| 159 | - |
|
| 160 | - if ( isset( $invoice['ID'] ) ) { |
|
| 161 | - $this->set_id( $invoice['ID'] ); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 165 | - $this->set_id( $invoice_id ); |
|
| 166 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 167 | - $this->set_id( $invoice_id ); |
|
| 168 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 169 | - $this->set_id( $invoice_id ); |
|
| 170 | - } else { |
|
| 171 | - $this->set_object_read( true ); |
|
| 172 | - } |
|
| 151 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 152 | + $this->set_id( (int) $invoice ); |
|
| 153 | + } elseif ( $invoice instanceof self ) { |
|
| 154 | + $this->set_id( $invoice->get_id() ); |
|
| 155 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 156 | + $this->set_id( $invoice->ID ); |
|
| 157 | + } elseif ( is_array( $invoice ) ) { |
|
| 158 | + $this->set_props( $invoice ); |
|
| 159 | + |
|
| 160 | + if ( isset( $invoice['ID'] ) ) { |
|
| 161 | + $this->set_id( $invoice['ID'] ); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 165 | + $this->set_id( $invoice_id ); |
|
| 166 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 167 | + $this->set_id( $invoice_id ); |
|
| 168 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 169 | + $this->set_id( $invoice_id ); |
|
| 170 | + } else { |
|
| 171 | + $this->set_object_read( true ); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | // Load the datastore. |
| 175 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 175 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 176 | 176 | |
| 177 | - if ( $this->get_id() > 0 ) { |
|
| 177 | + if ( $this->get_id() > 0 ) { |
|
| 178 | 178 | $this->post = get_post( $this->get_id() ); |
| 179 | 179 | $this->ID = $this->get_id(); |
| 180 | - $this->data_store->read( $this ); |
|
| 180 | + $this->data_store->read( $this ); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | - * Given an invoice key/number, it returns its id. |
|
| 187 | - * |
|
| 188 | - * |
|
| 189 | - * @static |
|
| 190 | - * @param string $value The invoice key or number |
|
| 191 | - * @param string $field Either key, transaction_id or number. |
|
| 192 | - * @since 1.0.15 |
|
| 193 | - * @return int |
|
| 194 | - */ |
|
| 195 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 186 | + * Given an invoice key/number, it returns its id. |
|
| 187 | + * |
|
| 188 | + * |
|
| 189 | + * @static |
|
| 190 | + * @param string $value The invoice key or number |
|
| 191 | + * @param string $field Either key, transaction_id or number. |
|
| 192 | + * @since 1.0.15 |
|
| 193 | + * @return int |
|
| 194 | + */ |
|
| 195 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 196 | 196 | global $wpdb; |
| 197 | 197 | |
| 198 | - // Trim the value. |
|
| 199 | - $value = trim( $value ); |
|
| 198 | + // Trim the value. |
|
| 199 | + $value = trim( $value ); |
|
| 200 | 200 | |
| 201 | - if ( empty( $value ) ) { |
|
| 202 | - return 0; |
|
| 203 | - } |
|
| 201 | + if ( empty( $value ) ) { |
|
| 202 | + return 0; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | 205 | // Valid fields. |
| 206 | 206 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 207 | 207 | |
| 208 | - // Ensure a field has been passed. |
|
| 209 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 210 | - return 0; |
|
| 211 | - } |
|
| 208 | + // Ensure a field has been passed. |
|
| 209 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 210 | + return 0; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - // Maybe retrieve from the cache. |
|
| 214 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 215 | - if ( false !== $invoice_id ) { |
|
| 216 | - return $invoice_id; |
|
| 217 | - } |
|
| 213 | + // Maybe retrieve from the cache. |
|
| 214 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 215 | + if ( false !== $invoice_id ) { |
|
| 216 | + return $invoice_id; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | // Fetch from the db. |
| 220 | 220 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | - // Update the cache with our data |
|
| 226 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 225 | + // Update the cache with our data |
|
| 226 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 227 | 227 | |
| 228 | - return $invoice_id; |
|
| 228 | + return $invoice_id; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -251,83 +251,83 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | - * Get parent invoice ID. |
|
| 255 | - * |
|
| 256 | - * @since 1.0.19 |
|
| 257 | - * @param string $context View or edit context. |
|
| 258 | - * @return int |
|
| 259 | - */ |
|
| 260 | - public function get_parent_id( $context = 'view' ) { |
|
| 261 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 254 | + * Get parent invoice ID. |
|
| 255 | + * |
|
| 256 | + * @since 1.0.19 |
|
| 257 | + * @param string $context View or edit context. |
|
| 258 | + * @return int |
|
| 259 | + */ |
|
| 260 | + public function get_parent_id( $context = 'view' ) { |
|
| 261 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Get parent invoice. |
|
| 266 | - * |
|
| 267 | - * @since 1.0.19 |
|
| 268 | - * @return WPInv_Invoice |
|
| 269 | - */ |
|
| 265 | + * Get parent invoice. |
|
| 266 | + * |
|
| 267 | + * @since 1.0.19 |
|
| 268 | + * @return WPInv_Invoice |
|
| 269 | + */ |
|
| 270 | 270 | public function get_parent_payment() { |
| 271 | 271 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
| 275 | - * Alias for self::get_parent_payment(). |
|
| 276 | - * |
|
| 277 | - * @since 1.0.19 |
|
| 278 | - * @return WPInv_Invoice |
|
| 279 | - */ |
|
| 275 | + * Alias for self::get_parent_payment(). |
|
| 276 | + * |
|
| 277 | + * @since 1.0.19 |
|
| 278 | + * @return WPInv_Invoice |
|
| 279 | + */ |
|
| 280 | 280 | public function get_parent() { |
| 281 | 281 | return $this->get_parent_payment(); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | - * Get invoice status. |
|
| 286 | - * |
|
| 287 | - * @since 1.0.19 |
|
| 288 | - * @param string $context View or edit context. |
|
| 289 | - * @return string |
|
| 290 | - */ |
|
| 291 | - public function get_status( $context = 'view' ) { |
|
| 292 | - return $this->get_prop( 'status', $context ); |
|
| 293 | - } |
|
| 285 | + * Get invoice status. |
|
| 286 | + * |
|
| 287 | + * @since 1.0.19 |
|
| 288 | + * @param string $context View or edit context. |
|
| 289 | + * @return string |
|
| 290 | + */ |
|
| 291 | + public function get_status( $context = 'view' ) { |
|
| 292 | + return $this->get_prop( 'status', $context ); |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - /** |
|
| 296 | - * Retrieves an array of possible invoice statuses. |
|
| 297 | - * |
|
| 298 | - * @since 1.0.19 |
|
| 299 | - * @return array |
|
| 300 | - */ |
|
| 301 | - public function get_all_statuses() { |
|
| 302 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Get invoice status nice name. |
|
| 307 | - * |
|
| 308 | - * @since 1.0.19 |
|
| 309 | - * @return string |
|
| 310 | - */ |
|
| 295 | + /** |
|
| 296 | + * Retrieves an array of possible invoice statuses. |
|
| 297 | + * |
|
| 298 | + * @since 1.0.19 |
|
| 299 | + * @return array |
|
| 300 | + */ |
|
| 301 | + public function get_all_statuses() { |
|
| 302 | + return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Get invoice status nice name. |
|
| 307 | + * |
|
| 308 | + * @since 1.0.19 |
|
| 309 | + * @return string |
|
| 310 | + */ |
|
| 311 | 311 | public function get_status_nicename() { |
| 312 | - $statuses = $this->get_all_statuses(); |
|
| 312 | + $statuses = $this->get_all_statuses(); |
|
| 313 | 313 | |
| 314 | 314 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 315 | 315 | |
| 316 | 316 | return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Retrieves the invoice status class |
|
| 321 | - * |
|
| 322 | - * @since 1.0.19 |
|
| 323 | - * @return string |
|
| 324 | - */ |
|
| 325 | - public function get_status_class() { |
|
| 326 | - $statuses = getpaid_get_invoice_status_classes(); |
|
| 327 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
| 328 | - } |
|
| 319 | + /** |
|
| 320 | + * Retrieves the invoice status class |
|
| 321 | + * |
|
| 322 | + * @since 1.0.19 |
|
| 323 | + * @return string |
|
| 324 | + */ |
|
| 325 | + public function get_status_class() { |
|
| 326 | + $statuses = getpaid_get_invoice_status_classes(); |
|
| 327 | + return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - /** |
|
| 330 | + /** |
|
| 331 | 331 | * Retrieves the invoice status label html |
| 332 | 332 | * |
| 333 | 333 | * @since 1.0.0 |
@@ -335,263 +335,263 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function get_status_label_html() { |
| 337 | 337 | |
| 338 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 339 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 340 | - $class = esc_attr( $this->get_status_class() ); |
|
| 338 | + $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 339 | + $status = sanitize_html_class( $this->get_status() ); |
|
| 340 | + $class = esc_attr( $this->get_status_class() ); |
|
| 341 | 341 | |
| 342 | - return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
|
| 343 | - } |
|
| 342 | + return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | - * Get plugin version when the invoice was created. |
|
| 347 | - * |
|
| 348 | - * @since 1.0.19 |
|
| 349 | - * @param string $context View or edit context. |
|
| 350 | - * @return string |
|
| 351 | - */ |
|
| 352 | - public function get_version( $context = 'view' ) { |
|
| 353 | - return $this->get_prop( 'version', $context ); |
|
| 354 | - } |
|
| 346 | + * Get plugin version when the invoice was created. |
|
| 347 | + * |
|
| 348 | + * @since 1.0.19 |
|
| 349 | + * @param string $context View or edit context. |
|
| 350 | + * @return string |
|
| 351 | + */ |
|
| 352 | + public function get_version( $context = 'view' ) { |
|
| 353 | + return $this->get_prop( 'version', $context ); |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * @deprecated |
|
| 358 | - */ |
|
| 359 | - public function get_invoice_date( $format = true ) { |
|
| 360 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 361 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 362 | - $formatted = getpaid_format_date( $date ); |
|
| 356 | + /** |
|
| 357 | + * @deprecated |
|
| 358 | + */ |
|
| 359 | + public function get_invoice_date( $format = true ) { |
|
| 360 | + $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 361 | + $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 362 | + $formatted = getpaid_format_date( $date ); |
|
| 363 | 363 | |
| 364 | - if ( $format ) { |
|
| 365 | - return $formatted; |
|
| 366 | - } |
|
| 364 | + if ( $format ) { |
|
| 365 | + return $formatted; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - return empty( $formatted ) ? '' : $date; |
|
| 368 | + return empty( $formatted ) ? '' : $date; |
|
| 369 | 369 | |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
| 373 | - * Get date when the invoice was created. |
|
| 374 | - * |
|
| 375 | - * @since 1.0.19 |
|
| 376 | - * @param string $context View or edit context. |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - public function get_date_created( $context = 'view' ) { |
|
| 380 | - return $this->get_prop( 'date_created', $context ); |
|
| 381 | - } |
|
| 373 | + * Get date when the invoice was created. |
|
| 374 | + * |
|
| 375 | + * @since 1.0.19 |
|
| 376 | + * @param string $context View or edit context. |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + public function get_date_created( $context = 'view' ) { |
|
| 380 | + return $this->get_prop( 'date_created', $context ); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - /** |
|
| 384 | - * Alias for self::get_date_created(). |
|
| 385 | - * |
|
| 386 | - * @since 1.0.19 |
|
| 387 | - * @param string $context View or edit context. |
|
| 388 | - * @return string |
|
| 389 | - */ |
|
| 390 | - public function get_created_date( $context = 'view' ) { |
|
| 391 | - return $this->get_date_created( $context ); |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Get GMT date when the invoice was created. |
|
| 396 | - * |
|
| 397 | - * @since 1.0.19 |
|
| 398 | - * @param string $context View or edit context. |
|
| 399 | - * @return string |
|
| 400 | - */ |
|
| 401 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 383 | + /** |
|
| 384 | + * Alias for self::get_date_created(). |
|
| 385 | + * |
|
| 386 | + * @since 1.0.19 |
|
| 387 | + * @param string $context View or edit context. |
|
| 388 | + * @return string |
|
| 389 | + */ |
|
| 390 | + public function get_created_date( $context = 'view' ) { |
|
| 391 | + return $this->get_date_created( $context ); |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Get GMT date when the invoice was created. |
|
| 396 | + * |
|
| 397 | + * @since 1.0.19 |
|
| 398 | + * @param string $context View or edit context. |
|
| 399 | + * @return string |
|
| 400 | + */ |
|
| 401 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 402 | 402 | $date = $this->get_date_created( $context ); |
| 403 | 403 | |
| 404 | 404 | if ( $date ) { |
| 405 | 405 | $date = get_gmt_from_date( $date ); |
| 406 | 406 | } |
| 407 | - return $date; |
|
| 407 | + return $date; |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | - * Get date when the invoice was last modified. |
|
| 412 | - * |
|
| 413 | - * @since 1.0.19 |
|
| 414 | - * @param string $context View or edit context. |
|
| 415 | - * @return string |
|
| 416 | - */ |
|
| 417 | - public function get_date_modified( $context = 'view' ) { |
|
| 418 | - return $this->get_prop( 'date_modified', $context ); |
|
| 419 | - } |
|
| 411 | + * Get date when the invoice was last modified. |
|
| 412 | + * |
|
| 413 | + * @since 1.0.19 |
|
| 414 | + * @param string $context View or edit context. |
|
| 415 | + * @return string |
|
| 416 | + */ |
|
| 417 | + public function get_date_modified( $context = 'view' ) { |
|
| 418 | + return $this->get_prop( 'date_modified', $context ); |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - /** |
|
| 422 | - * Alias for self::get_date_modified(). |
|
| 423 | - * |
|
| 424 | - * @since 1.0.19 |
|
| 425 | - * @param string $context View or edit context. |
|
| 426 | - * @return string |
|
| 427 | - */ |
|
| 428 | - public function get_modified_date( $context = 'view' ) { |
|
| 429 | - return $this->get_date_modified( $context ); |
|
| 421 | + /** |
|
| 422 | + * Alias for self::get_date_modified(). |
|
| 423 | + * |
|
| 424 | + * @since 1.0.19 |
|
| 425 | + * @param string $context View or edit context. |
|
| 426 | + * @return string |
|
| 427 | + */ |
|
| 428 | + public function get_modified_date( $context = 'view' ) { |
|
| 429 | + return $this->get_date_modified( $context ); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | - * Get GMT date when the invoice was last modified. |
|
| 434 | - * |
|
| 435 | - * @since 1.0.19 |
|
| 436 | - * @param string $context View or edit context. |
|
| 437 | - * @return string |
|
| 438 | - */ |
|
| 439 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 433 | + * Get GMT date when the invoice was last modified. |
|
| 434 | + * |
|
| 435 | + * @since 1.0.19 |
|
| 436 | + * @param string $context View or edit context. |
|
| 437 | + * @return string |
|
| 438 | + */ |
|
| 439 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 440 | 440 | $date = $this->get_date_modified( $context ); |
| 441 | 441 | |
| 442 | 442 | if ( $date ) { |
| 443 | 443 | $date = get_gmt_from_date( $date ); |
| 444 | 444 | } |
| 445 | - return $date; |
|
| 445 | + return $date; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | - * Get the invoice due date. |
|
| 450 | - * |
|
| 451 | - * @since 1.0.19 |
|
| 452 | - * @param string $context View or edit context. |
|
| 453 | - * @return string |
|
| 454 | - */ |
|
| 455 | - public function get_due_date( $context = 'view' ) { |
|
| 456 | - return $this->get_prop( 'due_date', $context ); |
|
| 449 | + * Get the invoice due date. |
|
| 450 | + * |
|
| 451 | + * @since 1.0.19 |
|
| 452 | + * @param string $context View or edit context. |
|
| 453 | + * @return string |
|
| 454 | + */ |
|
| 455 | + public function get_due_date( $context = 'view' ) { |
|
| 456 | + return $this->get_prop( 'due_date', $context ); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
| 460 | - * Alias for self::get_due_date(). |
|
| 461 | - * |
|
| 462 | - * @since 1.0.19 |
|
| 463 | - * @param string $context View or edit context. |
|
| 464 | - * @return string |
|
| 465 | - */ |
|
| 466 | - public function get_date_due( $context = 'view' ) { |
|
| 467 | - return $this->get_due_date( $context ); |
|
| 460 | + * Alias for self::get_due_date(). |
|
| 461 | + * |
|
| 462 | + * @since 1.0.19 |
|
| 463 | + * @param string $context View or edit context. |
|
| 464 | + * @return string |
|
| 465 | + */ |
|
| 466 | + public function get_date_due( $context = 'view' ) { |
|
| 467 | + return $this->get_due_date( $context ); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
| 471 | - * Get the invoice GMT due date. |
|
| 472 | - * |
|
| 473 | - * @since 1.0.19 |
|
| 474 | - * @param string $context View or edit context. |
|
| 475 | - * @return string |
|
| 476 | - */ |
|
| 477 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 471 | + * Get the invoice GMT due date. |
|
| 472 | + * |
|
| 473 | + * @since 1.0.19 |
|
| 474 | + * @param string $context View or edit context. |
|
| 475 | + * @return string |
|
| 476 | + */ |
|
| 477 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 478 | 478 | $date = $this->get_due_date( $context ); |
| 479 | 479 | |
| 480 | 480 | if ( $date ) { |
| 481 | 481 | $date = get_gmt_from_date( $date ); |
| 482 | 482 | } |
| 483 | - return $date; |
|
| 483 | + return $date; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
| 487 | - * Alias for self::get_due_date_gmt(). |
|
| 488 | - * |
|
| 489 | - * @since 1.0.19 |
|
| 490 | - * @param string $context View or edit context. |
|
| 491 | - * @return string |
|
| 492 | - */ |
|
| 493 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 494 | - return $this->get_due_date_gmt( $context ); |
|
| 487 | + * Alias for self::get_due_date_gmt(). |
|
| 488 | + * |
|
| 489 | + * @since 1.0.19 |
|
| 490 | + * @param string $context View or edit context. |
|
| 491 | + * @return string |
|
| 492 | + */ |
|
| 493 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 494 | + return $this->get_due_date_gmt( $context ); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | - * Get date when the invoice was completed. |
|
| 499 | - * |
|
| 500 | - * @since 1.0.19 |
|
| 501 | - * @param string $context View or edit context. |
|
| 502 | - * @return string |
|
| 503 | - */ |
|
| 504 | - public function get_completed_date( $context = 'view' ) { |
|
| 505 | - return $this->get_prop( 'completed_date', $context ); |
|
| 498 | + * Get date when the invoice was completed. |
|
| 499 | + * |
|
| 500 | + * @since 1.0.19 |
|
| 501 | + * @param string $context View or edit context. |
|
| 502 | + * @return string |
|
| 503 | + */ |
|
| 504 | + public function get_completed_date( $context = 'view' ) { |
|
| 505 | + return $this->get_prop( 'completed_date', $context ); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | - * Alias for self::get_completed_date(). |
|
| 510 | - * |
|
| 511 | - * @since 1.0.19 |
|
| 512 | - * @param string $context View or edit context. |
|
| 513 | - * @return string |
|
| 514 | - */ |
|
| 515 | - public function get_date_completed( $context = 'view' ) { |
|
| 516 | - return $this->get_completed_date( $context ); |
|
| 509 | + * Alias for self::get_completed_date(). |
|
| 510 | + * |
|
| 511 | + * @since 1.0.19 |
|
| 512 | + * @param string $context View or edit context. |
|
| 513 | + * @return string |
|
| 514 | + */ |
|
| 515 | + public function get_date_completed( $context = 'view' ) { |
|
| 516 | + return $this->get_completed_date( $context ); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | - * Get GMT date when the invoice was was completed. |
|
| 521 | - * |
|
| 522 | - * @since 1.0.19 |
|
| 523 | - * @param string $context View or edit context. |
|
| 524 | - * @return string |
|
| 525 | - */ |
|
| 526 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 520 | + * Get GMT date when the invoice was was completed. |
|
| 521 | + * |
|
| 522 | + * @since 1.0.19 |
|
| 523 | + * @param string $context View or edit context. |
|
| 524 | + * @return string |
|
| 525 | + */ |
|
| 526 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 527 | 527 | $date = $this->get_completed_date( $context ); |
| 528 | 528 | |
| 529 | 529 | if ( $date ) { |
| 530 | 530 | $date = get_gmt_from_date( $date ); |
| 531 | 531 | } |
| 532 | - return $date; |
|
| 532 | + return $date; |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | - * Alias for self::get_completed_date_gmt(). |
|
| 537 | - * |
|
| 538 | - * @since 1.0.19 |
|
| 539 | - * @param string $context View or edit context. |
|
| 540 | - * @return string |
|
| 541 | - */ |
|
| 542 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 543 | - return $this->get_completed_date_gmt( $context ); |
|
| 536 | + * Alias for self::get_completed_date_gmt(). |
|
| 537 | + * |
|
| 538 | + * @since 1.0.19 |
|
| 539 | + * @param string $context View or edit context. |
|
| 540 | + * @return string |
|
| 541 | + */ |
|
| 542 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 543 | + return $this->get_completed_date_gmt( $context ); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
| 547 | - * Get the invoice number. |
|
| 548 | - * |
|
| 549 | - * @since 1.0.19 |
|
| 550 | - * @param string $context View or edit context. |
|
| 551 | - * @return string |
|
| 552 | - */ |
|
| 553 | - public function get_number( $context = 'view' ) { |
|
| 554 | - $number = $this->get_prop( 'number', $context ); |
|
| 547 | + * Get the invoice number. |
|
| 548 | + * |
|
| 549 | + * @since 1.0.19 |
|
| 550 | + * @param string $context View or edit context. |
|
| 551 | + * @return string |
|
| 552 | + */ |
|
| 553 | + public function get_number( $context = 'view' ) { |
|
| 554 | + $number = $this->get_prop( 'number', $context ); |
|
| 555 | 555 | |
| 556 | - if ( empty( $number ) ) { |
|
| 557 | - $number = $this->generate_number(); |
|
| 558 | - $this->set_number( $this->generate_number() ); |
|
| 559 | - } |
|
| 556 | + if ( empty( $number ) ) { |
|
| 557 | + $number = $this->generate_number(); |
|
| 558 | + $this->set_number( $this->generate_number() ); |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | - return $number; |
|
| 561 | + return $number; |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - /** |
|
| 565 | - * Set the invoice number. |
|
| 566 | - * |
|
| 567 | - * @since 1.0.19 |
|
| 568 | - */ |
|
| 569 | - public function maybe_set_number() { |
|
| 564 | + /** |
|
| 565 | + * Set the invoice number. |
|
| 566 | + * |
|
| 567 | + * @since 1.0.19 |
|
| 568 | + */ |
|
| 569 | + public function maybe_set_number() { |
|
| 570 | 570 | $number = $this->get_number(); |
| 571 | 571 | |
| 572 | 572 | if ( empty( $number ) || $this->get_id() == $number ) { |
| 573 | - $this->set_number( $this->generate_number() ); |
|
| 573 | + $this->set_number( $this->generate_number() ); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - } |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | 578 | /** |
| 579 | - * Get the invoice key. |
|
| 580 | - * |
|
| 581 | - * @since 1.0.19 |
|
| 582 | - * @param string $context View or edit context. |
|
| 583 | - * @return string |
|
| 584 | - */ |
|
| 585 | - public function get_key( $context = 'view' ) { |
|
| 579 | + * Get the invoice key. |
|
| 580 | + * |
|
| 581 | + * @since 1.0.19 |
|
| 582 | + * @param string $context View or edit context. |
|
| 583 | + * @return string |
|
| 584 | + */ |
|
| 585 | + public function get_key( $context = 'view' ) { |
|
| 586 | 586 | return $this->get_prop( 'key', $context ); |
| 587 | - } |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * Set the invoice key. |
|
| 591 | - * |
|
| 592 | - * @since 1.0.19 |
|
| 593 | - */ |
|
| 594 | - public function maybe_set_key() { |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * Set the invoice key. |
|
| 591 | + * |
|
| 592 | + * @since 1.0.19 |
|
| 593 | + */ |
|
| 594 | + public function maybe_set_key() { |
|
| 595 | 595 | $key = $this->get_key(); |
| 596 | 596 | |
| 597 | 597 | if ( empty( $key ) ) { |
@@ -602,140 +602,140 @@ discard block |
||
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
| 605 | - * Get the invoice type. |
|
| 606 | - * |
|
| 607 | - * @since 1.0.19 |
|
| 608 | - * @param string $context View or edit context. |
|
| 609 | - * @return string |
|
| 610 | - */ |
|
| 611 | - public function get_type( $context = 'view' ) { |
|
| 605 | + * Get the invoice type. |
|
| 606 | + * |
|
| 607 | + * @since 1.0.19 |
|
| 608 | + * @param string $context View or edit context. |
|
| 609 | + * @return string |
|
| 610 | + */ |
|
| 611 | + public function get_type( $context = 'view' ) { |
|
| 612 | 612 | return $this->get_prop( 'type', $context ); |
| 613 | - } |
|
| 614 | - |
|
| 615 | - /** |
|
| 616 | - * Returns the post type name. |
|
| 617 | - * |
|
| 618 | - * @since 1.0.19 |
|
| 619 | - * @return string |
|
| 620 | - */ |
|
| 621 | - public function get_invoice_quote_type() { |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + /** |
|
| 616 | + * Returns the post type name. |
|
| 617 | + * |
|
| 618 | + * @since 1.0.19 |
|
| 619 | + * @return string |
|
| 620 | + */ |
|
| 621 | + public function get_invoice_quote_type() { |
|
| 622 | 622 | return getpaid_get_post_type_label( $this->get_post_type(), false ); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
| 626 | - * Get the invoice post type label. |
|
| 627 | - * |
|
| 628 | - * @since 1.0.19 |
|
| 629 | - * @param string $context View or edit context. |
|
| 630 | - * @return string |
|
| 631 | - */ |
|
| 632 | - public function get_label( $context = 'view' ) { |
|
| 626 | + * Get the invoice post type label. |
|
| 627 | + * |
|
| 628 | + * @since 1.0.19 |
|
| 629 | + * @param string $context View or edit context. |
|
| 630 | + * @return string |
|
| 631 | + */ |
|
| 632 | + public function get_label( $context = 'view' ) { |
|
| 633 | 633 | return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
| 634 | - } |
|
| 635 | - |
|
| 636 | - /** |
|
| 637 | - * Get the invoice post type. |
|
| 638 | - * |
|
| 639 | - * @since 1.0.19 |
|
| 640 | - * @param string $context View or edit context. |
|
| 641 | - * @return string |
|
| 642 | - */ |
|
| 643 | - public function get_post_type( $context = 'view' ) { |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + /** |
|
| 637 | + * Get the invoice post type. |
|
| 638 | + * |
|
| 639 | + * @since 1.0.19 |
|
| 640 | + * @param string $context View or edit context. |
|
| 641 | + * @return string |
|
| 642 | + */ |
|
| 643 | + public function get_post_type( $context = 'view' ) { |
|
| 644 | 644 | return $this->get_prop( 'post_type', $context ); |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
| 648 | - * Get the invoice mode. |
|
| 649 | - * |
|
| 650 | - * @since 1.0.19 |
|
| 651 | - * @param string $context View or edit context. |
|
| 652 | - * @return string |
|
| 653 | - */ |
|
| 654 | - public function get_mode( $context = 'view' ) { |
|
| 648 | + * Get the invoice mode. |
|
| 649 | + * |
|
| 650 | + * @since 1.0.19 |
|
| 651 | + * @param string $context View or edit context. |
|
| 652 | + * @return string |
|
| 653 | + */ |
|
| 654 | + public function get_mode( $context = 'view' ) { |
|
| 655 | 655 | return $this->get_prop( 'mode', $context ); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
| 659 | - * Get the invoice path. |
|
| 660 | - * |
|
| 661 | - * @since 1.0.19 |
|
| 662 | - * @param string $context View or edit context. |
|
| 663 | - * @return string |
|
| 664 | - */ |
|
| 665 | - public function get_path( $context = 'view' ) { |
|
| 659 | + * Get the invoice path. |
|
| 660 | + * |
|
| 661 | + * @since 1.0.19 |
|
| 662 | + * @param string $context View or edit context. |
|
| 663 | + * @return string |
|
| 664 | + */ |
|
| 665 | + public function get_path( $context = 'view' ) { |
|
| 666 | 666 | $path = $this->get_prop( 'path', $context ); |
| 667 | - $prefix = $this->get_type(); |
|
| 667 | + $prefix = $this->get_type(); |
|
| 668 | 668 | |
| 669 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 670 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 671 | - $this->set_path( $path ); |
|
| 672 | - } |
|
| 669 | + if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 670 | + $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 671 | + $this->set_path( $path ); |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | - return $path; |
|
| 674 | + return $path; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | - * Get the invoice name/title. |
|
| 679 | - * |
|
| 680 | - * @since 1.0.19 |
|
| 681 | - * @param string $context View or edit context. |
|
| 682 | - * @return string |
|
| 683 | - */ |
|
| 684 | - public function get_name( $context = 'view' ) { |
|
| 678 | + * Get the invoice name/title. |
|
| 679 | + * |
|
| 680 | + * @since 1.0.19 |
|
| 681 | + * @param string $context View or edit context. |
|
| 682 | + * @return string |
|
| 683 | + */ |
|
| 684 | + public function get_name( $context = 'view' ) { |
|
| 685 | 685 | return $this->get_prop( 'title', $context ); |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
| 689 | - * Alias of self::get_name(). |
|
| 690 | - * |
|
| 691 | - * @since 1.0.19 |
|
| 692 | - * @param string $context View or edit context. |
|
| 693 | - * @return string |
|
| 694 | - */ |
|
| 695 | - public function get_title( $context = 'view' ) { |
|
| 696 | - return $this->get_name( $context ); |
|
| 689 | + * Alias of self::get_name(). |
|
| 690 | + * |
|
| 691 | + * @since 1.0.19 |
|
| 692 | + * @param string $context View or edit context. |
|
| 693 | + * @return string |
|
| 694 | + */ |
|
| 695 | + public function get_title( $context = 'view' ) { |
|
| 696 | + return $this->get_name( $context ); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
| 700 | - * Get the invoice description. |
|
| 701 | - * |
|
| 702 | - * @since 1.0.19 |
|
| 703 | - * @param string $context View or edit context. |
|
| 704 | - * @return string |
|
| 705 | - */ |
|
| 706 | - public function get_description( $context = 'view' ) { |
|
| 707 | - return $this->get_prop( 'description', $context ); |
|
| 700 | + * Get the invoice description. |
|
| 701 | + * |
|
| 702 | + * @since 1.0.19 |
|
| 703 | + * @param string $context View or edit context. |
|
| 704 | + * @return string |
|
| 705 | + */ |
|
| 706 | + public function get_description( $context = 'view' ) { |
|
| 707 | + return $this->get_prop( 'description', $context ); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /** |
| 711 | - * Alias of self::get_description(). |
|
| 712 | - * |
|
| 713 | - * @since 1.0.19 |
|
| 714 | - * @param string $context View or edit context. |
|
| 715 | - * @return string |
|
| 716 | - */ |
|
| 717 | - public function get_excerpt( $context = 'view' ) { |
|
| 718 | - return $this->get_description( $context ); |
|
| 711 | + * Alias of self::get_description(). |
|
| 712 | + * |
|
| 713 | + * @since 1.0.19 |
|
| 714 | + * @param string $context View or edit context. |
|
| 715 | + * @return string |
|
| 716 | + */ |
|
| 717 | + public function get_excerpt( $context = 'view' ) { |
|
| 718 | + return $this->get_description( $context ); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
| 722 | - * Alias of self::get_description(). |
|
| 723 | - * |
|
| 724 | - * @since 1.0.19 |
|
| 725 | - * @param string $context View or edit context. |
|
| 726 | - * @return string |
|
| 727 | - */ |
|
| 728 | - public function get_summary( $context = 'view' ) { |
|
| 729 | - return $this->get_description( $context ); |
|
| 722 | + * Alias of self::get_description(). |
|
| 723 | + * |
|
| 724 | + * @since 1.0.19 |
|
| 725 | + * @param string $context View or edit context. |
|
| 726 | + * @return string |
|
| 727 | + */ |
|
| 728 | + public function get_summary( $context = 'view' ) { |
|
| 729 | + return $this->get_description( $context ); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
| 733 | - * Returns the user info. |
|
| 734 | - * |
|
| 735 | - * @since 1.0.19 |
|
| 733 | + * Returns the user info. |
|
| 734 | + * |
|
| 735 | + * @since 1.0.19 |
|
| 736 | 736 | * @param string $context View or edit context. |
| 737 | - * @return array |
|
| 738 | - */ |
|
| 737 | + * @return array |
|
| 738 | + */ |
|
| 739 | 739 | public function get_user_info( $context = 'view' ) { |
| 740 | 740 | |
| 741 | 741 | $user_info = array( |
@@ -750,630 +750,630 @@ discard block |
||
| 750 | 750 | 'state' => $this->get_state( $context ), |
| 751 | 751 | 'zip' => $this->get_zip( $context ), |
| 752 | 752 | 'company' => $this->get_company( $context ), |
| 753 | - 'company_id' => $this->get_company_id( $context ), |
|
| 753 | + 'company_id' => $this->get_company_id( $context ), |
|
| 754 | 754 | 'vat_number' => $this->get_vat_number( $context ), |
| 755 | 755 | 'discount' => $this->get_discount_code( $context ), |
| 756 | - ); |
|
| 756 | + ); |
|
| 757 | 757 | |
| 758 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 758 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 759 | 759 | |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | - * Get the customer id. |
|
| 764 | - * |
|
| 765 | - * @since 1.0.19 |
|
| 766 | - * @param string $context View or edit context. |
|
| 767 | - * @return int |
|
| 768 | - */ |
|
| 769 | - public function get_author( $context = 'view' ) { |
|
| 770 | - return (int) $this->get_prop( 'author', $context ); |
|
| 763 | + * Get the customer id. |
|
| 764 | + * |
|
| 765 | + * @since 1.0.19 |
|
| 766 | + * @param string $context View or edit context. |
|
| 767 | + * @return int |
|
| 768 | + */ |
|
| 769 | + public function get_author( $context = 'view' ) { |
|
| 770 | + return (int) $this->get_prop( 'author', $context ); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
| 774 | - * Alias of self::get_author(). |
|
| 775 | - * |
|
| 776 | - * @since 1.0.19 |
|
| 777 | - * @param string $context View or edit context. |
|
| 778 | - * @return int |
|
| 779 | - */ |
|
| 780 | - public function get_user_id( $context = 'view' ) { |
|
| 781 | - return $this->get_author( $context ); |
|
| 774 | + * Alias of self::get_author(). |
|
| 775 | + * |
|
| 776 | + * @since 1.0.19 |
|
| 777 | + * @param string $context View or edit context. |
|
| 778 | + * @return int |
|
| 779 | + */ |
|
| 780 | + public function get_user_id( $context = 'view' ) { |
|
| 781 | + return $this->get_author( $context ); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - /** |
|
| 785 | - * Alias of self::get_author(). |
|
| 786 | - * |
|
| 787 | - * @since 1.0.19 |
|
| 788 | - * @param string $context View or edit context. |
|
| 789 | - * @return int |
|
| 790 | - */ |
|
| 791 | - public function get_customer_id( $context = 'view' ) { |
|
| 792 | - return $this->get_author( $context ); |
|
| 784 | + /** |
|
| 785 | + * Alias of self::get_author(). |
|
| 786 | + * |
|
| 787 | + * @since 1.0.19 |
|
| 788 | + * @param string $context View or edit context. |
|
| 789 | + * @return int |
|
| 790 | + */ |
|
| 791 | + public function get_customer_id( $context = 'view' ) { |
|
| 792 | + return $this->get_author( $context ); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | - * Get the customer's ip. |
|
| 797 | - * |
|
| 798 | - * @since 1.0.19 |
|
| 799 | - * @param string $context View or edit context. |
|
| 800 | - * @return string |
|
| 801 | - */ |
|
| 802 | - public function get_ip( $context = 'view' ) { |
|
| 803 | - return $this->get_prop( 'user_ip', $context ); |
|
| 796 | + * Get the customer's ip. |
|
| 797 | + * |
|
| 798 | + * @since 1.0.19 |
|
| 799 | + * @param string $context View or edit context. |
|
| 800 | + * @return string |
|
| 801 | + */ |
|
| 802 | + public function get_ip( $context = 'view' ) { |
|
| 803 | + return $this->get_prop( 'user_ip', $context ); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /** |
| 807 | - * Alias of self::get_ip(). |
|
| 808 | - * |
|
| 809 | - * @since 1.0.19 |
|
| 810 | - * @param string $context View or edit context. |
|
| 811 | - * @return string |
|
| 812 | - */ |
|
| 813 | - public function get_user_ip( $context = 'view' ) { |
|
| 814 | - return $this->get_ip( $context ); |
|
| 807 | + * Alias of self::get_ip(). |
|
| 808 | + * |
|
| 809 | + * @since 1.0.19 |
|
| 810 | + * @param string $context View or edit context. |
|
| 811 | + * @return string |
|
| 812 | + */ |
|
| 813 | + public function get_user_ip( $context = 'view' ) { |
|
| 814 | + return $this->get_ip( $context ); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - /** |
|
| 818 | - * Alias of self::get_ip(). |
|
| 819 | - * |
|
| 820 | - * @since 1.0.19 |
|
| 821 | - * @param string $context View or edit context. |
|
| 822 | - * @return string |
|
| 823 | - */ |
|
| 824 | - public function get_customer_ip( $context = 'view' ) { |
|
| 825 | - return $this->get_ip( $context ); |
|
| 817 | + /** |
|
| 818 | + * Alias of self::get_ip(). |
|
| 819 | + * |
|
| 820 | + * @since 1.0.19 |
|
| 821 | + * @param string $context View or edit context. |
|
| 822 | + * @return string |
|
| 823 | + */ |
|
| 824 | + public function get_customer_ip( $context = 'view' ) { |
|
| 825 | + return $this->get_ip( $context ); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
| 829 | - * Get the customer's first name. |
|
| 830 | - * |
|
| 831 | - * @since 1.0.19 |
|
| 832 | - * @param string $context View or edit context. |
|
| 833 | - * @return string |
|
| 834 | - */ |
|
| 835 | - public function get_first_name( $context = 'view' ) { |
|
| 836 | - return $this->get_prop( 'first_name', $context ); |
|
| 829 | + * Get the customer's first name. |
|
| 830 | + * |
|
| 831 | + * @since 1.0.19 |
|
| 832 | + * @param string $context View or edit context. |
|
| 833 | + * @return string |
|
| 834 | + */ |
|
| 835 | + public function get_first_name( $context = 'view' ) { |
|
| 836 | + return $this->get_prop( 'first_name', $context ); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | - * Alias of self::get_first_name(). |
|
| 841 | - * |
|
| 842 | - * @since 1.0.19 |
|
| 843 | - * @param string $context View or edit context. |
|
| 844 | - * @return string |
|
| 845 | - */ |
|
| 846 | - public function get_user_first_name( $context = 'view' ) { |
|
| 847 | - return $this->get_first_name( $context ); |
|
| 840 | + * Alias of self::get_first_name(). |
|
| 841 | + * |
|
| 842 | + * @since 1.0.19 |
|
| 843 | + * @param string $context View or edit context. |
|
| 844 | + * @return string |
|
| 845 | + */ |
|
| 846 | + public function get_user_first_name( $context = 'view' ) { |
|
| 847 | + return $this->get_first_name( $context ); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - /** |
|
| 851 | - * Alias of self::get_first_name(). |
|
| 852 | - * |
|
| 853 | - * @since 1.0.19 |
|
| 854 | - * @param string $context View or edit context. |
|
| 855 | - * @return string |
|
| 856 | - */ |
|
| 857 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 858 | - return $this->get_first_name( $context ); |
|
| 850 | + /** |
|
| 851 | + * Alias of self::get_first_name(). |
|
| 852 | + * |
|
| 853 | + * @since 1.0.19 |
|
| 854 | + * @param string $context View or edit context. |
|
| 855 | + * @return string |
|
| 856 | + */ |
|
| 857 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 858 | + return $this->get_first_name( $context ); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
| 862 | - * Get the customer's last name. |
|
| 863 | - * |
|
| 864 | - * @since 1.0.19 |
|
| 865 | - * @param string $context View or edit context. |
|
| 866 | - * @return string |
|
| 867 | - */ |
|
| 868 | - public function get_last_name( $context = 'view' ) { |
|
| 869 | - return $this->get_prop( 'last_name', $context ); |
|
| 862 | + * Get the customer's last name. |
|
| 863 | + * |
|
| 864 | + * @since 1.0.19 |
|
| 865 | + * @param string $context View or edit context. |
|
| 866 | + * @return string |
|
| 867 | + */ |
|
| 868 | + public function get_last_name( $context = 'view' ) { |
|
| 869 | + return $this->get_prop( 'last_name', $context ); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | /** |
| 873 | - * Alias of self::get_last_name(). |
|
| 874 | - * |
|
| 875 | - * @since 1.0.19 |
|
| 876 | - * @param string $context View or edit context. |
|
| 877 | - * @return string |
|
| 878 | - */ |
|
| 879 | - public function get_user_last_name( $context = 'view' ) { |
|
| 880 | - return $this->get_last_name( $context ); |
|
| 873 | + * Alias of self::get_last_name(). |
|
| 874 | + * |
|
| 875 | + * @since 1.0.19 |
|
| 876 | + * @param string $context View or edit context. |
|
| 877 | + * @return string |
|
| 878 | + */ |
|
| 879 | + public function get_user_last_name( $context = 'view' ) { |
|
| 880 | + return $this->get_last_name( $context ); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /** |
| 884 | - * Alias of self::get_last_name(). |
|
| 885 | - * |
|
| 886 | - * @since 1.0.19 |
|
| 887 | - * @param string $context View or edit context. |
|
| 888 | - * @return string |
|
| 889 | - */ |
|
| 890 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 891 | - return $this->get_last_name( $context ); |
|
| 884 | + * Alias of self::get_last_name(). |
|
| 885 | + * |
|
| 886 | + * @since 1.0.19 |
|
| 887 | + * @param string $context View or edit context. |
|
| 888 | + * @return string |
|
| 889 | + */ |
|
| 890 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 891 | + return $this->get_last_name( $context ); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |
| 895 | - * Get the customer's full name. |
|
| 896 | - * |
|
| 897 | - * @since 1.0.19 |
|
| 898 | - * @param string $context View or edit context. |
|
| 899 | - * @return string |
|
| 900 | - */ |
|
| 901 | - public function get_full_name( $context = 'view' ) { |
|
| 902 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 895 | + * Get the customer's full name. |
|
| 896 | + * |
|
| 897 | + * @since 1.0.19 |
|
| 898 | + * @param string $context View or edit context. |
|
| 899 | + * @return string |
|
| 900 | + */ |
|
| 901 | + public function get_full_name( $context = 'view' ) { |
|
| 902 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
| 906 | - * Alias of self::get_full_name(). |
|
| 907 | - * |
|
| 908 | - * @since 1.0.19 |
|
| 909 | - * @param string $context View or edit context. |
|
| 910 | - * @return string |
|
| 911 | - */ |
|
| 912 | - public function get_user_full_name( $context = 'view' ) { |
|
| 913 | - return $this->get_full_name( $context ); |
|
| 906 | + * Alias of self::get_full_name(). |
|
| 907 | + * |
|
| 908 | + * @since 1.0.19 |
|
| 909 | + * @param string $context View or edit context. |
|
| 910 | + * @return string |
|
| 911 | + */ |
|
| 912 | + public function get_user_full_name( $context = 'view' ) { |
|
| 913 | + return $this->get_full_name( $context ); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | /** |
| 917 | - * Alias of self::get_full_name(). |
|
| 918 | - * |
|
| 919 | - * @since 1.0.19 |
|
| 920 | - * @param string $context View or edit context. |
|
| 921 | - * @return string |
|
| 922 | - */ |
|
| 923 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 924 | - return $this->get_full_name( $context ); |
|
| 917 | + * Alias of self::get_full_name(). |
|
| 918 | + * |
|
| 919 | + * @since 1.0.19 |
|
| 920 | + * @param string $context View or edit context. |
|
| 921 | + * @return string |
|
| 922 | + */ |
|
| 923 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 924 | + return $this->get_full_name( $context ); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
| 928 | - * Get the customer's phone number. |
|
| 929 | - * |
|
| 930 | - * @since 1.0.19 |
|
| 931 | - * @param string $context View or edit context. |
|
| 932 | - * @return string |
|
| 933 | - */ |
|
| 934 | - public function get_phone( $context = 'view' ) { |
|
| 935 | - return $this->get_prop( 'phone', $context ); |
|
| 928 | + * Get the customer's phone number. |
|
| 929 | + * |
|
| 930 | + * @since 1.0.19 |
|
| 931 | + * @param string $context View or edit context. |
|
| 932 | + * @return string |
|
| 933 | + */ |
|
| 934 | + public function get_phone( $context = 'view' ) { |
|
| 935 | + return $this->get_prop( 'phone', $context ); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
| 939 | - * Alias of self::get_phone(). |
|
| 940 | - * |
|
| 941 | - * @since 1.0.19 |
|
| 942 | - * @param string $context View or edit context. |
|
| 943 | - * @return string |
|
| 944 | - */ |
|
| 945 | - public function get_phone_number( $context = 'view' ) { |
|
| 946 | - return $this->get_phone( $context ); |
|
| 939 | + * Alias of self::get_phone(). |
|
| 940 | + * |
|
| 941 | + * @since 1.0.19 |
|
| 942 | + * @param string $context View or edit context. |
|
| 943 | + * @return string |
|
| 944 | + */ |
|
| 945 | + public function get_phone_number( $context = 'view' ) { |
|
| 946 | + return $this->get_phone( $context ); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
| 950 | - * Alias of self::get_phone(). |
|
| 951 | - * |
|
| 952 | - * @since 1.0.19 |
|
| 953 | - * @param string $context View or edit context. |
|
| 954 | - * @return string |
|
| 955 | - */ |
|
| 956 | - public function get_user_phone( $context = 'view' ) { |
|
| 957 | - return $this->get_phone( $context ); |
|
| 958 | - } |
|
| 959 | - |
|
| 950 | + * Alias of self::get_phone(). |
|
| 951 | + * |
|
| 952 | + * @since 1.0.19 |
|
| 953 | + * @param string $context View or edit context. |
|
| 954 | + * @return string |
|
| 955 | + */ |
|
| 956 | + public function get_user_phone( $context = 'view' ) { |
|
| 957 | + return $this->get_phone( $context ); |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + /** |
|
| 961 | + * Alias of self::get_phone(). |
|
| 962 | + * |
|
| 963 | + * @since 1.0.19 |
|
| 964 | + * @param string $context View or edit context. |
|
| 965 | + * @return string |
|
| 966 | + */ |
|
| 967 | + public function get_customer_phone( $context = 'view' ) { |
|
| 968 | + return $this->get_phone( $context ); |
|
| 969 | + } |
|
| 970 | + |
|
| 971 | + /** |
|
| 972 | + * Get the customer's email address. |
|
| 973 | + * |
|
| 974 | + * @since 1.0.19 |
|
| 975 | + * @param string $context View or edit context. |
|
| 976 | + * @return string |
|
| 977 | + */ |
|
| 978 | + public function get_email( $context = 'view' ) { |
|
| 979 | + return $this->get_prop( 'email', $context ); |
|
| 980 | + } |
|
| 981 | + |
|
| 982 | + /** |
|
| 983 | + * Alias of self::get_email(). |
|
| 984 | + * |
|
| 985 | + * @since 1.0.19 |
|
| 986 | + * @param string $context View or edit context. |
|
| 987 | + * @return string |
|
| 988 | + */ |
|
| 989 | + public function get_email_address( $context = 'view' ) { |
|
| 990 | + return $this->get_email( $context ); |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + /** |
|
| 994 | + * Alias of self::get_email(). |
|
| 995 | + * |
|
| 996 | + * @since 1.0.19 |
|
| 997 | + * @param string $context View or edit context. |
|
| 998 | + * @return string |
|
| 999 | + */ |
|
| 1000 | + public function get_user_email( $context = 'view' ) { |
|
| 1001 | + return $this->get_email( $context ); |
|
| 1002 | + } |
|
| 1003 | + |
|
| 1004 | + /** |
|
| 1005 | + * Alias of self::get_email(). |
|
| 1006 | + * |
|
| 1007 | + * @since 1.0.19 |
|
| 1008 | + * @param string $context View or edit context. |
|
| 1009 | + * @return string |
|
| 1010 | + */ |
|
| 1011 | + public function get_customer_email( $context = 'view' ) { |
|
| 1012 | + return $this->get_email( $context ); |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + /** |
|
| 1016 | + * Get the customer's country. |
|
| 1017 | + * |
|
| 1018 | + * @since 1.0.19 |
|
| 1019 | + * @param string $context View or edit context. |
|
| 1020 | + * @return string |
|
| 1021 | + */ |
|
| 1022 | + public function get_country( $context = 'view' ) { |
|
| 1023 | + $country = $this->get_prop( 'country', $context ); |
|
| 1024 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + /** |
|
| 1028 | + * Alias of self::get_country(). |
|
| 1029 | + * |
|
| 1030 | + * @since 1.0.19 |
|
| 1031 | + * @param string $context View or edit context. |
|
| 1032 | + * @return string |
|
| 1033 | + */ |
|
| 1034 | + public function get_user_country( $context = 'view' ) { |
|
| 1035 | + return $this->get_country( $context ); |
|
| 1036 | + } |
|
| 1037 | + |
|
| 1038 | + /** |
|
| 1039 | + * Alias of self::get_country(). |
|
| 1040 | + * |
|
| 1041 | + * @since 1.0.19 |
|
| 1042 | + * @param string $context View or edit context. |
|
| 1043 | + * @return string |
|
| 1044 | + */ |
|
| 1045 | + public function get_customer_country( $context = 'view' ) { |
|
| 1046 | + return $this->get_country( $context ); |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * Get the customer's state. |
|
| 1051 | + * |
|
| 1052 | + * @since 1.0.19 |
|
| 1053 | + * @param string $context View or edit context. |
|
| 1054 | + * @return string |
|
| 1055 | + */ |
|
| 1056 | + public function get_state( $context = 'view' ) { |
|
| 1057 | + $state = $this->get_prop( 'state', $context ); |
|
| 1058 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + /** |
|
| 1062 | + * Alias of self::get_state(). |
|
| 1063 | + * |
|
| 1064 | + * @since 1.0.19 |
|
| 1065 | + * @param string $context View or edit context. |
|
| 1066 | + * @return string |
|
| 1067 | + */ |
|
| 1068 | + public function get_user_state( $context = 'view' ) { |
|
| 1069 | + return $this->get_state( $context ); |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + /** |
|
| 1073 | + * Alias of self::get_state(). |
|
| 1074 | + * |
|
| 1075 | + * @since 1.0.19 |
|
| 1076 | + * @param string $context View or edit context. |
|
| 1077 | + * @return string |
|
| 1078 | + */ |
|
| 1079 | + public function get_customer_state( $context = 'view' ) { |
|
| 1080 | + return $this->get_state( $context ); |
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + /** |
|
| 1084 | + * Get the customer's city. |
|
| 1085 | + * |
|
| 1086 | + * @since 1.0.19 |
|
| 1087 | + * @param string $context View or edit context. |
|
| 1088 | + * @return string |
|
| 1089 | + */ |
|
| 1090 | + public function get_city( $context = 'view' ) { |
|
| 1091 | + return $this->get_prop( 'city', $context ); |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + /** |
|
| 1095 | + * Alias of self::get_city(). |
|
| 1096 | + * |
|
| 1097 | + * @since 1.0.19 |
|
| 1098 | + * @param string $context View or edit context. |
|
| 1099 | + * @return string |
|
| 1100 | + */ |
|
| 1101 | + public function get_user_city( $context = 'view' ) { |
|
| 1102 | + return $this->get_city( $context ); |
|
| 1103 | + } |
|
| 1104 | + |
|
| 960 | 1105 | /** |
| 961 | - * Alias of self::get_phone(). |
|
| 962 | - * |
|
| 963 | - * @since 1.0.19 |
|
| 964 | - * @param string $context View or edit context. |
|
| 965 | - * @return string |
|
| 966 | - */ |
|
| 967 | - public function get_customer_phone( $context = 'view' ) { |
|
| 968 | - return $this->get_phone( $context ); |
|
| 1106 | + * Alias of self::get_city(). |
|
| 1107 | + * |
|
| 1108 | + * @since 1.0.19 |
|
| 1109 | + * @param string $context View or edit context. |
|
| 1110 | + * @return string |
|
| 1111 | + */ |
|
| 1112 | + public function get_customer_city( $context = 'view' ) { |
|
| 1113 | + return $this->get_city( $context ); |
|
| 969 | 1114 | } |
| 970 | 1115 | |
| 971 | 1116 | /** |
| 972 | - * Get the customer's email address. |
|
| 973 | - * |
|
| 974 | - * @since 1.0.19 |
|
| 975 | - * @param string $context View or edit context. |
|
| 976 | - * @return string |
|
| 977 | - */ |
|
| 978 | - public function get_email( $context = 'view' ) { |
|
| 979 | - return $this->get_prop( 'email', $context ); |
|
| 1117 | + * Get the customer's zip. |
|
| 1118 | + * |
|
| 1119 | + * @since 1.0.19 |
|
| 1120 | + * @param string $context View or edit context. |
|
| 1121 | + * @return string |
|
| 1122 | + */ |
|
| 1123 | + public function get_zip( $context = 'view' ) { |
|
| 1124 | + return $this->get_prop( 'zip', $context ); |
|
| 980 | 1125 | } |
| 981 | 1126 | |
| 982 | 1127 | /** |
| 983 | - * Alias of self::get_email(). |
|
| 984 | - * |
|
| 985 | - * @since 1.0.19 |
|
| 986 | - * @param string $context View or edit context. |
|
| 987 | - * @return string |
|
| 988 | - */ |
|
| 989 | - public function get_email_address( $context = 'view' ) { |
|
| 990 | - return $this->get_email( $context ); |
|
| 1128 | + * Alias of self::get_zip(). |
|
| 1129 | + * |
|
| 1130 | + * @since 1.0.19 |
|
| 1131 | + * @param string $context View or edit context. |
|
| 1132 | + * @return string |
|
| 1133 | + */ |
|
| 1134 | + public function get_user_zip( $context = 'view' ) { |
|
| 1135 | + return $this->get_zip( $context ); |
|
| 991 | 1136 | } |
| 992 | 1137 | |
| 993 | 1138 | /** |
| 994 | - * Alias of self::get_email(). |
|
| 995 | - * |
|
| 996 | - * @since 1.0.19 |
|
| 997 | - * @param string $context View or edit context. |
|
| 998 | - * @return string |
|
| 999 | - */ |
|
| 1000 | - public function get_user_email( $context = 'view' ) { |
|
| 1001 | - return $this->get_email( $context ); |
|
| 1139 | + * Alias of self::get_zip(). |
|
| 1140 | + * |
|
| 1141 | + * @since 1.0.19 |
|
| 1142 | + * @param string $context View or edit context. |
|
| 1143 | + * @return string |
|
| 1144 | + */ |
|
| 1145 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1146 | + return $this->get_zip( $context ); |
|
| 1002 | 1147 | } |
| 1003 | 1148 | |
| 1004 | 1149 | /** |
| 1005 | - * Alias of self::get_email(). |
|
| 1006 | - * |
|
| 1007 | - * @since 1.0.19 |
|
| 1008 | - * @param string $context View or edit context. |
|
| 1009 | - * @return string |
|
| 1010 | - */ |
|
| 1011 | - public function get_customer_email( $context = 'view' ) { |
|
| 1012 | - return $this->get_email( $context ); |
|
| 1150 | + * Get the customer's company. |
|
| 1151 | + * |
|
| 1152 | + * @since 1.0.19 |
|
| 1153 | + * @param string $context View or edit context. |
|
| 1154 | + * @return string |
|
| 1155 | + */ |
|
| 1156 | + public function get_company( $context = 'view' ) { |
|
| 1157 | + return $this->get_prop( 'company', $context ); |
|
| 1013 | 1158 | } |
| 1014 | 1159 | |
| 1015 | 1160 | /** |
| 1016 | - * Get the customer's country. |
|
| 1017 | - * |
|
| 1018 | - * @since 1.0.19 |
|
| 1019 | - * @param string $context View or edit context. |
|
| 1020 | - * @return string |
|
| 1021 | - */ |
|
| 1022 | - public function get_country( $context = 'view' ) { |
|
| 1023 | - $country = $this->get_prop( 'country', $context ); |
|
| 1024 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1161 | + * Alias of self::get_company(). |
|
| 1162 | + * |
|
| 1163 | + * @since 1.0.19 |
|
| 1164 | + * @param string $context View or edit context. |
|
| 1165 | + * @return string |
|
| 1166 | + */ |
|
| 1167 | + public function get_user_company( $context = 'view' ) { |
|
| 1168 | + return $this->get_company( $context ); |
|
| 1025 | 1169 | } |
| 1026 | 1170 | |
| 1027 | 1171 | /** |
| 1028 | - * Alias of self::get_country(). |
|
| 1029 | - * |
|
| 1030 | - * @since 1.0.19 |
|
| 1031 | - * @param string $context View or edit context. |
|
| 1032 | - * @return string |
|
| 1033 | - */ |
|
| 1034 | - public function get_user_country( $context = 'view' ) { |
|
| 1035 | - return $this->get_country( $context ); |
|
| 1172 | + * Alias of self::get_company(). |
|
| 1173 | + * |
|
| 1174 | + * @since 1.0.19 |
|
| 1175 | + * @param string $context View or edit context. |
|
| 1176 | + * @return string |
|
| 1177 | + */ |
|
| 1178 | + public function get_customer_company( $context = 'view' ) { |
|
| 1179 | + return $this->get_company( $context ); |
|
| 1036 | 1180 | } |
| 1037 | 1181 | |
| 1038 | 1182 | /** |
| 1039 | - * Alias of self::get_country(). |
|
| 1040 | - * |
|
| 1041 | - * @since 1.0.19 |
|
| 1042 | - * @param string $context View or edit context. |
|
| 1043 | - * @return string |
|
| 1044 | - */ |
|
| 1045 | - public function get_customer_country( $context = 'view' ) { |
|
| 1046 | - return $this->get_country( $context ); |
|
| 1183 | + * Get the customer's company id. |
|
| 1184 | + * |
|
| 1185 | + * @since 1.0.19 |
|
| 1186 | + * @param string $context View or edit context. |
|
| 1187 | + * @return string |
|
| 1188 | + */ |
|
| 1189 | + public function get_company_id( $context = 'view' ) { |
|
| 1190 | + return $this->get_prop( 'company_id', $context ); |
|
| 1047 | 1191 | } |
| 1048 | 1192 | |
| 1049 | 1193 | /** |
| 1050 | - * Get the customer's state. |
|
| 1051 | - * |
|
| 1052 | - * @since 1.0.19 |
|
| 1053 | - * @param string $context View or edit context. |
|
| 1054 | - * @return string |
|
| 1055 | - */ |
|
| 1056 | - public function get_state( $context = 'view' ) { |
|
| 1057 | - $state = $this->get_prop( 'state', $context ); |
|
| 1058 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1194 | + * Get the customer's vat number. |
|
| 1195 | + * |
|
| 1196 | + * @since 1.0.19 |
|
| 1197 | + * @param string $context View or edit context. |
|
| 1198 | + * @return string |
|
| 1199 | + */ |
|
| 1200 | + public function get_vat_number( $context = 'view' ) { |
|
| 1201 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1059 | 1202 | } |
| 1060 | 1203 | |
| 1061 | 1204 | /** |
| 1062 | - * Alias of self::get_state(). |
|
| 1063 | - * |
|
| 1064 | - * @since 1.0.19 |
|
| 1065 | - * @param string $context View or edit context. |
|
| 1066 | - * @return string |
|
| 1067 | - */ |
|
| 1068 | - public function get_user_state( $context = 'view' ) { |
|
| 1069 | - return $this->get_state( $context ); |
|
| 1205 | + * Alias of self::get_vat_number(). |
|
| 1206 | + * |
|
| 1207 | + * @since 1.0.19 |
|
| 1208 | + * @param string $context View or edit context. |
|
| 1209 | + * @return string |
|
| 1210 | + */ |
|
| 1211 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1212 | + return $this->get_vat_number( $context ); |
|
| 1070 | 1213 | } |
| 1071 | 1214 | |
| 1072 | 1215 | /** |
| 1073 | - * Alias of self::get_state(). |
|
| 1074 | - * |
|
| 1075 | - * @since 1.0.19 |
|
| 1076 | - * @param string $context View or edit context. |
|
| 1077 | - * @return string |
|
| 1078 | - */ |
|
| 1079 | - public function get_customer_state( $context = 'view' ) { |
|
| 1080 | - return $this->get_state( $context ); |
|
| 1216 | + * Alias of self::get_vat_number(). |
|
| 1217 | + * |
|
| 1218 | + * @since 1.0.19 |
|
| 1219 | + * @param string $context View or edit context. |
|
| 1220 | + * @return string |
|
| 1221 | + */ |
|
| 1222 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1223 | + return $this->get_vat_number( $context ); |
|
| 1081 | 1224 | } |
| 1082 | 1225 | |
| 1083 | 1226 | /** |
| 1084 | - * Get the customer's city. |
|
| 1085 | - * |
|
| 1086 | - * @since 1.0.19 |
|
| 1087 | - * @param string $context View or edit context. |
|
| 1088 | - * @return string |
|
| 1089 | - */ |
|
| 1090 | - public function get_city( $context = 'view' ) { |
|
| 1091 | - return $this->get_prop( 'city', $context ); |
|
| 1227 | + * Get the customer's vat rate. |
|
| 1228 | + * |
|
| 1229 | + * @since 1.0.19 |
|
| 1230 | + * @param string $context View or edit context. |
|
| 1231 | + * @return string |
|
| 1232 | + */ |
|
| 1233 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1234 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1092 | 1235 | } |
| 1093 | 1236 | |
| 1094 | 1237 | /** |
| 1095 | - * Alias of self::get_city(). |
|
| 1096 | - * |
|
| 1097 | - * @since 1.0.19 |
|
| 1098 | - * @param string $context View or edit context. |
|
| 1099 | - * @return string |
|
| 1100 | - */ |
|
| 1101 | - public function get_user_city( $context = 'view' ) { |
|
| 1102 | - return $this->get_city( $context ); |
|
| 1238 | + * Alias of self::get_vat_rate(). |
|
| 1239 | + * |
|
| 1240 | + * @since 1.0.19 |
|
| 1241 | + * @param string $context View or edit context. |
|
| 1242 | + * @return string |
|
| 1243 | + */ |
|
| 1244 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1245 | + return $this->get_vat_rate( $context ); |
|
| 1103 | 1246 | } |
| 1104 | 1247 | |
| 1105 | 1248 | /** |
| 1106 | - * Alias of self::get_city(). |
|
| 1107 | - * |
|
| 1108 | - * @since 1.0.19 |
|
| 1109 | - * @param string $context View or edit context. |
|
| 1110 | - * @return string |
|
| 1111 | - */ |
|
| 1112 | - public function get_customer_city( $context = 'view' ) { |
|
| 1113 | - return $this->get_city( $context ); |
|
| 1249 | + * Alias of self::get_vat_rate(). |
|
| 1250 | + * |
|
| 1251 | + * @since 1.0.19 |
|
| 1252 | + * @param string $context View or edit context. |
|
| 1253 | + * @return string |
|
| 1254 | + */ |
|
| 1255 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1256 | + return $this->get_vat_rate( $context ); |
|
| 1114 | 1257 | } |
| 1115 | 1258 | |
| 1116 | 1259 | /** |
| 1117 | - * Get the customer's zip. |
|
| 1118 | - * |
|
| 1119 | - * @since 1.0.19 |
|
| 1120 | - * @param string $context View or edit context. |
|
| 1121 | - * @return string |
|
| 1122 | - */ |
|
| 1123 | - public function get_zip( $context = 'view' ) { |
|
| 1124 | - return $this->get_prop( 'zip', $context ); |
|
| 1260 | + * Get the customer's address. |
|
| 1261 | + * |
|
| 1262 | + * @since 1.0.19 |
|
| 1263 | + * @param string $context View or edit context. |
|
| 1264 | + * @return string |
|
| 1265 | + */ |
|
| 1266 | + public function get_address( $context = 'view' ) { |
|
| 1267 | + return $this->get_prop( 'address', $context ); |
|
| 1125 | 1268 | } |
| 1126 | 1269 | |
| 1127 | 1270 | /** |
| 1128 | - * Alias of self::get_zip(). |
|
| 1129 | - * |
|
| 1130 | - * @since 1.0.19 |
|
| 1131 | - * @param string $context View or edit context. |
|
| 1132 | - * @return string |
|
| 1133 | - */ |
|
| 1134 | - public function get_user_zip( $context = 'view' ) { |
|
| 1135 | - return $this->get_zip( $context ); |
|
| 1271 | + * Alias of self::get_address(). |
|
| 1272 | + * |
|
| 1273 | + * @since 1.0.19 |
|
| 1274 | + * @param string $context View or edit context. |
|
| 1275 | + * @return string |
|
| 1276 | + */ |
|
| 1277 | + public function get_user_address( $context = 'view' ) { |
|
| 1278 | + return $this->get_address( $context ); |
|
| 1136 | 1279 | } |
| 1137 | 1280 | |
| 1138 | 1281 | /** |
| 1139 | - * Alias of self::get_zip(). |
|
| 1140 | - * |
|
| 1141 | - * @since 1.0.19 |
|
| 1142 | - * @param string $context View or edit context. |
|
| 1143 | - * @return string |
|
| 1144 | - */ |
|
| 1145 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1146 | - return $this->get_zip( $context ); |
|
| 1282 | + * Alias of self::get_address(). |
|
| 1283 | + * |
|
| 1284 | + * @since 1.0.19 |
|
| 1285 | + * @param string $context View or edit context. |
|
| 1286 | + * @return string |
|
| 1287 | + */ |
|
| 1288 | + public function get_customer_address( $context = 'view' ) { |
|
| 1289 | + return $this->get_address( $context ); |
|
| 1147 | 1290 | } |
| 1148 | 1291 | |
| 1149 | 1292 | /** |
| 1150 | - * Get the customer's company. |
|
| 1151 | - * |
|
| 1152 | - * @since 1.0.19 |
|
| 1153 | - * @param string $context View or edit context. |
|
| 1154 | - * @return string |
|
| 1155 | - */ |
|
| 1156 | - public function get_company( $context = 'view' ) { |
|
| 1157 | - return $this->get_prop( 'company', $context ); |
|
| 1293 | + * Get whether the customer has viewed the invoice or not. |
|
| 1294 | + * |
|
| 1295 | + * @since 1.0.19 |
|
| 1296 | + * @param string $context View or edit context. |
|
| 1297 | + * @return bool |
|
| 1298 | + */ |
|
| 1299 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1300 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1158 | 1301 | } |
| 1159 | 1302 | |
| 1160 | 1303 | /** |
| 1161 | - * Alias of self::get_company(). |
|
| 1162 | - * |
|
| 1163 | - * @since 1.0.19 |
|
| 1164 | - * @param string $context View or edit context. |
|
| 1165 | - * @return string |
|
| 1166 | - */ |
|
| 1167 | - public function get_user_company( $context = 'view' ) { |
|
| 1168 | - return $this->get_company( $context ); |
|
| 1304 | + * Get other recipients for invoice communications. |
|
| 1305 | + * |
|
| 1306 | + * @since 1.0.19 |
|
| 1307 | + * @param string $context View or edit context. |
|
| 1308 | + * @return bool |
|
| 1309 | + */ |
|
| 1310 | + public function get_email_cc( $context = 'view' ) { |
|
| 1311 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1169 | 1312 | } |
| 1170 | 1313 | |
| 1171 | 1314 | /** |
| 1172 | - * Alias of self::get_company(). |
|
| 1173 | - * |
|
| 1174 | - * @since 1.0.19 |
|
| 1175 | - * @param string $context View or edit context. |
|
| 1176 | - * @return string |
|
| 1177 | - */ |
|
| 1178 | - public function get_customer_company( $context = 'view' ) { |
|
| 1179 | - return $this->get_company( $context ); |
|
| 1315 | + * Get invoice template. |
|
| 1316 | + * |
|
| 1317 | + * @since 1.0.19 |
|
| 1318 | + * @param string $context View or edit context. |
|
| 1319 | + * @return bool |
|
| 1320 | + */ |
|
| 1321 | + public function get_template( $context = 'view' ) { |
|
| 1322 | + return $this->get_prop( 'template', $context ); |
|
| 1180 | 1323 | } |
| 1181 | 1324 | |
| 1182 | - /** |
|
| 1183 | - * Get the customer's company id. |
|
| 1184 | - * |
|
| 1185 | - * @since 1.0.19 |
|
| 1186 | - * @param string $context View or edit context. |
|
| 1187 | - * @return string |
|
| 1188 | - */ |
|
| 1189 | - public function get_company_id( $context = 'view' ) { |
|
| 1190 | - return $this->get_prop( 'company_id', $context ); |
|
| 1325 | + /** |
|
| 1326 | + * Get invoice source. |
|
| 1327 | + * |
|
| 1328 | + * @since 1.0.19 |
|
| 1329 | + * @param string $context View or edit context. |
|
| 1330 | + * @return bool |
|
| 1331 | + */ |
|
| 1332 | + public function get_created_via( $context = 'view' ) { |
|
| 1333 | + return $this->get_prop( 'created_via', $context ); |
|
| 1191 | 1334 | } |
| 1192 | 1335 | |
| 1193 | 1336 | /** |
| 1194 | - * Get the customer's vat number. |
|
| 1195 | - * |
|
| 1196 | - * @since 1.0.19 |
|
| 1197 | - * @param string $context View or edit context. |
|
| 1198 | - * @return string |
|
| 1199 | - */ |
|
| 1200 | - public function get_vat_number( $context = 'view' ) { |
|
| 1201 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1337 | + * Get whether the customer has confirmed their address. |
|
| 1338 | + * |
|
| 1339 | + * @since 1.0.19 |
|
| 1340 | + * @param string $context View or edit context. |
|
| 1341 | + * @return bool |
|
| 1342 | + */ |
|
| 1343 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1344 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1202 | 1345 | } |
| 1203 | 1346 | |
| 1204 | 1347 | /** |
| 1205 | - * Alias of self::get_vat_number(). |
|
| 1206 | - * |
|
| 1207 | - * @since 1.0.19 |
|
| 1208 | - * @param string $context View or edit context. |
|
| 1209 | - * @return string |
|
| 1210 | - */ |
|
| 1211 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1212 | - return $this->get_vat_number( $context ); |
|
| 1348 | + * Alias of self::get_address_confirmed(). |
|
| 1349 | + * |
|
| 1350 | + * @since 1.0.19 |
|
| 1351 | + * @param string $context View or edit context. |
|
| 1352 | + * @return bool |
|
| 1353 | + */ |
|
| 1354 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1355 | + return $this->get_address_confirmed( $context ); |
|
| 1213 | 1356 | } |
| 1214 | 1357 | |
| 1215 | 1358 | /** |
| 1216 | - * Alias of self::get_vat_number(). |
|
| 1217 | - * |
|
| 1218 | - * @since 1.0.19 |
|
| 1219 | - * @param string $context View or edit context. |
|
| 1220 | - * @return string |
|
| 1221 | - */ |
|
| 1222 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1223 | - return $this->get_vat_number( $context ); |
|
| 1359 | + * Alias of self::get_address(). |
|
| 1360 | + * |
|
| 1361 | + * @since 1.0.19 |
|
| 1362 | + * @param string $context View or edit context. |
|
| 1363 | + * @return bool |
|
| 1364 | + */ |
|
| 1365 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1366 | + return $this->get_address_confirmed( $context ); |
|
| 1224 | 1367 | } |
| 1225 | 1368 | |
| 1226 | - /** |
|
| 1227 | - * Get the customer's vat rate. |
|
| 1228 | - * |
|
| 1229 | - * @since 1.0.19 |
|
| 1230 | - * @param string $context View or edit context. |
|
| 1231 | - * @return string |
|
| 1232 | - */ |
|
| 1233 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1234 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - /** |
|
| 1238 | - * Alias of self::get_vat_rate(). |
|
| 1239 | - * |
|
| 1240 | - * @since 1.0.19 |
|
| 1241 | - * @param string $context View or edit context. |
|
| 1242 | - * @return string |
|
| 1243 | - */ |
|
| 1244 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1245 | - return $this->get_vat_rate( $context ); |
|
| 1246 | - } |
|
| 1247 | - |
|
| 1248 | - /** |
|
| 1249 | - * Alias of self::get_vat_rate(). |
|
| 1250 | - * |
|
| 1251 | - * @since 1.0.19 |
|
| 1252 | - * @param string $context View or edit context. |
|
| 1253 | - * @return string |
|
| 1254 | - */ |
|
| 1255 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1256 | - return $this->get_vat_rate( $context ); |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * Get the customer's address. |
|
| 1261 | - * |
|
| 1262 | - * @since 1.0.19 |
|
| 1263 | - * @param string $context View or edit context. |
|
| 1264 | - * @return string |
|
| 1265 | - */ |
|
| 1266 | - public function get_address( $context = 'view' ) { |
|
| 1267 | - return $this->get_prop( 'address', $context ); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - /** |
|
| 1271 | - * Alias of self::get_address(). |
|
| 1272 | - * |
|
| 1273 | - * @since 1.0.19 |
|
| 1274 | - * @param string $context View or edit context. |
|
| 1275 | - * @return string |
|
| 1276 | - */ |
|
| 1277 | - public function get_user_address( $context = 'view' ) { |
|
| 1278 | - return $this->get_address( $context ); |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - /** |
|
| 1282 | - * Alias of self::get_address(). |
|
| 1283 | - * |
|
| 1284 | - * @since 1.0.19 |
|
| 1285 | - * @param string $context View or edit context. |
|
| 1286 | - * @return string |
|
| 1287 | - */ |
|
| 1288 | - public function get_customer_address( $context = 'view' ) { |
|
| 1289 | - return $this->get_address( $context ); |
|
| 1290 | - } |
|
| 1291 | - |
|
| 1292 | - /** |
|
| 1293 | - * Get whether the customer has viewed the invoice or not. |
|
| 1294 | - * |
|
| 1295 | - * @since 1.0.19 |
|
| 1296 | - * @param string $context View or edit context. |
|
| 1297 | - * @return bool |
|
| 1298 | - */ |
|
| 1299 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1300 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - /** |
|
| 1304 | - * Get other recipients for invoice communications. |
|
| 1305 | - * |
|
| 1306 | - * @since 1.0.19 |
|
| 1307 | - * @param string $context View or edit context. |
|
| 1308 | - * @return bool |
|
| 1309 | - */ |
|
| 1310 | - public function get_email_cc( $context = 'view' ) { |
|
| 1311 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1312 | - } |
|
| 1313 | - |
|
| 1314 | - /** |
|
| 1315 | - * Get invoice template. |
|
| 1316 | - * |
|
| 1317 | - * @since 1.0.19 |
|
| 1318 | - * @param string $context View or edit context. |
|
| 1319 | - * @return bool |
|
| 1320 | - */ |
|
| 1321 | - public function get_template( $context = 'view' ) { |
|
| 1322 | - return $this->get_prop( 'template', $context ); |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - /** |
|
| 1326 | - * Get invoice source. |
|
| 1327 | - * |
|
| 1328 | - * @since 1.0.19 |
|
| 1329 | - * @param string $context View or edit context. |
|
| 1330 | - * @return bool |
|
| 1331 | - */ |
|
| 1332 | - public function get_created_via( $context = 'view' ) { |
|
| 1333 | - return $this->get_prop( 'created_via', $context ); |
|
| 1334 | - } |
|
| 1335 | - |
|
| 1336 | - /** |
|
| 1337 | - * Get whether the customer has confirmed their address. |
|
| 1338 | - * |
|
| 1339 | - * @since 1.0.19 |
|
| 1340 | - * @param string $context View or edit context. |
|
| 1341 | - * @return bool |
|
| 1342 | - */ |
|
| 1343 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1344 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1345 | - } |
|
| 1346 | - |
|
| 1347 | - /** |
|
| 1348 | - * Alias of self::get_address_confirmed(). |
|
| 1349 | - * |
|
| 1350 | - * @since 1.0.19 |
|
| 1351 | - * @param string $context View or edit context. |
|
| 1352 | - * @return bool |
|
| 1353 | - */ |
|
| 1354 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1355 | - return $this->get_address_confirmed( $context ); |
|
| 1356 | - } |
|
| 1357 | - |
|
| 1358 | - /** |
|
| 1359 | - * Alias of self::get_address(). |
|
| 1360 | - * |
|
| 1361 | - * @since 1.0.19 |
|
| 1362 | - * @param string $context View or edit context. |
|
| 1363 | - * @return bool |
|
| 1364 | - */ |
|
| 1365 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1366 | - return $this->get_address_confirmed( $context ); |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - /** |
|
| 1370 | - * Get the invoice subtotal. |
|
| 1371 | - * |
|
| 1372 | - * @since 1.0.19 |
|
| 1373 | - * @param string $context View or edit context. |
|
| 1374 | - * @return float |
|
| 1375 | - */ |
|
| 1376 | - public function get_subtotal( $context = 'view' ) { |
|
| 1369 | + /** |
|
| 1370 | + * Get the invoice subtotal. |
|
| 1371 | + * |
|
| 1372 | + * @since 1.0.19 |
|
| 1373 | + * @param string $context View or edit context. |
|
| 1374 | + * @return float |
|
| 1375 | + */ |
|
| 1376 | + public function get_subtotal( $context = 'view' ) { |
|
| 1377 | 1377 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1378 | 1378 | |
| 1379 | 1379 | // Backwards compatibility. |
@@ -1385,192 +1385,192 @@ discard block |
||
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
| 1388 | - * Get the invoice discount total. |
|
| 1389 | - * |
|
| 1390 | - * @since 1.0.19 |
|
| 1391 | - * @param string $context View or edit context. |
|
| 1392 | - * @return float |
|
| 1393 | - */ |
|
| 1394 | - public function get_total_discount( $context = 'view' ) { |
|
| 1395 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
| 1388 | + * Get the invoice discount total. |
|
| 1389 | + * |
|
| 1390 | + * @since 1.0.19 |
|
| 1391 | + * @param string $context View or edit context. |
|
| 1392 | + * @return float |
|
| 1393 | + */ |
|
| 1394 | + public function get_total_discount( $context = 'view' ) { |
|
| 1395 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | /** |
| 1399 | - * Get the invoice tax total. |
|
| 1400 | - * |
|
| 1401 | - * @since 1.0.19 |
|
| 1402 | - * @param string $context View or edit context. |
|
| 1403 | - * @return float |
|
| 1404 | - */ |
|
| 1405 | - public function get_total_tax( $context = 'view' ) { |
|
| 1406 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
| 1407 | - } |
|
| 1399 | + * Get the invoice tax total. |
|
| 1400 | + * |
|
| 1401 | + * @since 1.0.19 |
|
| 1402 | + * @param string $context View or edit context. |
|
| 1403 | + * @return float |
|
| 1404 | + */ |
|
| 1405 | + public function get_total_tax( $context = 'view' ) { |
|
| 1406 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
| 1407 | + } |
|
| 1408 | 1408 | |
| 1409 | - /** |
|
| 1410 | - * @deprecated |
|
| 1411 | - */ |
|
| 1412 | - public function get_final_tax( $currency = false ) { |
|
| 1413 | - $tax = $this->get_total_tax(); |
|
| 1409 | + /** |
|
| 1410 | + * @deprecated |
|
| 1411 | + */ |
|
| 1412 | + public function get_final_tax( $currency = false ) { |
|
| 1413 | + $tax = $this->get_total_tax(); |
|
| 1414 | 1414 | |
| 1415 | 1415 | if ( $currency ) { |
| 1416 | - return wpinv_price( $tax, $this->get_currency() ); |
|
| 1416 | + return wpinv_price( $tax, $this->get_currency() ); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | return $tax; |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | 1422 | /** |
| 1423 | - * Get the invoice fees total. |
|
| 1424 | - * |
|
| 1425 | - * @since 1.0.19 |
|
| 1426 | - * @param string $context View or edit context. |
|
| 1427 | - * @return float |
|
| 1428 | - */ |
|
| 1429 | - public function get_total_fees( $context = 'view' ) { |
|
| 1430 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
| 1423 | + * Get the invoice fees total. |
|
| 1424 | + * |
|
| 1425 | + * @since 1.0.19 |
|
| 1426 | + * @param string $context View or edit context. |
|
| 1427 | + * @return float |
|
| 1428 | + */ |
|
| 1429 | + public function get_total_fees( $context = 'view' ) { |
|
| 1430 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
| 1431 | + } |
|
| 1432 | + |
|
| 1433 | + /** |
|
| 1434 | + * Alias for self::get_total_fees(). |
|
| 1435 | + * |
|
| 1436 | + * @since 1.0.19 |
|
| 1437 | + * @param string $context View or edit context. |
|
| 1438 | + * @return float |
|
| 1439 | + */ |
|
| 1440 | + public function get_fees_total( $context = 'view' ) { |
|
| 1441 | + return $this->get_total_fees( $context ); |
|
| 1431 | 1442 | } |
| 1432 | 1443 | |
| 1433 | 1444 | /** |
| 1434 | - * Alias for self::get_total_fees(). |
|
| 1435 | - * |
|
| 1436 | - * @since 1.0.19 |
|
| 1437 | - * @param string $context View or edit context. |
|
| 1438 | - * @return float |
|
| 1439 | - */ |
|
| 1440 | - public function get_fees_total( $context = 'view' ) { |
|
| 1441 | - return $this->get_total_fees( $context ); |
|
| 1445 | + * Get the invoice total. |
|
| 1446 | + * |
|
| 1447 | + * @since 1.0.19 |
|
| 1448 | + * @return float |
|
| 1449 | + */ |
|
| 1450 | + public function get_total( $context = 'view' ) { |
|
| 1451 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
| 1442 | 1452 | } |
| 1443 | 1453 | |
| 1444 | 1454 | /** |
| 1445 | - * Get the invoice total. |
|
| 1446 | - * |
|
| 1447 | - * @since 1.0.19 |
|
| 1455 | + * Retrieves the non-recurring total of items. |
|
| 1456 | + * |
|
| 1457 | + * @since 2.3.0 |
|
| 1448 | 1458 | * @return float |
| 1449 | - */ |
|
| 1450 | - public function get_total( $context = 'view' ) { |
|
| 1451 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
| 1452 | - } |
|
| 1453 | - |
|
| 1454 | - /** |
|
| 1455 | - * Retrieves the non-recurring total of items. |
|
| 1456 | - * |
|
| 1457 | - * @since 2.3.0 |
|
| 1458 | - * @return float |
|
| 1459 | - */ |
|
| 1460 | - public function get_non_recurring_total() { |
|
| 1461 | - |
|
| 1462 | - $subtotal = 0; |
|
| 1463 | - foreach ( $this->get_items() as $item ) { |
|
| 1464 | - if ( ! $item->is_recurring() ) { |
|
| 1465 | - $subtotal += $item->get_sub_total(); |
|
| 1466 | - } |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - foreach ( $this->get_fees() as $fee ) { |
|
| 1470 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
| 1471 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 1472 | - } |
|
| 1473 | - } |
|
| 1474 | - |
|
| 1475 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
| 1459 | + */ |
|
| 1460 | + public function get_non_recurring_total() { |
|
| 1461 | + |
|
| 1462 | + $subtotal = 0; |
|
| 1463 | + foreach ( $this->get_items() as $item ) { |
|
| 1464 | + if ( ! $item->is_recurring() ) { |
|
| 1465 | + $subtotal += $item->get_sub_total(); |
|
| 1466 | + } |
|
| 1467 | + } |
|
| 1468 | + |
|
| 1469 | + foreach ( $this->get_fees() as $fee ) { |
|
| 1470 | + if ( empty( $fee['recurring_fee'] ) ) { |
|
| 1471 | + $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 1472 | + } |
|
| 1473 | + } |
|
| 1474 | + |
|
| 1475 | + $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
| 1476 | 1476 | return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
| 1477 | 1477 | |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - /** |
|
| 1481 | - * Get the invoice totals. |
|
| 1482 | - * |
|
| 1483 | - * @since 1.0.19 |
|
| 1480 | + /** |
|
| 1481 | + * Get the invoice totals. |
|
| 1482 | + * |
|
| 1483 | + * @since 1.0.19 |
|
| 1484 | 1484 | * @return array |
| 1485 | - */ |
|
| 1486 | - public function get_totals() { |
|
| 1487 | - return $this->totals; |
|
| 1485 | + */ |
|
| 1486 | + public function get_totals() { |
|
| 1487 | + return $this->totals; |
|
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | 1490 | /** |
| 1491 | - * Get the initial invoice total. |
|
| 1492 | - * |
|
| 1493 | - * @since 1.0.19 |
|
| 1491 | + * Get the initial invoice total. |
|
| 1492 | + * |
|
| 1493 | + * @since 1.0.19 |
|
| 1494 | 1494 | * @param string $context View or edit context. |
| 1495 | 1495 | * @return float |
| 1496 | - */ |
|
| 1496 | + */ |
|
| 1497 | 1497 | public function get_initial_total() { |
| 1498 | 1498 | |
| 1499 | - if ( empty( $this->totals ) ) { |
|
| 1500 | - $this->recalculate_total(); |
|
| 1501 | - } |
|
| 1499 | + if ( empty( $this->totals ) ) { |
|
| 1500 | + $this->recalculate_total(); |
|
| 1501 | + } |
|
| 1502 | 1502 | |
| 1503 | - $tax = $this->totals['tax']['initial']; |
|
| 1504 | - $fee = $this->totals['fee']['initial']; |
|
| 1505 | - $discount = $this->totals['discount']['initial']; |
|
| 1506 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1507 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1503 | + $tax = $this->totals['tax']['initial']; |
|
| 1504 | + $fee = $this->totals['fee']['initial']; |
|
| 1505 | + $discount = $this->totals['discount']['initial']; |
|
| 1506 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1507 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1508 | 1508 | |
| 1509 | - if ( 0 > $total ) { |
|
| 1510 | - $total = 0; |
|
| 1511 | - } |
|
| 1509 | + if ( 0 > $total ) { |
|
| 1510 | + $total = 0; |
|
| 1511 | + } |
|
| 1512 | 1512 | |
| 1513 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1513 | + $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1514 | 1514 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1515 | - } |
|
| 1515 | + } |
|
| 1516 | 1516 | |
| 1517 | - /** |
|
| 1518 | - * Get the recurring invoice total. |
|
| 1519 | - * |
|
| 1520 | - * @since 1.0.19 |
|
| 1517 | + /** |
|
| 1518 | + * Get the recurring invoice total. |
|
| 1519 | + * |
|
| 1520 | + * @since 1.0.19 |
|
| 1521 | 1521 | * @param string $context View or edit context. |
| 1522 | 1522 | * @return float |
| 1523 | - */ |
|
| 1523 | + */ |
|
| 1524 | 1524 | public function get_recurring_total() { |
| 1525 | 1525 | |
| 1526 | - if ( empty( $this->totals ) ) { |
|
| 1527 | - $this->recalculate_total(); |
|
| 1528 | - } |
|
| 1526 | + if ( empty( $this->totals ) ) { |
|
| 1527 | + $this->recalculate_total(); |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | - $tax = $this->totals['tax']['recurring']; |
|
| 1531 | - $fee = $this->totals['fee']['recurring']; |
|
| 1532 | - $discount = $this->totals['discount']['recurring']; |
|
| 1533 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1534 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1530 | + $tax = $this->totals['tax']['recurring']; |
|
| 1531 | + $fee = $this->totals['fee']['recurring']; |
|
| 1532 | + $discount = $this->totals['discount']['recurring']; |
|
| 1533 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1534 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1535 | 1535 | |
| 1536 | - if ( 0 > $total ) { |
|
| 1537 | - $total = 0; |
|
| 1538 | - } |
|
| 1536 | + if ( 0 > $total ) { |
|
| 1537 | + $total = 0; |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1540 | + $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1541 | 1541 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1542 | - } |
|
| 1542 | + } |
|
| 1543 | 1543 | |
| 1544 | - /** |
|
| 1545 | - * Returns recurring payment details. |
|
| 1546 | - * |
|
| 1547 | - * @since 1.0.19 |
|
| 1544 | + /** |
|
| 1545 | + * Returns recurring payment details. |
|
| 1546 | + * |
|
| 1547 | + * @since 1.0.19 |
|
| 1548 | 1548 | * @param string $field Optionally provide a field to return. |
| 1549 | - * @param string $currency Whether to include the currency. |
|
| 1549 | + * @param string $currency Whether to include the currency. |
|
| 1550 | 1550 | * @return float|string |
| 1551 | - */ |
|
| 1551 | + */ |
|
| 1552 | 1552 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1553 | 1553 | |
| 1554 | - // Maybe recalculate totals. |
|
| 1555 | - if ( empty( $this->totals ) ) { |
|
| 1556 | - $this->recalculate_total(); |
|
| 1557 | - } |
|
| 1554 | + // Maybe recalculate totals. |
|
| 1555 | + if ( empty( $this->totals ) ) { |
|
| 1556 | + $this->recalculate_total(); |
|
| 1557 | + } |
|
| 1558 | 1558 | |
| 1559 | - // Prepare recurring totals. |
|
| 1559 | + // Prepare recurring totals. |
|
| 1560 | 1560 | $data = apply_filters( |
| 1561 | - 'wpinv_get_invoice_recurring_details', |
|
| 1562 | - array( |
|
| 1563 | - 'cart_details' => $this->get_cart_details(), |
|
| 1564 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1565 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1566 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1567 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1568 | - 'total' => $this->get_recurring_total(), |
|
| 1569 | - ), |
|
| 1570 | - $this, |
|
| 1571 | - $field, |
|
| 1572 | - $currency |
|
| 1573 | - ); |
|
| 1561 | + 'wpinv_get_invoice_recurring_details', |
|
| 1562 | + array( |
|
| 1563 | + 'cart_details' => $this->get_cart_details(), |
|
| 1564 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1565 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1566 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1567 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1568 | + 'total' => $this->get_recurring_total(), |
|
| 1569 | + ), |
|
| 1570 | + $this, |
|
| 1571 | + $field, |
|
| 1572 | + $currency |
|
| 1573 | + ); |
|
| 1574 | 1574 | |
| 1575 | 1575 | if ( isset( $data[$field] ) ) { |
| 1576 | 1576 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1580,166 +1580,166 @@ discard block |
||
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | /** |
| 1583 | - * Get the invoice fees. |
|
| 1584 | - * |
|
| 1585 | - * @since 1.0.19 |
|
| 1586 | - * @param string $context View or edit context. |
|
| 1587 | - * @return array |
|
| 1588 | - */ |
|
| 1589 | - public function get_fees( $context = 'view' ) { |
|
| 1590 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1583 | + * Get the invoice fees. |
|
| 1584 | + * |
|
| 1585 | + * @since 1.0.19 |
|
| 1586 | + * @param string $context View or edit context. |
|
| 1587 | + * @return array |
|
| 1588 | + */ |
|
| 1589 | + public function get_fees( $context = 'view' ) { |
|
| 1590 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | /** |
| 1594 | - * Get the invoice discounts. |
|
| 1595 | - * |
|
| 1596 | - * @since 1.0.19 |
|
| 1597 | - * @param string $context View or edit context. |
|
| 1598 | - * @return array |
|
| 1599 | - */ |
|
| 1600 | - public function get_discounts( $context = 'view' ) { |
|
| 1601 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1594 | + * Get the invoice discounts. |
|
| 1595 | + * |
|
| 1596 | + * @since 1.0.19 |
|
| 1597 | + * @param string $context View or edit context. |
|
| 1598 | + * @return array |
|
| 1599 | + */ |
|
| 1600 | + public function get_discounts( $context = 'view' ) { |
|
| 1601 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | /** |
| 1605 | - * Get the invoice taxes. |
|
| 1606 | - * |
|
| 1607 | - * @since 1.0.19 |
|
| 1608 | - * @param string $context View or edit context. |
|
| 1609 | - * @return array |
|
| 1610 | - */ |
|
| 1611 | - public function get_taxes( $context = 'view' ) { |
|
| 1612 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1605 | + * Get the invoice taxes. |
|
| 1606 | + * |
|
| 1607 | + * @since 1.0.19 |
|
| 1608 | + * @param string $context View or edit context. |
|
| 1609 | + * @return array |
|
| 1610 | + */ |
|
| 1611 | + public function get_taxes( $context = 'view' ) { |
|
| 1612 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
| 1616 | - * Get the invoice items. |
|
| 1617 | - * |
|
| 1618 | - * @since 1.0.19 |
|
| 1619 | - * @param string $context View or edit context. |
|
| 1620 | - * @return GetPaid_Form_Item[] |
|
| 1621 | - */ |
|
| 1622 | - public function get_items( $context = 'view' ) { |
|
| 1616 | + * Get the invoice items. |
|
| 1617 | + * |
|
| 1618 | + * @since 1.0.19 |
|
| 1619 | + * @param string $context View or edit context. |
|
| 1620 | + * @return GetPaid_Form_Item[] |
|
| 1621 | + */ |
|
| 1622 | + public function get_items( $context = 'view' ) { |
|
| 1623 | 1623 | return $this->get_prop( 'items', $context ); |
| 1624 | - } |
|
| 1624 | + } |
|
| 1625 | 1625 | |
| 1626 | - /** |
|
| 1627 | - * Get the invoice item ids. |
|
| 1628 | - * |
|
| 1629 | - * @since 1.0.19 |
|
| 1630 | - * @return string |
|
| 1631 | - */ |
|
| 1632 | - public function get_item_ids() { |
|
| 1633 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
| 1626 | + /** |
|
| 1627 | + * Get the invoice item ids. |
|
| 1628 | + * |
|
| 1629 | + * @since 1.0.19 |
|
| 1630 | + * @return string |
|
| 1631 | + */ |
|
| 1632 | + public function get_item_ids() { |
|
| 1633 | + return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | /** |
| 1637 | - * Get the invoice's payment form. |
|
| 1638 | - * |
|
| 1639 | - * @since 1.0.19 |
|
| 1640 | - * @param string $context View or edit context. |
|
| 1641 | - * @return int |
|
| 1642 | - */ |
|
| 1643 | - public function get_payment_form( $context = 'view' ) { |
|
| 1644 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1637 | + * Get the invoice's payment form. |
|
| 1638 | + * |
|
| 1639 | + * @since 1.0.19 |
|
| 1640 | + * @param string $context View or edit context. |
|
| 1641 | + * @return int |
|
| 1642 | + */ |
|
| 1643 | + public function get_payment_form( $context = 'view' ) { |
|
| 1644 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | /** |
| 1648 | - * Get the invoice's submission id. |
|
| 1649 | - * |
|
| 1650 | - * @since 1.0.19 |
|
| 1651 | - * @param string $context View or edit context. |
|
| 1652 | - * @return string |
|
| 1653 | - */ |
|
| 1654 | - public function get_submission_id( $context = 'view' ) { |
|
| 1655 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1648 | + * Get the invoice's submission id. |
|
| 1649 | + * |
|
| 1650 | + * @since 1.0.19 |
|
| 1651 | + * @param string $context View or edit context. |
|
| 1652 | + * @return string |
|
| 1653 | + */ |
|
| 1654 | + public function get_submission_id( $context = 'view' ) { |
|
| 1655 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | 1658 | /** |
| 1659 | - * Get the invoice's discount code. |
|
| 1660 | - * |
|
| 1661 | - * @since 1.0.19 |
|
| 1662 | - * @param string $context View or edit context. |
|
| 1663 | - * @return string |
|
| 1664 | - */ |
|
| 1665 | - public function get_discount_code( $context = 'view' ) { |
|
| 1666 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1659 | + * Get the invoice's discount code. |
|
| 1660 | + * |
|
| 1661 | + * @since 1.0.19 |
|
| 1662 | + * @param string $context View or edit context. |
|
| 1663 | + * @return string |
|
| 1664 | + */ |
|
| 1665 | + public function get_discount_code( $context = 'view' ) { |
|
| 1666 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | /** |
| 1670 | - * Get the invoice's gateway. |
|
| 1671 | - * |
|
| 1672 | - * @since 1.0.19 |
|
| 1673 | - * @param string $context View or edit context. |
|
| 1674 | - * @return string |
|
| 1675 | - */ |
|
| 1676 | - public function get_gateway( $context = 'view' ) { |
|
| 1677 | - return $this->get_prop( 'gateway', $context ); |
|
| 1670 | + * Get the invoice's gateway. |
|
| 1671 | + * |
|
| 1672 | + * @since 1.0.19 |
|
| 1673 | + * @param string $context View or edit context. |
|
| 1674 | + * @return string |
|
| 1675 | + */ |
|
| 1676 | + public function get_gateway( $context = 'view' ) { |
|
| 1677 | + return $this->get_prop( 'gateway', $context ); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | 1680 | /** |
| 1681 | - * Get the invoice's gateway display title. |
|
| 1682 | - * |
|
| 1683 | - * @since 1.0.19 |
|
| 1684 | - * @return string |
|
| 1685 | - */ |
|
| 1681 | + * Get the invoice's gateway display title. |
|
| 1682 | + * |
|
| 1683 | + * @since 1.0.19 |
|
| 1684 | + * @return string |
|
| 1685 | + */ |
|
| 1686 | 1686 | public function get_gateway_title() { |
| 1687 | 1687 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1688 | 1688 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | 1691 | /** |
| 1692 | - * Get the invoice's transaction id. |
|
| 1693 | - * |
|
| 1694 | - * @since 1.0.19 |
|
| 1695 | - * @param string $context View or edit context. |
|
| 1696 | - * @return string |
|
| 1697 | - */ |
|
| 1698 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1699 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1692 | + * Get the invoice's transaction id. |
|
| 1693 | + * |
|
| 1694 | + * @since 1.0.19 |
|
| 1695 | + * @param string $context View or edit context. |
|
| 1696 | + * @return string |
|
| 1697 | + */ |
|
| 1698 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1699 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | 1702 | /** |
| 1703 | - * Get the invoice's currency. |
|
| 1704 | - * |
|
| 1705 | - * @since 1.0.19 |
|
| 1706 | - * @param string $context View or edit context. |
|
| 1707 | - * @return string |
|
| 1708 | - */ |
|
| 1709 | - public function get_currency( $context = 'view' ) { |
|
| 1703 | + * Get the invoice's currency. |
|
| 1704 | + * |
|
| 1705 | + * @since 1.0.19 |
|
| 1706 | + * @param string $context View or edit context. |
|
| 1707 | + * @return string |
|
| 1708 | + */ |
|
| 1709 | + public function get_currency( $context = 'view' ) { |
|
| 1710 | 1710 | $currency = $this->get_prop( 'currency', $context ); |
| 1711 | 1711 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
| 1715 | - * Checks if we are charging taxes for this invoice. |
|
| 1716 | - * |
|
| 1717 | - * @since 1.0.19 |
|
| 1718 | - * @param string $context View or edit context. |
|
| 1719 | - * @return bool |
|
| 1720 | - */ |
|
| 1721 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1715 | + * Checks if we are charging taxes for this invoice. |
|
| 1716 | + * |
|
| 1717 | + * @since 1.0.19 |
|
| 1718 | + * @param string $context View or edit context. |
|
| 1719 | + * @return bool |
|
| 1720 | + */ |
|
| 1721 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1722 | 1722 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | /** |
| 1726 | - * Retrieves the subscription id for an invoice. |
|
| 1727 | - * |
|
| 1728 | - * @since 1.0.19 |
|
| 1729 | - * @param string $context View or edit context. |
|
| 1730 | - * @return int |
|
| 1731 | - */ |
|
| 1726 | + * Retrieves the subscription id for an invoice. |
|
| 1727 | + * |
|
| 1728 | + * @since 1.0.19 |
|
| 1729 | + * @param string $context View or edit context. |
|
| 1730 | + * @return int |
|
| 1731 | + */ |
|
| 1732 | 1732 | public function get_subscription_id( $context = 'view' ) { |
| 1733 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1734 | - } |
|
| 1735 | - |
|
| 1736 | - /** |
|
| 1737 | - * Retrieves the remote subscription id for an invoice. |
|
| 1738 | - * |
|
| 1739 | - * @since 1.0.19 |
|
| 1740 | - * @param string $context View or edit context. |
|
| 1741 | - * @return int |
|
| 1742 | - */ |
|
| 1733 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1734 | + } |
|
| 1735 | + |
|
| 1736 | + /** |
|
| 1737 | + * Retrieves the remote subscription id for an invoice. |
|
| 1738 | + * |
|
| 1739 | + * @since 1.0.19 |
|
| 1740 | + * @param string $context View or edit context. |
|
| 1741 | + * @return int |
|
| 1742 | + */ |
|
| 1743 | 1743 | public function get_remote_subscription_id( $context = 'view' ) { |
| 1744 | 1744 | $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
| 1745 | 1745 | |
@@ -1752,12 +1752,12 @@ discard block |
||
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | /** |
| 1755 | - * Retrieves the payment meta for an invoice. |
|
| 1756 | - * |
|
| 1757 | - * @since 1.0.19 |
|
| 1758 | - * @param string $context View or edit context. |
|
| 1759 | - * @return array |
|
| 1760 | - */ |
|
| 1755 | + * Retrieves the payment meta for an invoice. |
|
| 1756 | + * |
|
| 1757 | + * @since 1.0.19 |
|
| 1758 | + * @param string $context View or edit context. |
|
| 1759 | + * @return array |
|
| 1760 | + */ |
|
| 1761 | 1761 | public function get_payment_meta( $context = 'view' ) { |
| 1762 | 1762 | |
| 1763 | 1763 | return array( |
@@ -1777,31 +1777,31 @@ discard block |
||
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | 1779 | /** |
| 1780 | - * Retrieves the cart details for an invoice. |
|
| 1781 | - * |
|
| 1782 | - * @since 1.0.19 |
|
| 1783 | - * @return array |
|
| 1784 | - */ |
|
| 1780 | + * Retrieves the cart details for an invoice. |
|
| 1781 | + * |
|
| 1782 | + * @since 1.0.19 |
|
| 1783 | + * @return array |
|
| 1784 | + */ |
|
| 1785 | 1785 | public function get_cart_details() { |
| 1786 | 1786 | $items = $this->get_items(); |
| 1787 | 1787 | $cart_details = array(); |
| 1788 | 1788 | |
| 1789 | 1789 | foreach ( $items as $item ) { |
| 1790 | - $item->invoice_id = $this->get_id(); |
|
| 1790 | + $item->invoice_id = $this->get_id(); |
|
| 1791 | 1791 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | 1794 | return $cart_details; |
| 1795 | - } |
|
| 1795 | + } |
|
| 1796 | 1796 | |
| 1797 | - /** |
|
| 1798 | - * Retrieves the recurring item. |
|
| 1799 | - * |
|
| 1800 | - * @return null|GetPaid_Form_Item|int |
|
| 1801 | - */ |
|
| 1802 | - public function get_recurring( $object = false ) { |
|
| 1797 | + /** |
|
| 1798 | + * Retrieves the recurring item. |
|
| 1799 | + * |
|
| 1800 | + * @return null|GetPaid_Form_Item|int |
|
| 1801 | + */ |
|
| 1802 | + public function get_recurring( $object = false ) { |
|
| 1803 | 1803 | |
| 1804 | - // Are we returning an object? |
|
| 1804 | + // Are we returning an object? |
|
| 1805 | 1805 | if ( $object ) { |
| 1806 | 1806 | return $this->get_item( $this->recurring_item ); |
| 1807 | 1807 | } |
@@ -1809,114 +1809,114 @@ discard block |
||
| 1809 | 1809 | return $this->recurring_item; |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | - /** |
|
| 1813 | - * Retrieves the subscription name. |
|
| 1814 | - * |
|
| 1815 | - * @since 1.0.19 |
|
| 1816 | - * @return string |
|
| 1817 | - */ |
|
| 1818 | - public function get_subscription_name() { |
|
| 1812 | + /** |
|
| 1813 | + * Retrieves the subscription name. |
|
| 1814 | + * |
|
| 1815 | + * @since 1.0.19 |
|
| 1816 | + * @return string |
|
| 1817 | + */ |
|
| 1818 | + public function get_subscription_name() { |
|
| 1819 | 1819 | |
| 1820 | - // Retrieve the recurring name |
|
| 1820 | + // Retrieve the recurring name |
|
| 1821 | 1821 | $item = $this->get_recurring( true ); |
| 1822 | 1822 | |
| 1823 | - // Abort if it does not exist. |
|
| 1823 | + // Abort if it does not exist. |
|
| 1824 | 1824 | if ( empty( $item ) ) { |
| 1825 | 1825 | return ''; |
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | - // Return the item name. |
|
| 1828 | + // Return the item name. |
|
| 1829 | 1829 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1830 | - } |
|
| 1831 | - |
|
| 1832 | - /** |
|
| 1833 | - * Retrieves the view url. |
|
| 1834 | - * |
|
| 1835 | - * @since 1.0.19 |
|
| 1836 | - * @return string |
|
| 1837 | - */ |
|
| 1838 | - public function get_view_url() { |
|
| 1830 | + } |
|
| 1831 | + |
|
| 1832 | + /** |
|
| 1833 | + * Retrieves the view url. |
|
| 1834 | + * |
|
| 1835 | + * @since 1.0.19 |
|
| 1836 | + * @return string |
|
| 1837 | + */ |
|
| 1838 | + public function get_view_url() { |
|
| 1839 | 1839 | $invoice_url = get_permalink( $this->get_id() ); |
| 1840 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1840 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1841 | 1841 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1842 | - } |
|
| 1842 | + } |
|
| 1843 | 1843 | |
| 1844 | - /** |
|
| 1845 | - * Retrieves the payment url. |
|
| 1846 | - * |
|
| 1847 | - * @since 1.0.19 |
|
| 1848 | - * @return string |
|
| 1849 | - */ |
|
| 1850 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1844 | + /** |
|
| 1845 | + * Retrieves the payment url. |
|
| 1846 | + * |
|
| 1847 | + * @since 1.0.19 |
|
| 1848 | + * @return string |
|
| 1849 | + */ |
|
| 1850 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1851 | 1851 | |
| 1852 | - // Retrieve the checkout url. |
|
| 1852 | + // Retrieve the checkout url. |
|
| 1853 | 1853 | $pay_url = wpinv_get_checkout_uri(); |
| 1854 | 1854 | |
| 1855 | - // Maybe force ssl. |
|
| 1855 | + // Maybe force ssl. |
|
| 1856 | 1856 | if ( is_ssl() ) { |
| 1857 | 1857 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | - // Add the invoice key. |
|
| 1861 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1860 | + // Add the invoice key. |
|
| 1861 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1862 | 1862 | |
| 1863 | - // (Maybe?) add a secret |
|
| 1863 | + // (Maybe?) add a secret |
|
| 1864 | 1864 | if ( $secret ) { |
| 1865 | 1865 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1869 | - } |
|
| 1869 | + } |
|
| 1870 | 1870 | |
| 1871 | - /** |
|
| 1872 | - * Retrieves the receipt url. |
|
| 1873 | - * |
|
| 1874 | - * @since 1.0.19 |
|
| 1875 | - * @return string |
|
| 1876 | - */ |
|
| 1877 | - public function get_receipt_url() { |
|
| 1878 | - |
|
| 1879 | - // Retrieve the checkout url. |
|
| 1871 | + /** |
|
| 1872 | + * Retrieves the receipt url. |
|
| 1873 | + * |
|
| 1874 | + * @since 1.0.19 |
|
| 1875 | + * @return string |
|
| 1876 | + */ |
|
| 1877 | + public function get_receipt_url() { |
|
| 1878 | + |
|
| 1879 | + // Retrieve the checkout url. |
|
| 1880 | 1880 | $receipt_url = wpinv_get_success_page_uri(); |
| 1881 | 1881 | |
| 1882 | - // Maybe force ssl. |
|
| 1882 | + // Maybe force ssl. |
|
| 1883 | 1883 | if ( is_ssl() ) { |
| 1884 | 1884 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - // Add the invoice key. |
|
| 1888 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1887 | + // Add the invoice key. |
|
| 1888 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1889 | 1889 | |
| 1890 | 1890 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1891 | - } |
|
| 1891 | + } |
|
| 1892 | 1892 | |
| 1893 | - /** |
|
| 1894 | - * Retrieves the default status. |
|
| 1895 | - * |
|
| 1896 | - * @since 1.0.19 |
|
| 1897 | - * @return string |
|
| 1898 | - */ |
|
| 1899 | - public function get_default_status() { |
|
| 1900 | - |
|
| 1901 | - $type = $this->get_type(); |
|
| 1902 | - $status = "wpi-$type-pending"; |
|
| 1903 | - return str_replace( '-invoice', '', $status ); |
|
| 1904 | - |
|
| 1905 | - } |
|
| 1906 | - |
|
| 1907 | - /** |
|
| 1908 | - * Magic method for accessing invoice properties. |
|
| 1909 | - * |
|
| 1910 | - * @since 1.0.15 |
|
| 1911 | - * @access public |
|
| 1912 | - * |
|
| 1913 | - * @param string $key Discount data to retrieve |
|
| 1914 | - * @param string $context View or edit context. |
|
| 1915 | - * @return mixed Value of the given invoice property (if set). |
|
| 1916 | - */ |
|
| 1917 | - public function get( $key, $context = 'view' ) { |
|
| 1893 | + /** |
|
| 1894 | + * Retrieves the default status. |
|
| 1895 | + * |
|
| 1896 | + * @since 1.0.19 |
|
| 1897 | + * @return string |
|
| 1898 | + */ |
|
| 1899 | + public function get_default_status() { |
|
| 1900 | + |
|
| 1901 | + $type = $this->get_type(); |
|
| 1902 | + $status = "wpi-$type-pending"; |
|
| 1903 | + return str_replace( '-invoice', '', $status ); |
|
| 1904 | + |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + /** |
|
| 1908 | + * Magic method for accessing invoice properties. |
|
| 1909 | + * |
|
| 1910 | + * @since 1.0.15 |
|
| 1911 | + * @access public |
|
| 1912 | + * |
|
| 1913 | + * @param string $key Discount data to retrieve |
|
| 1914 | + * @param string $context View or edit context. |
|
| 1915 | + * @return mixed Value of the given invoice property (if set). |
|
| 1916 | + */ |
|
| 1917 | + public function get( $key, $context = 'view' ) { |
|
| 1918 | 1918 | return $this->get_prop( $key, $context ); |
| 1919 | - } |
|
| 1919 | + } |
|
| 1920 | 1920 | |
| 1921 | 1921 | /* |
| 1922 | 1922 | |-------------------------------------------------------------------------- |
@@ -1929,130 +1929,130 @@ discard block |
||
| 1929 | 1929 | */ |
| 1930 | 1930 | |
| 1931 | 1931 | /** |
| 1932 | - * Magic method for setting invoice properties. |
|
| 1933 | - * |
|
| 1934 | - * @since 1.0.19 |
|
| 1935 | - * @access public |
|
| 1936 | - * |
|
| 1937 | - * @param string $key Discount data to retrieve |
|
| 1938 | - * @param mixed $value new value. |
|
| 1939 | - * @return mixed Value of the given invoice property (if set). |
|
| 1940 | - */ |
|
| 1941 | - public function set( $key, $value ) { |
|
| 1932 | + * Magic method for setting invoice properties. |
|
| 1933 | + * |
|
| 1934 | + * @since 1.0.19 |
|
| 1935 | + * @access public |
|
| 1936 | + * |
|
| 1937 | + * @param string $key Discount data to retrieve |
|
| 1938 | + * @param mixed $value new value. |
|
| 1939 | + * @return mixed Value of the given invoice property (if set). |
|
| 1940 | + */ |
|
| 1941 | + public function set( $key, $value ) { |
|
| 1942 | 1942 | |
| 1943 | 1943 | $setter = "set_$key"; |
| 1944 | 1944 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1945 | 1945 | $this->{$setter}( $value ); |
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | - } |
|
| 1948 | + } |
|
| 1949 | 1949 | |
| 1950 | - /** |
|
| 1951 | - * Sets item status. |
|
| 1952 | - * |
|
| 1953 | - * @since 1.0.19 |
|
| 1954 | - * @param string $new_status New status. |
|
| 1955 | - * @param string $note Optional note to add. |
|
| 1956 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1957 | - * @return array details of change. |
|
| 1958 | - */ |
|
| 1959 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1960 | - $old_status = $this->get_status(); |
|
| 1950 | + /** |
|
| 1951 | + * Sets item status. |
|
| 1952 | + * |
|
| 1953 | + * @since 1.0.19 |
|
| 1954 | + * @param string $new_status New status. |
|
| 1955 | + * @param string $note Optional note to add. |
|
| 1956 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1957 | + * @return array details of change. |
|
| 1958 | + */ |
|
| 1959 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1960 | + $old_status = $this->get_status(); |
|
| 1961 | 1961 | |
| 1962 | - $statuses = $this->get_all_statuses(); |
|
| 1962 | + $statuses = $this->get_all_statuses(); |
|
| 1963 | 1963 | |
| 1964 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1965 | - unset( $statuses[ 'draft' ] ); |
|
| 1966 | - } |
|
| 1964 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1965 | + unset( $statuses[ 'draft' ] ); |
|
| 1966 | + } |
|
| 1967 | 1967 | |
| 1968 | - $this->set_prop( 'status', $new_status ); |
|
| 1968 | + $this->set_prop( 'status', $new_status ); |
|
| 1969 | 1969 | |
| 1970 | - // If setting the status, ensure it's set to a valid status. |
|
| 1971 | - if ( true === $this->object_read ) { |
|
| 1970 | + // If setting the status, ensure it's set to a valid status. |
|
| 1971 | + if ( true === $this->object_read ) { |
|
| 1972 | 1972 | |
| 1973 | - // Only allow valid new status. |
|
| 1974 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1975 | - $new_status = $this->get_default_status(); |
|
| 1976 | - } |
|
| 1973 | + // Only allow valid new status. |
|
| 1974 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1975 | + $new_status = $this->get_default_status(); |
|
| 1976 | + } |
|
| 1977 | 1977 | |
| 1978 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1979 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1980 | - $old_status = $this->get_default_status(); |
|
| 1981 | - } |
|
| 1978 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1979 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1980 | + $old_status = $this->get_default_status(); |
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1984 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1985 | - $old_status = 'wpi-pending'; |
|
| 1986 | - } |
|
| 1983 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1984 | + if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1985 | + $old_status = 'wpi-pending'; |
|
| 1986 | + } |
|
| 1987 | 1987 | |
| 1988 | - if ( $old_status !== $new_status ) { |
|
| 1989 | - $this->status_transition = array( |
|
| 1990 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1991 | - 'to' => $new_status, |
|
| 1992 | - 'note' => $note, |
|
| 1993 | - 'manual' => (bool) $manual_update, |
|
| 1994 | - ); |
|
| 1988 | + if ( $old_status !== $new_status ) { |
|
| 1989 | + $this->status_transition = array( |
|
| 1990 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1991 | + 'to' => $new_status, |
|
| 1992 | + 'note' => $note, |
|
| 1993 | + 'manual' => (bool) $manual_update, |
|
| 1994 | + ); |
|
| 1995 | 1995 | |
| 1996 | - if ( $manual_update ) { |
|
| 1997 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1998 | - } |
|
| 1996 | + if ( $manual_update ) { |
|
| 1997 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1998 | + } |
|
| 1999 | 1999 | |
| 2000 | - $this->maybe_set_date_paid(); |
|
| 2000 | + $this->maybe_set_date_paid(); |
|
| 2001 | 2001 | |
| 2002 | - } |
|
| 2002 | + } |
|
| 2003 | 2003 | |
| 2004 | - } |
|
| 2004 | + } |
|
| 2005 | 2005 | |
| 2006 | - return array( |
|
| 2007 | - 'from' => $old_status, |
|
| 2008 | - 'to' => $new_status, |
|
| 2009 | - ); |
|
| 2010 | - } |
|
| 2006 | + return array( |
|
| 2007 | + 'from' => $old_status, |
|
| 2008 | + 'to' => $new_status, |
|
| 2009 | + ); |
|
| 2010 | + } |
|
| 2011 | 2011 | |
| 2012 | - /** |
|
| 2013 | - * Maybe set date paid. |
|
| 2014 | - * |
|
| 2015 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 2016 | - * order status. |
|
| 2017 | - * |
|
| 2018 | - * @since 1.0.19 |
|
| 2019 | - */ |
|
| 2020 | - public function maybe_set_date_paid() { |
|
| 2012 | + /** |
|
| 2013 | + * Maybe set date paid. |
|
| 2014 | + * |
|
| 2015 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 2016 | + * order status. |
|
| 2017 | + * |
|
| 2018 | + * @since 1.0.19 |
|
| 2019 | + */ |
|
| 2020 | + public function maybe_set_date_paid() { |
|
| 2021 | 2021 | |
| 2022 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 2023 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 2024 | - } |
|
| 2025 | - } |
|
| 2022 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 2023 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 2024 | + } |
|
| 2025 | + } |
|
| 2026 | 2026 | |
| 2027 | 2027 | /** |
| 2028 | - * Set parent invoice ID. |
|
| 2029 | - * |
|
| 2030 | - * @since 1.0.19 |
|
| 2031 | - */ |
|
| 2032 | - public function set_parent_id( $value ) { |
|
| 2033 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 2034 | - return; |
|
| 2035 | - } |
|
| 2036 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 2028 | + * Set parent invoice ID. |
|
| 2029 | + * |
|
| 2030 | + * @since 1.0.19 |
|
| 2031 | + */ |
|
| 2032 | + public function set_parent_id( $value ) { |
|
| 2033 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 2034 | + return; |
|
| 2035 | + } |
|
| 2036 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | /** |
| 2040 | - * Set plugin version when the invoice was created. |
|
| 2041 | - * |
|
| 2042 | - * @since 1.0.19 |
|
| 2043 | - */ |
|
| 2044 | - public function set_version( $value ) { |
|
| 2045 | - $this->set_prop( 'version', $value ); |
|
| 2040 | + * Set plugin version when the invoice was created. |
|
| 2041 | + * |
|
| 2042 | + * @since 1.0.19 |
|
| 2043 | + */ |
|
| 2044 | + public function set_version( $value ) { |
|
| 2045 | + $this->set_prop( 'version', $value ); |
|
| 2046 | 2046 | } |
| 2047 | - |
|
| 2048 | - /** |
|
| 2049 | - * Set date when the invoice was created. |
|
| 2050 | - * |
|
| 2051 | - * @since 1.0.19 |
|
| 2052 | - * @param string $value Value to set. |
|
| 2047 | + |
|
| 2048 | + /** |
|
| 2049 | + * Set date when the invoice was created. |
|
| 2050 | + * |
|
| 2051 | + * @since 1.0.19 |
|
| 2052 | + * @param string $value Value to set. |
|
| 2053 | 2053 | * @return bool Whether or not the date was set. |
| 2054 | - */ |
|
| 2055 | - public function set_date_created( $value ) { |
|
| 2054 | + */ |
|
| 2055 | + public function set_date_created( $value ) { |
|
| 2056 | 2056 | $date = strtotime( $value ); |
| 2057 | 2057 | |
| 2058 | 2058 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2060,19 +2060,19 @@ discard block |
||
| 2060 | 2060 | return true; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - $this->set_prop( 'date_created', '' ); |
|
| 2064 | - return false; |
|
| 2063 | + $this->set_prop( 'date_created', '' ); |
|
| 2064 | + return false; |
|
| 2065 | 2065 | |
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | /** |
| 2069 | - * Set date invoice due date. |
|
| 2070 | - * |
|
| 2071 | - * @since 1.0.19 |
|
| 2072 | - * @param string $value Value to set. |
|
| 2069 | + * Set date invoice due date. |
|
| 2070 | + * |
|
| 2071 | + * @since 1.0.19 |
|
| 2072 | + * @param string $value Value to set. |
|
| 2073 | 2073 | * @return bool Whether or not the date was set. |
| 2074 | - */ |
|
| 2075 | - public function set_due_date( $value ) { |
|
| 2074 | + */ |
|
| 2075 | + public function set_due_date( $value ) { |
|
| 2076 | 2076 | $date = strtotime( $value ); |
| 2077 | 2077 | |
| 2078 | 2078 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2080,29 +2080,29 @@ discard block |
||
| 2080 | 2080 | return true; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | - $this->set_prop( 'due_date', '' ); |
|
| 2083 | + $this->set_prop( 'due_date', '' ); |
|
| 2084 | 2084 | return false; |
| 2085 | 2085 | |
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | 2088 | /** |
| 2089 | - * Alias of self::set_due_date(). |
|
| 2090 | - * |
|
| 2091 | - * @since 1.0.19 |
|
| 2092 | - * @param string $value New name. |
|
| 2093 | - */ |
|
| 2094 | - public function set_date_due( $value ) { |
|
| 2095 | - $this->set_due_date( $value ); |
|
| 2089 | + * Alias of self::set_due_date(). |
|
| 2090 | + * |
|
| 2091 | + * @since 1.0.19 |
|
| 2092 | + * @param string $value New name. |
|
| 2093 | + */ |
|
| 2094 | + public function set_date_due( $value ) { |
|
| 2095 | + $this->set_due_date( $value ); |
|
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | /** |
| 2099 | - * Set date invoice was completed. |
|
| 2100 | - * |
|
| 2101 | - * @since 1.0.19 |
|
| 2102 | - * @param string $value Value to set. |
|
| 2099 | + * Set date invoice was completed. |
|
| 2100 | + * |
|
| 2101 | + * @since 1.0.19 |
|
| 2102 | + * @param string $value Value to set. |
|
| 2103 | 2103 | * @return bool Whether or not the date was set. |
| 2104 | - */ |
|
| 2105 | - public function set_completed_date( $value ) { |
|
| 2104 | + */ |
|
| 2105 | + public function set_completed_date( $value ) { |
|
| 2106 | 2106 | $date = strtotime( $value ); |
| 2107 | 2107 | |
| 2108 | 2108 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2110,29 +2110,29 @@ discard block |
||
| 2110 | 2110 | return true; |
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | - $this->set_prop( 'completed_date', '' ); |
|
| 2113 | + $this->set_prop( 'completed_date', '' ); |
|
| 2114 | 2114 | return false; |
| 2115 | 2115 | |
| 2116 | 2116 | } |
| 2117 | 2117 | |
| 2118 | 2118 | /** |
| 2119 | - * Alias of self::set_completed_date(). |
|
| 2120 | - * |
|
| 2121 | - * @since 1.0.19 |
|
| 2122 | - * @param string $value New name. |
|
| 2123 | - */ |
|
| 2124 | - public function set_date_completed( $value ) { |
|
| 2125 | - $this->set_completed_date( $value ); |
|
| 2119 | + * Alias of self::set_completed_date(). |
|
| 2120 | + * |
|
| 2121 | + * @since 1.0.19 |
|
| 2122 | + * @param string $value New name. |
|
| 2123 | + */ |
|
| 2124 | + public function set_date_completed( $value ) { |
|
| 2125 | + $this->set_completed_date( $value ); |
|
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | 2128 | /** |
| 2129 | - * Set date when the invoice was last modified. |
|
| 2130 | - * |
|
| 2131 | - * @since 1.0.19 |
|
| 2132 | - * @param string $value Value to set. |
|
| 2129 | + * Set date when the invoice was last modified. |
|
| 2130 | + * |
|
| 2131 | + * @since 1.0.19 |
|
| 2132 | + * @param string $value Value to set. |
|
| 2133 | 2133 | * @return bool Whether or not the date was set. |
| 2134 | - */ |
|
| 2135 | - public function set_date_modified( $value ) { |
|
| 2134 | + */ |
|
| 2135 | + public function set_date_modified( $value ) { |
|
| 2136 | 2136 | $date = strtotime( $value ); |
| 2137 | 2137 | |
| 2138 | 2138 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2140,798 +2140,798 @@ discard block |
||
| 2140 | 2140 | return true; |
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | - $this->set_prop( 'date_modified', '' ); |
|
| 2143 | + $this->set_prop( 'date_modified', '' ); |
|
| 2144 | 2144 | return false; |
| 2145 | 2145 | |
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | 2148 | /** |
| 2149 | - * Set the invoice number. |
|
| 2150 | - * |
|
| 2151 | - * @since 1.0.19 |
|
| 2152 | - * @param string $value New number. |
|
| 2153 | - */ |
|
| 2154 | - public function set_number( $value ) { |
|
| 2149 | + * Set the invoice number. |
|
| 2150 | + * |
|
| 2151 | + * @since 1.0.19 |
|
| 2152 | + * @param string $value New number. |
|
| 2153 | + */ |
|
| 2154 | + public function set_number( $value ) { |
|
| 2155 | 2155 | $number = sanitize_text_field( $value ); |
| 2156 | - $this->set_prop( 'number', $number ); |
|
| 2156 | + $this->set_prop( 'number', $number ); |
|
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | 2159 | /** |
| 2160 | - * Set the invoice type. |
|
| 2161 | - * |
|
| 2162 | - * @since 1.0.19 |
|
| 2163 | - * @param string $value Type. |
|
| 2164 | - */ |
|
| 2165 | - public function set_type( $value ) { |
|
| 2160 | + * Set the invoice type. |
|
| 2161 | + * |
|
| 2162 | + * @since 1.0.19 |
|
| 2163 | + * @param string $value Type. |
|
| 2164 | + */ |
|
| 2165 | + public function set_type( $value ) { |
|
| 2166 | 2166 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2167 | - $this->set_prop( 'type', $type ); |
|
| 2168 | - } |
|
| 2167 | + $this->set_prop( 'type', $type ); |
|
| 2168 | + } |
|
| 2169 | 2169 | |
| 2170 | 2170 | /** |
| 2171 | - * Set the invoice post type. |
|
| 2172 | - * |
|
| 2173 | - * @since 1.0.19 |
|
| 2174 | - * @param string $value Post type. |
|
| 2175 | - */ |
|
| 2176 | - public function set_post_type( $value ) { |
|
| 2171 | + * Set the invoice post type. |
|
| 2172 | + * |
|
| 2173 | + * @since 1.0.19 |
|
| 2174 | + * @param string $value Post type. |
|
| 2175 | + */ |
|
| 2176 | + public function set_post_type( $value ) { |
|
| 2177 | 2177 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2178 | - $this->set_type( $value ); |
|
| 2178 | + $this->set_type( $value ); |
|
| 2179 | 2179 | $this->set_prop( 'post_type', $value ); |
| 2180 | 2180 | } |
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | /** |
| 2184 | - * Set the invoice key. |
|
| 2185 | - * |
|
| 2186 | - * @since 1.0.19 |
|
| 2187 | - * @param string $value New key. |
|
| 2188 | - */ |
|
| 2189 | - public function set_key( $value ) { |
|
| 2184 | + * Set the invoice key. |
|
| 2185 | + * |
|
| 2186 | + * @since 1.0.19 |
|
| 2187 | + * @param string $value New key. |
|
| 2188 | + */ |
|
| 2189 | + public function set_key( $value ) { |
|
| 2190 | 2190 | $key = sanitize_text_field( $value ); |
| 2191 | - $this->set_prop( 'key', $key ); |
|
| 2191 | + $this->set_prop( 'key', $key ); |
|
| 2192 | 2192 | } |
| 2193 | 2193 | |
| 2194 | 2194 | /** |
| 2195 | - * Set the invoice mode. |
|
| 2196 | - * |
|
| 2197 | - * @since 1.0.19 |
|
| 2198 | - * @param string $value mode. |
|
| 2199 | - */ |
|
| 2200 | - public function set_mode( $value ) { |
|
| 2195 | + * Set the invoice mode. |
|
| 2196 | + * |
|
| 2197 | + * @since 1.0.19 |
|
| 2198 | + * @param string $value mode. |
|
| 2199 | + */ |
|
| 2200 | + public function set_mode( $value ) { |
|
| 2201 | 2201 | if ( in_array( $value, array( 'live', 'test' ) ) ) { |
| 2202 | 2202 | $this->set_prop( 'mode', $value ); |
| 2203 | 2203 | } |
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | 2206 | /** |
| 2207 | - * Set the invoice path. |
|
| 2208 | - * |
|
| 2209 | - * @since 1.0.19 |
|
| 2210 | - * @param string $value path. |
|
| 2211 | - */ |
|
| 2212 | - public function set_path( $value ) { |
|
| 2207 | + * Set the invoice path. |
|
| 2208 | + * |
|
| 2209 | + * @since 1.0.19 |
|
| 2210 | + * @param string $value path. |
|
| 2211 | + */ |
|
| 2212 | + public function set_path( $value ) { |
|
| 2213 | 2213 | $this->set_prop( 'path', $value ); |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | /** |
| 2217 | - * Set the invoice name. |
|
| 2218 | - * |
|
| 2219 | - * @since 1.0.19 |
|
| 2220 | - * @param string $value New name. |
|
| 2221 | - */ |
|
| 2222 | - public function set_name( $value ) { |
|
| 2217 | + * Set the invoice name. |
|
| 2218 | + * |
|
| 2219 | + * @since 1.0.19 |
|
| 2220 | + * @param string $value New name. |
|
| 2221 | + */ |
|
| 2222 | + public function set_name( $value ) { |
|
| 2223 | 2223 | $name = sanitize_text_field( $value ); |
| 2224 | - $this->set_prop( 'name', $name ); |
|
| 2224 | + $this->set_prop( 'name', $name ); |
|
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | /** |
| 2228 | - * Alias of self::set_name(). |
|
| 2229 | - * |
|
| 2230 | - * @since 1.0.19 |
|
| 2231 | - * @param string $value New name. |
|
| 2232 | - */ |
|
| 2233 | - public function set_title( $value ) { |
|
| 2234 | - $this->set_name( $value ); |
|
| 2228 | + * Alias of self::set_name(). |
|
| 2229 | + * |
|
| 2230 | + * @since 1.0.19 |
|
| 2231 | + * @param string $value New name. |
|
| 2232 | + */ |
|
| 2233 | + public function set_title( $value ) { |
|
| 2234 | + $this->set_name( $value ); |
|
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | 2237 | /** |
| 2238 | - * Set the invoice description. |
|
| 2239 | - * |
|
| 2240 | - * @since 1.0.19 |
|
| 2241 | - * @param string $value New description. |
|
| 2242 | - */ |
|
| 2243 | - public function set_description( $value ) { |
|
| 2238 | + * Set the invoice description. |
|
| 2239 | + * |
|
| 2240 | + * @since 1.0.19 |
|
| 2241 | + * @param string $value New description. |
|
| 2242 | + */ |
|
| 2243 | + public function set_description( $value ) { |
|
| 2244 | 2244 | $description = wp_kses_post( $value ); |
| 2245 | - $this->set_prop( 'description', $description ); |
|
| 2245 | + $this->set_prop( 'description', $description ); |
|
| 2246 | + } |
|
| 2247 | + |
|
| 2248 | + /** |
|
| 2249 | + * Alias of self::set_description(). |
|
| 2250 | + * |
|
| 2251 | + * @since 1.0.19 |
|
| 2252 | + * @param string $value New description. |
|
| 2253 | + */ |
|
| 2254 | + public function set_excerpt( $value ) { |
|
| 2255 | + $this->set_description( $value ); |
|
| 2256 | + } |
|
| 2257 | + |
|
| 2258 | + /** |
|
| 2259 | + * Alias of self::set_description(). |
|
| 2260 | + * |
|
| 2261 | + * @since 1.0.19 |
|
| 2262 | + * @param string $value New description. |
|
| 2263 | + */ |
|
| 2264 | + public function set_summary( $value ) { |
|
| 2265 | + $this->set_description( $value ); |
|
| 2266 | + } |
|
| 2267 | + |
|
| 2268 | + /** |
|
| 2269 | + * Set the receiver of the invoice. |
|
| 2270 | + * |
|
| 2271 | + * @since 1.0.19 |
|
| 2272 | + * @param int $value New author. |
|
| 2273 | + */ |
|
| 2274 | + public function set_author( $value ) { |
|
| 2275 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2276 | + |
|
| 2277 | + if ( $user && $user->ID ) { |
|
| 2278 | + $this->set_prop( 'author', $user->ID ); |
|
| 2279 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2280 | + } |
|
| 2281 | + |
|
| 2282 | + } |
|
| 2283 | + |
|
| 2284 | + /** |
|
| 2285 | + * Alias of self::set_author(). |
|
| 2286 | + * |
|
| 2287 | + * @since 1.0.19 |
|
| 2288 | + * @param int $value New user id. |
|
| 2289 | + */ |
|
| 2290 | + public function set_user_id( $value ) { |
|
| 2291 | + $this->set_author( $value ); |
|
| 2292 | + } |
|
| 2293 | + |
|
| 2294 | + /** |
|
| 2295 | + * Alias of self::set_author(). |
|
| 2296 | + * |
|
| 2297 | + * @since 1.0.19 |
|
| 2298 | + * @param int $value New user id. |
|
| 2299 | + */ |
|
| 2300 | + public function set_customer_id( $value ) { |
|
| 2301 | + $this->set_author( $value ); |
|
| 2302 | + } |
|
| 2303 | + |
|
| 2304 | + /** |
|
| 2305 | + * Set the customer's ip. |
|
| 2306 | + * |
|
| 2307 | + * @since 1.0.19 |
|
| 2308 | + * @param string $value ip address. |
|
| 2309 | + */ |
|
| 2310 | + public function set_ip( $value ) { |
|
| 2311 | + $this->set_prop( 'ip', $value ); |
|
| 2312 | + } |
|
| 2313 | + |
|
| 2314 | + /** |
|
| 2315 | + * Alias of self::set_ip(). |
|
| 2316 | + * |
|
| 2317 | + * @since 1.0.19 |
|
| 2318 | + * @param string $value ip address. |
|
| 2319 | + */ |
|
| 2320 | + public function set_user_ip( $value ) { |
|
| 2321 | + $this->set_ip( $value ); |
|
| 2322 | + } |
|
| 2323 | + |
|
| 2324 | + /** |
|
| 2325 | + * Set the customer's first name. |
|
| 2326 | + * |
|
| 2327 | + * @since 1.0.19 |
|
| 2328 | + * @param string $value first name. |
|
| 2329 | + */ |
|
| 2330 | + public function set_first_name( $value ) { |
|
| 2331 | + $this->set_prop( 'first_name', $value ); |
|
| 2332 | + } |
|
| 2333 | + |
|
| 2334 | + /** |
|
| 2335 | + * Alias of self::set_first_name(). |
|
| 2336 | + * |
|
| 2337 | + * @since 1.0.19 |
|
| 2338 | + * @param string $value first name. |
|
| 2339 | + */ |
|
| 2340 | + public function set_user_first_name( $value ) { |
|
| 2341 | + $this->set_first_name( $value ); |
|
| 2342 | + } |
|
| 2343 | + |
|
| 2344 | + /** |
|
| 2345 | + * Alias of self::set_first_name(). |
|
| 2346 | + * |
|
| 2347 | + * @since 1.0.19 |
|
| 2348 | + * @param string $value first name. |
|
| 2349 | + */ |
|
| 2350 | + public function set_customer_first_name( $value ) { |
|
| 2351 | + $this->set_first_name( $value ); |
|
| 2352 | + } |
|
| 2353 | + |
|
| 2354 | + /** |
|
| 2355 | + * Set the customer's last name. |
|
| 2356 | + * |
|
| 2357 | + * @since 1.0.19 |
|
| 2358 | + * @param string $value last name. |
|
| 2359 | + */ |
|
| 2360 | + public function set_last_name( $value ) { |
|
| 2361 | + $this->set_prop( 'last_name', $value ); |
|
| 2362 | + } |
|
| 2363 | + |
|
| 2364 | + /** |
|
| 2365 | + * Alias of self::set_last_name(). |
|
| 2366 | + * |
|
| 2367 | + * @since 1.0.19 |
|
| 2368 | + * @param string $value last name. |
|
| 2369 | + */ |
|
| 2370 | + public function set_user_last_name( $value ) { |
|
| 2371 | + $this->set_last_name( $value ); |
|
| 2372 | + } |
|
| 2373 | + |
|
| 2374 | + /** |
|
| 2375 | + * Alias of self::set_last_name(). |
|
| 2376 | + * |
|
| 2377 | + * @since 1.0.19 |
|
| 2378 | + * @param string $value last name. |
|
| 2379 | + */ |
|
| 2380 | + public function set_customer_last_name( $value ) { |
|
| 2381 | + $this->set_last_name( $value ); |
|
| 2246 | 2382 | } |
| 2247 | 2383 | |
| 2248 | 2384 | /** |
| 2249 | - * Alias of self::set_description(). |
|
| 2250 | - * |
|
| 2251 | - * @since 1.0.19 |
|
| 2252 | - * @param string $value New description. |
|
| 2253 | - */ |
|
| 2254 | - public function set_excerpt( $value ) { |
|
| 2255 | - $this->set_description( $value ); |
|
| 2385 | + * Set the customer's phone number. |
|
| 2386 | + * |
|
| 2387 | + * @since 1.0.19 |
|
| 2388 | + * @param string $value phone. |
|
| 2389 | + */ |
|
| 2390 | + public function set_phone( $value ) { |
|
| 2391 | + $this->set_prop( 'phone', $value ); |
|
| 2256 | 2392 | } |
| 2257 | 2393 | |
| 2258 | 2394 | /** |
| 2259 | - * Alias of self::set_description(). |
|
| 2260 | - * |
|
| 2261 | - * @since 1.0.19 |
|
| 2262 | - * @param string $value New description. |
|
| 2263 | - */ |
|
| 2264 | - public function set_summary( $value ) { |
|
| 2265 | - $this->set_description( $value ); |
|
| 2395 | + * Alias of self::set_phone(). |
|
| 2396 | + * |
|
| 2397 | + * @since 1.0.19 |
|
| 2398 | + * @param string $value phone. |
|
| 2399 | + */ |
|
| 2400 | + public function set_user_phone( $value ) { |
|
| 2401 | + $this->set_phone( $value ); |
|
| 2266 | 2402 | } |
| 2267 | 2403 | |
| 2268 | 2404 | /** |
| 2269 | - * Set the receiver of the invoice. |
|
| 2270 | - * |
|
| 2271 | - * @since 1.0.19 |
|
| 2272 | - * @param int $value New author. |
|
| 2273 | - */ |
|
| 2274 | - public function set_author( $value ) { |
|
| 2275 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2405 | + * Alias of self::set_phone(). |
|
| 2406 | + * |
|
| 2407 | + * @since 1.0.19 |
|
| 2408 | + * @param string $value phone. |
|
| 2409 | + */ |
|
| 2410 | + public function set_customer_phone( $value ) { |
|
| 2411 | + $this->set_phone( $value ); |
|
| 2412 | + } |
|
| 2276 | 2413 | |
| 2277 | - if ( $user && $user->ID ) { |
|
| 2278 | - $this->set_prop( 'author', $user->ID ); |
|
| 2279 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2280 | - } |
|
| 2414 | + /** |
|
| 2415 | + * Alias of self::set_phone(). |
|
| 2416 | + * |
|
| 2417 | + * @since 1.0.19 |
|
| 2418 | + * @param string $value phone. |
|
| 2419 | + */ |
|
| 2420 | + public function set_phone_number( $value ) { |
|
| 2421 | + $this->set_phone( $value ); |
|
| 2422 | + } |
|
| 2281 | 2423 | |
| 2424 | + /** |
|
| 2425 | + * Set the customer's email address. |
|
| 2426 | + * |
|
| 2427 | + * @since 1.0.19 |
|
| 2428 | + * @param string $value email address. |
|
| 2429 | + */ |
|
| 2430 | + public function set_email( $value ) { |
|
| 2431 | + $this->set_prop( 'email', $value ); |
|
| 2282 | 2432 | } |
| 2283 | 2433 | |
| 2284 | 2434 | /** |
| 2285 | - * Alias of self::set_author(). |
|
| 2286 | - * |
|
| 2287 | - * @since 1.0.19 |
|
| 2288 | - * @param int $value New user id. |
|
| 2289 | - */ |
|
| 2290 | - public function set_user_id( $value ) { |
|
| 2291 | - $this->set_author( $value ); |
|
| 2435 | + * Alias of self::set_email(). |
|
| 2436 | + * |
|
| 2437 | + * @since 1.0.19 |
|
| 2438 | + * @param string $value email address. |
|
| 2439 | + */ |
|
| 2440 | + public function set_user_email( $value ) { |
|
| 2441 | + $this->set_email( $value ); |
|
| 2292 | 2442 | } |
| 2293 | 2443 | |
| 2294 | 2444 | /** |
| 2295 | - * Alias of self::set_author(). |
|
| 2296 | - * |
|
| 2297 | - * @since 1.0.19 |
|
| 2298 | - * @param int $value New user id. |
|
| 2299 | - */ |
|
| 2300 | - public function set_customer_id( $value ) { |
|
| 2301 | - $this->set_author( $value ); |
|
| 2445 | + * Alias of self::set_email(). |
|
| 2446 | + * |
|
| 2447 | + * @since 1.0.19 |
|
| 2448 | + * @param string $value email address. |
|
| 2449 | + */ |
|
| 2450 | + public function set_email_address( $value ) { |
|
| 2451 | + $this->set_email( $value ); |
|
| 2302 | 2452 | } |
| 2303 | 2453 | |
| 2304 | 2454 | /** |
| 2305 | - * Set the customer's ip. |
|
| 2306 | - * |
|
| 2307 | - * @since 1.0.19 |
|
| 2308 | - * @param string $value ip address. |
|
| 2309 | - */ |
|
| 2310 | - public function set_ip( $value ) { |
|
| 2311 | - $this->set_prop( 'ip', $value ); |
|
| 2455 | + * Alias of self::set_email(). |
|
| 2456 | + * |
|
| 2457 | + * @since 1.0.19 |
|
| 2458 | + * @param string $value email address. |
|
| 2459 | + */ |
|
| 2460 | + public function set_customer_email( $value ) { |
|
| 2461 | + $this->set_email( $value ); |
|
| 2312 | 2462 | } |
| 2313 | 2463 | |
| 2314 | 2464 | /** |
| 2315 | - * Alias of self::set_ip(). |
|
| 2316 | - * |
|
| 2317 | - * @since 1.0.19 |
|
| 2318 | - * @param string $value ip address. |
|
| 2319 | - */ |
|
| 2320 | - public function set_user_ip( $value ) { |
|
| 2321 | - $this->set_ip( $value ); |
|
| 2465 | + * Set the customer's country. |
|
| 2466 | + * |
|
| 2467 | + * @since 1.0.19 |
|
| 2468 | + * @param string $value country. |
|
| 2469 | + */ |
|
| 2470 | + public function set_country( $value ) { |
|
| 2471 | + $this->set_prop( 'country', $value ); |
|
| 2322 | 2472 | } |
| 2323 | 2473 | |
| 2324 | 2474 | /** |
| 2325 | - * Set the customer's first name. |
|
| 2326 | - * |
|
| 2327 | - * @since 1.0.19 |
|
| 2328 | - * @param string $value first name. |
|
| 2329 | - */ |
|
| 2330 | - public function set_first_name( $value ) { |
|
| 2331 | - $this->set_prop( 'first_name', $value ); |
|
| 2475 | + * Alias of self::set_country(). |
|
| 2476 | + * |
|
| 2477 | + * @since 1.0.19 |
|
| 2478 | + * @param string $value country. |
|
| 2479 | + */ |
|
| 2480 | + public function set_user_country( $value ) { |
|
| 2481 | + $this->set_country( $value ); |
|
| 2332 | 2482 | } |
| 2333 | 2483 | |
| 2334 | 2484 | /** |
| 2335 | - * Alias of self::set_first_name(). |
|
| 2336 | - * |
|
| 2337 | - * @since 1.0.19 |
|
| 2338 | - * @param string $value first name. |
|
| 2339 | - */ |
|
| 2340 | - public function set_user_first_name( $value ) { |
|
| 2341 | - $this->set_first_name( $value ); |
|
| 2485 | + * Alias of self::set_country(). |
|
| 2486 | + * |
|
| 2487 | + * @since 1.0.19 |
|
| 2488 | + * @param string $value country. |
|
| 2489 | + */ |
|
| 2490 | + public function set_customer_country( $value ) { |
|
| 2491 | + $this->set_country( $value ); |
|
| 2342 | 2492 | } |
| 2343 | 2493 | |
| 2344 | 2494 | /** |
| 2345 | - * Alias of self::set_first_name(). |
|
| 2346 | - * |
|
| 2347 | - * @since 1.0.19 |
|
| 2348 | - * @param string $value first name. |
|
| 2349 | - */ |
|
| 2350 | - public function set_customer_first_name( $value ) { |
|
| 2351 | - $this->set_first_name( $value ); |
|
| 2495 | + * Set the customer's state. |
|
| 2496 | + * |
|
| 2497 | + * @since 1.0.19 |
|
| 2498 | + * @param string $value state. |
|
| 2499 | + */ |
|
| 2500 | + public function set_state( $value ) { |
|
| 2501 | + $this->set_prop( 'state', $value ); |
|
| 2352 | 2502 | } |
| 2353 | 2503 | |
| 2354 | 2504 | /** |
| 2355 | - * Set the customer's last name. |
|
| 2356 | - * |
|
| 2357 | - * @since 1.0.19 |
|
| 2358 | - * @param string $value last name. |
|
| 2359 | - */ |
|
| 2360 | - public function set_last_name( $value ) { |
|
| 2361 | - $this->set_prop( 'last_name', $value ); |
|
| 2505 | + * Alias of self::set_state(). |
|
| 2506 | + * |
|
| 2507 | + * @since 1.0.19 |
|
| 2508 | + * @param string $value state. |
|
| 2509 | + */ |
|
| 2510 | + public function set_user_state( $value ) { |
|
| 2511 | + $this->set_state( $value ); |
|
| 2362 | 2512 | } |
| 2363 | 2513 | |
| 2364 | 2514 | /** |
| 2365 | - * Alias of self::set_last_name(). |
|
| 2366 | - * |
|
| 2367 | - * @since 1.0.19 |
|
| 2368 | - * @param string $value last name. |
|
| 2369 | - */ |
|
| 2370 | - public function set_user_last_name( $value ) { |
|
| 2371 | - $this->set_last_name( $value ); |
|
| 2515 | + * Alias of self::set_state(). |
|
| 2516 | + * |
|
| 2517 | + * @since 1.0.19 |
|
| 2518 | + * @param string $value state. |
|
| 2519 | + */ |
|
| 2520 | + public function set_customer_state( $value ) { |
|
| 2521 | + $this->set_state( $value ); |
|
| 2372 | 2522 | } |
| 2373 | 2523 | |
| 2374 | 2524 | /** |
| 2375 | - * Alias of self::set_last_name(). |
|
| 2376 | - * |
|
| 2377 | - * @since 1.0.19 |
|
| 2378 | - * @param string $value last name. |
|
| 2379 | - */ |
|
| 2380 | - public function set_customer_last_name( $value ) { |
|
| 2381 | - $this->set_last_name( $value ); |
|
| 2525 | + * Set the customer's city. |
|
| 2526 | + * |
|
| 2527 | + * @since 1.0.19 |
|
| 2528 | + * @param string $value city. |
|
| 2529 | + */ |
|
| 2530 | + public function set_city( $value ) { |
|
| 2531 | + $this->set_prop( 'city', $value ); |
|
| 2382 | 2532 | } |
| 2383 | 2533 | |
| 2384 | 2534 | /** |
| 2385 | - * Set the customer's phone number. |
|
| 2386 | - * |
|
| 2387 | - * @since 1.0.19 |
|
| 2388 | - * @param string $value phone. |
|
| 2389 | - */ |
|
| 2390 | - public function set_phone( $value ) { |
|
| 2391 | - $this->set_prop( 'phone', $value ); |
|
| 2535 | + * Alias of self::set_city(). |
|
| 2536 | + * |
|
| 2537 | + * @since 1.0.19 |
|
| 2538 | + * @param string $value city. |
|
| 2539 | + */ |
|
| 2540 | + public function set_user_city( $value ) { |
|
| 2541 | + $this->set_city( $value ); |
|
| 2392 | 2542 | } |
| 2393 | 2543 | |
| 2394 | 2544 | /** |
| 2395 | - * Alias of self::set_phone(). |
|
| 2396 | - * |
|
| 2397 | - * @since 1.0.19 |
|
| 2398 | - * @param string $value phone. |
|
| 2399 | - */ |
|
| 2400 | - public function set_user_phone( $value ) { |
|
| 2401 | - $this->set_phone( $value ); |
|
| 2545 | + * Alias of self::set_city(). |
|
| 2546 | + * |
|
| 2547 | + * @since 1.0.19 |
|
| 2548 | + * @param string $value city. |
|
| 2549 | + */ |
|
| 2550 | + public function set_customer_city( $value ) { |
|
| 2551 | + $this->set_city( $value ); |
|
| 2402 | 2552 | } |
| 2403 | 2553 | |
| 2404 | 2554 | /** |
| 2405 | - * Alias of self::set_phone(). |
|
| 2406 | - * |
|
| 2407 | - * @since 1.0.19 |
|
| 2408 | - * @param string $value phone. |
|
| 2409 | - */ |
|
| 2410 | - public function set_customer_phone( $value ) { |
|
| 2411 | - $this->set_phone( $value ); |
|
| 2555 | + * Set the customer's zip code. |
|
| 2556 | + * |
|
| 2557 | + * @since 1.0.19 |
|
| 2558 | + * @param string $value zip. |
|
| 2559 | + */ |
|
| 2560 | + public function set_zip( $value ) { |
|
| 2561 | + $this->set_prop( 'zip', $value ); |
|
| 2412 | 2562 | } |
| 2413 | 2563 | |
| 2414 | 2564 | /** |
| 2415 | - * Alias of self::set_phone(). |
|
| 2416 | - * |
|
| 2417 | - * @since 1.0.19 |
|
| 2418 | - * @param string $value phone. |
|
| 2419 | - */ |
|
| 2420 | - public function set_phone_number( $value ) { |
|
| 2421 | - $this->set_phone( $value ); |
|
| 2565 | + * Alias of self::set_zip(). |
|
| 2566 | + * |
|
| 2567 | + * @since 1.0.19 |
|
| 2568 | + * @param string $value zip. |
|
| 2569 | + */ |
|
| 2570 | + public function set_user_zip( $value ) { |
|
| 2571 | + $this->set_zip( $value ); |
|
| 2422 | 2572 | } |
| 2423 | 2573 | |
| 2424 | 2574 | /** |
| 2425 | - * Set the customer's email address. |
|
| 2426 | - * |
|
| 2427 | - * @since 1.0.19 |
|
| 2428 | - * @param string $value email address. |
|
| 2429 | - */ |
|
| 2430 | - public function set_email( $value ) { |
|
| 2431 | - $this->set_prop( 'email', $value ); |
|
| 2575 | + * Alias of self::set_zip(). |
|
| 2576 | + * |
|
| 2577 | + * @since 1.0.19 |
|
| 2578 | + * @param string $value zip. |
|
| 2579 | + */ |
|
| 2580 | + public function set_customer_zip( $value ) { |
|
| 2581 | + $this->set_zip( $value ); |
|
| 2432 | 2582 | } |
| 2433 | 2583 | |
| 2434 | 2584 | /** |
| 2435 | - * Alias of self::set_email(). |
|
| 2436 | - * |
|
| 2437 | - * @since 1.0.19 |
|
| 2438 | - * @param string $value email address. |
|
| 2439 | - */ |
|
| 2440 | - public function set_user_email( $value ) { |
|
| 2441 | - $this->set_email( $value ); |
|
| 2585 | + * Set the customer's company. |
|
| 2586 | + * |
|
| 2587 | + * @since 1.0.19 |
|
| 2588 | + * @param string $value company. |
|
| 2589 | + */ |
|
| 2590 | + public function set_company( $value ) { |
|
| 2591 | + $this->set_prop( 'company', $value ); |
|
| 2442 | 2592 | } |
| 2443 | 2593 | |
| 2444 | 2594 | /** |
| 2445 | - * Alias of self::set_email(). |
|
| 2446 | - * |
|
| 2447 | - * @since 1.0.19 |
|
| 2448 | - * @param string $value email address. |
|
| 2449 | - */ |
|
| 2450 | - public function set_email_address( $value ) { |
|
| 2451 | - $this->set_email( $value ); |
|
| 2595 | + * Alias of self::set_company(). |
|
| 2596 | + * |
|
| 2597 | + * @since 1.0.19 |
|
| 2598 | + * @param string $value company. |
|
| 2599 | + */ |
|
| 2600 | + public function set_user_company( $value ) { |
|
| 2601 | + $this->set_company( $value ); |
|
| 2452 | 2602 | } |
| 2453 | 2603 | |
| 2454 | 2604 | /** |
| 2455 | - * Alias of self::set_email(). |
|
| 2456 | - * |
|
| 2457 | - * @since 1.0.19 |
|
| 2458 | - * @param string $value email address. |
|
| 2459 | - */ |
|
| 2460 | - public function set_customer_email( $value ) { |
|
| 2461 | - $this->set_email( $value ); |
|
| 2605 | + * Alias of self::set_company(). |
|
| 2606 | + * |
|
| 2607 | + * @since 1.0.19 |
|
| 2608 | + * @param string $value company. |
|
| 2609 | + */ |
|
| 2610 | + public function set_customer_company( $value ) { |
|
| 2611 | + $this->set_company( $value ); |
|
| 2462 | 2612 | } |
| 2463 | 2613 | |
| 2464 | 2614 | /** |
| 2465 | - * Set the customer's country. |
|
| 2466 | - * |
|
| 2467 | - * @since 1.0.19 |
|
| 2468 | - * @param string $value country. |
|
| 2469 | - */ |
|
| 2470 | - public function set_country( $value ) { |
|
| 2471 | - $this->set_prop( 'country', $value ); |
|
| 2615 | + * Set the customer's company id. |
|
| 2616 | + * |
|
| 2617 | + * @since 1.0.19 |
|
| 2618 | + * @param string $value company id. |
|
| 2619 | + */ |
|
| 2620 | + public function set_company_id( $value ) { |
|
| 2621 | + $this->set_prop( 'company_id', $value ); |
|
| 2472 | 2622 | } |
| 2473 | 2623 | |
| 2474 | 2624 | /** |
| 2475 | - * Alias of self::set_country(). |
|
| 2476 | - * |
|
| 2477 | - * @since 1.0.19 |
|
| 2478 | - * @param string $value country. |
|
| 2479 | - */ |
|
| 2480 | - public function set_user_country( $value ) { |
|
| 2481 | - $this->set_country( $value ); |
|
| 2625 | + * Set the customer's var number. |
|
| 2626 | + * |
|
| 2627 | + * @since 1.0.19 |
|
| 2628 | + * @param string $value var number. |
|
| 2629 | + */ |
|
| 2630 | + public function set_vat_number( $value ) { |
|
| 2631 | + $this->set_prop( 'vat_number', $value ); |
|
| 2482 | 2632 | } |
| 2483 | 2633 | |
| 2484 | 2634 | /** |
| 2485 | - * Alias of self::set_country(). |
|
| 2486 | - * |
|
| 2487 | - * @since 1.0.19 |
|
| 2488 | - * @param string $value country. |
|
| 2489 | - */ |
|
| 2490 | - public function set_customer_country( $value ) { |
|
| 2491 | - $this->set_country( $value ); |
|
| 2635 | + * Alias of self::set_vat_number(). |
|
| 2636 | + * |
|
| 2637 | + * @since 1.0.19 |
|
| 2638 | + * @param string $value var number. |
|
| 2639 | + */ |
|
| 2640 | + public function set_user_vat_number( $value ) { |
|
| 2641 | + $this->set_vat_number( $value ); |
|
| 2492 | 2642 | } |
| 2493 | 2643 | |
| 2494 | 2644 | /** |
| 2495 | - * Set the customer's state. |
|
| 2496 | - * |
|
| 2497 | - * @since 1.0.19 |
|
| 2498 | - * @param string $value state. |
|
| 2499 | - */ |
|
| 2500 | - public function set_state( $value ) { |
|
| 2501 | - $this->set_prop( 'state', $value ); |
|
| 2645 | + * Alias of self::set_vat_number(). |
|
| 2646 | + * |
|
| 2647 | + * @since 1.0.19 |
|
| 2648 | + * @param string $value var number. |
|
| 2649 | + */ |
|
| 2650 | + public function set_customer_vat_number( $value ) { |
|
| 2651 | + $this->set_vat_number( $value ); |
|
| 2502 | 2652 | } |
| 2503 | 2653 | |
| 2504 | 2654 | /** |
| 2505 | - * Alias of self::set_state(). |
|
| 2506 | - * |
|
| 2507 | - * @since 1.0.19 |
|
| 2508 | - * @param string $value state. |
|
| 2509 | - */ |
|
| 2510 | - public function set_user_state( $value ) { |
|
| 2511 | - $this->set_state( $value ); |
|
| 2655 | + * Set the customer's vat rate. |
|
| 2656 | + * |
|
| 2657 | + * @since 1.0.19 |
|
| 2658 | + * @param string $value var rate. |
|
| 2659 | + */ |
|
| 2660 | + public function set_vat_rate( $value ) { |
|
| 2661 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2512 | 2662 | } |
| 2513 | 2663 | |
| 2514 | 2664 | /** |
| 2515 | - * Alias of self::set_state(). |
|
| 2516 | - * |
|
| 2517 | - * @since 1.0.19 |
|
| 2518 | - * @param string $value state. |
|
| 2519 | - */ |
|
| 2520 | - public function set_customer_state( $value ) { |
|
| 2521 | - $this->set_state( $value ); |
|
| 2665 | + * Alias of self::set_vat_rate(). |
|
| 2666 | + * |
|
| 2667 | + * @since 1.0.19 |
|
| 2668 | + * @param string $value var number. |
|
| 2669 | + */ |
|
| 2670 | + public function set_user_vat_rate( $value ) { |
|
| 2671 | + $this->set_vat_rate( $value ); |
|
| 2522 | 2672 | } |
| 2523 | 2673 | |
| 2524 | 2674 | /** |
| 2525 | - * Set the customer's city. |
|
| 2526 | - * |
|
| 2527 | - * @since 1.0.19 |
|
| 2528 | - * @param string $value city. |
|
| 2529 | - */ |
|
| 2530 | - public function set_city( $value ) { |
|
| 2531 | - $this->set_prop( 'city', $value ); |
|
| 2675 | + * Alias of self::set_vat_rate(). |
|
| 2676 | + * |
|
| 2677 | + * @since 1.0.19 |
|
| 2678 | + * @param string $value var number. |
|
| 2679 | + */ |
|
| 2680 | + public function set_customer_vat_rate( $value ) { |
|
| 2681 | + $this->set_vat_rate( $value ); |
|
| 2532 | 2682 | } |
| 2533 | 2683 | |
| 2534 | 2684 | /** |
| 2535 | - * Alias of self::set_city(). |
|
| 2536 | - * |
|
| 2537 | - * @since 1.0.19 |
|
| 2538 | - * @param string $value city. |
|
| 2539 | - */ |
|
| 2540 | - public function set_user_city( $value ) { |
|
| 2541 | - $this->set_city( $value ); |
|
| 2685 | + * Set the customer's address. |
|
| 2686 | + * |
|
| 2687 | + * @since 1.0.19 |
|
| 2688 | + * @param string $value address. |
|
| 2689 | + */ |
|
| 2690 | + public function set_address( $value ) { |
|
| 2691 | + $this->set_prop( 'address', $value ); |
|
| 2542 | 2692 | } |
| 2543 | 2693 | |
| 2544 | 2694 | /** |
| 2545 | - * Alias of self::set_city(). |
|
| 2546 | - * |
|
| 2547 | - * @since 1.0.19 |
|
| 2548 | - * @param string $value city. |
|
| 2549 | - */ |
|
| 2550 | - public function set_customer_city( $value ) { |
|
| 2551 | - $this->set_city( $value ); |
|
| 2695 | + * Alias of self::set_address(). |
|
| 2696 | + * |
|
| 2697 | + * @since 1.0.19 |
|
| 2698 | + * @param string $value address. |
|
| 2699 | + */ |
|
| 2700 | + public function set_user_address( $value ) { |
|
| 2701 | + $this->set_address( $value ); |
|
| 2552 | 2702 | } |
| 2553 | 2703 | |
| 2554 | 2704 | /** |
| 2555 | - * Set the customer's zip code. |
|
| 2556 | - * |
|
| 2557 | - * @since 1.0.19 |
|
| 2558 | - * @param string $value zip. |
|
| 2559 | - */ |
|
| 2560 | - public function set_zip( $value ) { |
|
| 2561 | - $this->set_prop( 'zip', $value ); |
|
| 2705 | + * Alias of self::set_address(). |
|
| 2706 | + * |
|
| 2707 | + * @since 1.0.19 |
|
| 2708 | + * @param string $value address. |
|
| 2709 | + */ |
|
| 2710 | + public function set_customer_address( $value ) { |
|
| 2711 | + $this->set_address( $value ); |
|
| 2562 | 2712 | } |
| 2563 | 2713 | |
| 2564 | 2714 | /** |
| 2565 | - * Alias of self::set_zip(). |
|
| 2566 | - * |
|
| 2567 | - * @since 1.0.19 |
|
| 2568 | - * @param string $value zip. |
|
| 2569 | - */ |
|
| 2570 | - public function set_user_zip( $value ) { |
|
| 2571 | - $this->set_zip( $value ); |
|
| 2715 | + * Set whether the customer has viewed the invoice or not. |
|
| 2716 | + * |
|
| 2717 | + * @since 1.0.19 |
|
| 2718 | + * @param int|bool $value confirmed. |
|
| 2719 | + */ |
|
| 2720 | + public function set_is_viewed( $value ) { |
|
| 2721 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2572 | 2722 | } |
| 2573 | 2723 | |
| 2574 | 2724 | /** |
| 2575 | - * Alias of self::set_zip(). |
|
| 2576 | - * |
|
| 2577 | - * @since 1.0.19 |
|
| 2578 | - * @param string $value zip. |
|
| 2579 | - */ |
|
| 2580 | - public function set_customer_zip( $value ) { |
|
| 2581 | - $this->set_zip( $value ); |
|
| 2725 | + * Set extra email recipients. |
|
| 2726 | + * |
|
| 2727 | + * @since 1.0.19 |
|
| 2728 | + * @param string $value email recipients. |
|
| 2729 | + */ |
|
| 2730 | + public function set_email_cc( $value ) { |
|
| 2731 | + $this->set_prop( 'email_cc', $value ); |
|
| 2582 | 2732 | } |
| 2583 | 2733 | |
| 2584 | 2734 | /** |
| 2585 | - * Set the customer's company. |
|
| 2586 | - * |
|
| 2587 | - * @since 1.0.19 |
|
| 2588 | - * @param string $value company. |
|
| 2589 | - */ |
|
| 2590 | - public function set_company( $value ) { |
|
| 2591 | - $this->set_prop( 'company', $value ); |
|
| 2735 | + * Set the invoice template. |
|
| 2736 | + * |
|
| 2737 | + * @since 1.0.19 |
|
| 2738 | + * @param string $value template. |
|
| 2739 | + */ |
|
| 2740 | + public function set_template( $value ) { |
|
| 2741 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2742 | + $this->set_prop( 'template', $value ); |
|
| 2743 | + } |
|
| 2592 | 2744 | } |
| 2593 | 2745 | |
| 2594 | 2746 | /** |
| 2595 | - * Alias of self::set_company(). |
|
| 2596 | - * |
|
| 2597 | - * @since 1.0.19 |
|
| 2598 | - * @param string $value company. |
|
| 2599 | - */ |
|
| 2600 | - public function set_user_company( $value ) { |
|
| 2601 | - $this->set_company( $value ); |
|
| 2747 | + * Set the invoice source. |
|
| 2748 | + * |
|
| 2749 | + * @since 1.0.19 |
|
| 2750 | + * @param string $value source. |
|
| 2751 | + * @deprecated |
|
| 2752 | + */ |
|
| 2753 | + public function created_via( $value ) { |
|
| 2754 | + $this->set_created_via( sanitize_text_field( $value ) ); |
|
| 2602 | 2755 | } |
| 2603 | 2756 | |
| 2604 | 2757 | /** |
| 2605 | - * Alias of self::set_company(). |
|
| 2606 | - * |
|
| 2607 | - * @since 1.0.19 |
|
| 2608 | - * @param string $value company. |
|
| 2609 | - */ |
|
| 2610 | - public function set_customer_company( $value ) { |
|
| 2611 | - $this->set_company( $value ); |
|
| 2758 | + * Set the invoice source. |
|
| 2759 | + * |
|
| 2760 | + * @since 1.0.19 |
|
| 2761 | + * @param string $value source. |
|
| 2762 | + */ |
|
| 2763 | + public function set_created_via( $value ) { |
|
| 2764 | + $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2612 | 2765 | } |
| 2613 | 2766 | |
| 2614 | - /** |
|
| 2615 | - * Set the customer's company id. |
|
| 2616 | - * |
|
| 2617 | - * @since 1.0.19 |
|
| 2618 | - * @param string $value company id. |
|
| 2619 | - */ |
|
| 2620 | - public function set_company_id( $value ) { |
|
| 2621 | - $this->set_prop( 'company_id', $value ); |
|
| 2767 | + /** |
|
| 2768 | + * Set the customer's address confirmed status. |
|
| 2769 | + * |
|
| 2770 | + * @since 1.0.19 |
|
| 2771 | + * @param int|bool $value confirmed. |
|
| 2772 | + */ |
|
| 2773 | + public function set_address_confirmed( $value ) { |
|
| 2774 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2622 | 2775 | } |
| 2623 | 2776 | |
| 2624 | 2777 | /** |
| 2625 | - * Set the customer's var number. |
|
| 2626 | - * |
|
| 2627 | - * @since 1.0.19 |
|
| 2628 | - * @param string $value var number. |
|
| 2629 | - */ |
|
| 2630 | - public function set_vat_number( $value ) { |
|
| 2631 | - $this->set_prop( 'vat_number', $value ); |
|
| 2778 | + * Alias of self::set_address_confirmed(). |
|
| 2779 | + * |
|
| 2780 | + * @since 1.0.19 |
|
| 2781 | + * @param int|bool $value confirmed. |
|
| 2782 | + */ |
|
| 2783 | + public function set_user_address_confirmed( $value ) { |
|
| 2784 | + $this->set_address_confirmed( $value ); |
|
| 2632 | 2785 | } |
| 2633 | 2786 | |
| 2634 | 2787 | /** |
| 2635 | - * Alias of self::set_vat_number(). |
|
| 2636 | - * |
|
| 2637 | - * @since 1.0.19 |
|
| 2638 | - * @param string $value var number. |
|
| 2639 | - */ |
|
| 2640 | - public function set_user_vat_number( $value ) { |
|
| 2641 | - $this->set_vat_number( $value ); |
|
| 2788 | + * Alias of self::set_address_confirmed(). |
|
| 2789 | + * |
|
| 2790 | + * @since 1.0.19 |
|
| 2791 | + * @param int|bool $value confirmed. |
|
| 2792 | + */ |
|
| 2793 | + public function set_customer_address_confirmed( $value ) { |
|
| 2794 | + $this->set_address_confirmed( $value ); |
|
| 2642 | 2795 | } |
| 2643 | 2796 | |
| 2644 | 2797 | /** |
| 2645 | - * Alias of self::set_vat_number(). |
|
| 2646 | - * |
|
| 2647 | - * @since 1.0.19 |
|
| 2648 | - * @param string $value var number. |
|
| 2649 | - */ |
|
| 2650 | - public function set_customer_vat_number( $value ) { |
|
| 2651 | - $this->set_vat_number( $value ); |
|
| 2798 | + * Set the invoice sub total. |
|
| 2799 | + * |
|
| 2800 | + * @since 1.0.19 |
|
| 2801 | + * @param float $value sub total. |
|
| 2802 | + */ |
|
| 2803 | + public function set_subtotal( $value ) { |
|
| 2804 | + $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
| 2652 | 2805 | } |
| 2653 | 2806 | |
| 2654 | 2807 | /** |
| 2655 | - * Set the customer's vat rate. |
|
| 2656 | - * |
|
| 2657 | - * @since 1.0.19 |
|
| 2658 | - * @param string $value var rate. |
|
| 2659 | - */ |
|
| 2660 | - public function set_vat_rate( $value ) { |
|
| 2661 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2808 | + * Set the invoice total. |
|
| 2809 | + * |
|
| 2810 | + * @since 1.0.19 |
|
| 2811 | + * @param float $value sub total. |
|
| 2812 | + */ |
|
| 2813 | + public function set_total( $value ) { |
|
| 2814 | + $this->set_prop( 'total', max( 0, $value ) ); |
|
| 2662 | 2815 | } |
| 2663 | 2816 | |
| 2664 | - /** |
|
| 2665 | - * Alias of self::set_vat_rate(). |
|
| 2666 | - * |
|
| 2667 | - * @since 1.0.19 |
|
| 2668 | - * @param string $value var number. |
|
| 2669 | - */ |
|
| 2670 | - public function set_user_vat_rate( $value ) { |
|
| 2671 | - $this->set_vat_rate( $value ); |
|
| 2672 | - } |
|
| 2673 | - |
|
| 2674 | - /** |
|
| 2675 | - * Alias of self::set_vat_rate(). |
|
| 2676 | - * |
|
| 2677 | - * @since 1.0.19 |
|
| 2678 | - * @param string $value var number. |
|
| 2679 | - */ |
|
| 2680 | - public function set_customer_vat_rate( $value ) { |
|
| 2681 | - $this->set_vat_rate( $value ); |
|
| 2682 | - } |
|
| 2683 | - |
|
| 2684 | - /** |
|
| 2685 | - * Set the customer's address. |
|
| 2686 | - * |
|
| 2687 | - * @since 1.0.19 |
|
| 2688 | - * @param string $value address. |
|
| 2689 | - */ |
|
| 2690 | - public function set_address( $value ) { |
|
| 2691 | - $this->set_prop( 'address', $value ); |
|
| 2692 | - } |
|
| 2693 | - |
|
| 2694 | - /** |
|
| 2695 | - * Alias of self::set_address(). |
|
| 2696 | - * |
|
| 2697 | - * @since 1.0.19 |
|
| 2698 | - * @param string $value address. |
|
| 2699 | - */ |
|
| 2700 | - public function set_user_address( $value ) { |
|
| 2701 | - $this->set_address( $value ); |
|
| 2702 | - } |
|
| 2703 | - |
|
| 2704 | - /** |
|
| 2705 | - * Alias of self::set_address(). |
|
| 2706 | - * |
|
| 2707 | - * @since 1.0.19 |
|
| 2708 | - * @param string $value address. |
|
| 2709 | - */ |
|
| 2710 | - public function set_customer_address( $value ) { |
|
| 2711 | - $this->set_address( $value ); |
|
| 2712 | - } |
|
| 2713 | - |
|
| 2714 | - /** |
|
| 2715 | - * Set whether the customer has viewed the invoice or not. |
|
| 2716 | - * |
|
| 2717 | - * @since 1.0.19 |
|
| 2718 | - * @param int|bool $value confirmed. |
|
| 2719 | - */ |
|
| 2720 | - public function set_is_viewed( $value ) { |
|
| 2721 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2722 | - } |
|
| 2723 | - |
|
| 2724 | - /** |
|
| 2725 | - * Set extra email recipients. |
|
| 2726 | - * |
|
| 2727 | - * @since 1.0.19 |
|
| 2728 | - * @param string $value email recipients. |
|
| 2729 | - */ |
|
| 2730 | - public function set_email_cc( $value ) { |
|
| 2731 | - $this->set_prop( 'email_cc', $value ); |
|
| 2732 | - } |
|
| 2733 | - |
|
| 2734 | - /** |
|
| 2735 | - * Set the invoice template. |
|
| 2736 | - * |
|
| 2737 | - * @since 1.0.19 |
|
| 2738 | - * @param string $value template. |
|
| 2739 | - */ |
|
| 2740 | - public function set_template( $value ) { |
|
| 2741 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2742 | - $this->set_prop( 'template', $value ); |
|
| 2743 | - } |
|
| 2744 | - } |
|
| 2745 | - |
|
| 2746 | - /** |
|
| 2747 | - * Set the invoice source. |
|
| 2748 | - * |
|
| 2749 | - * @since 1.0.19 |
|
| 2750 | - * @param string $value source. |
|
| 2751 | - * @deprecated |
|
| 2752 | - */ |
|
| 2753 | - public function created_via( $value ) { |
|
| 2754 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
| 2755 | - } |
|
| 2756 | - |
|
| 2757 | - /** |
|
| 2758 | - * Set the invoice source. |
|
| 2759 | - * |
|
| 2760 | - * @since 1.0.19 |
|
| 2761 | - * @param string $value source. |
|
| 2762 | - */ |
|
| 2763 | - public function set_created_via( $value ) { |
|
| 2764 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2765 | - } |
|
| 2766 | - |
|
| 2767 | - /** |
|
| 2768 | - * Set the customer's address confirmed status. |
|
| 2769 | - * |
|
| 2770 | - * @since 1.0.19 |
|
| 2771 | - * @param int|bool $value confirmed. |
|
| 2772 | - */ |
|
| 2773 | - public function set_address_confirmed( $value ) { |
|
| 2774 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2775 | - } |
|
| 2776 | - |
|
| 2777 | - /** |
|
| 2778 | - * Alias of self::set_address_confirmed(). |
|
| 2779 | - * |
|
| 2780 | - * @since 1.0.19 |
|
| 2781 | - * @param int|bool $value confirmed. |
|
| 2782 | - */ |
|
| 2783 | - public function set_user_address_confirmed( $value ) { |
|
| 2784 | - $this->set_address_confirmed( $value ); |
|
| 2785 | - } |
|
| 2786 | - |
|
| 2787 | - /** |
|
| 2788 | - * Alias of self::set_address_confirmed(). |
|
| 2789 | - * |
|
| 2790 | - * @since 1.0.19 |
|
| 2791 | - * @param int|bool $value confirmed. |
|
| 2792 | - */ |
|
| 2793 | - public function set_customer_address_confirmed( $value ) { |
|
| 2794 | - $this->set_address_confirmed( $value ); |
|
| 2795 | - } |
|
| 2796 | - |
|
| 2797 | - /** |
|
| 2798 | - * Set the invoice sub total. |
|
| 2799 | - * |
|
| 2800 | - * @since 1.0.19 |
|
| 2801 | - * @param float $value sub total. |
|
| 2802 | - */ |
|
| 2803 | - public function set_subtotal( $value ) { |
|
| 2804 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
| 2805 | - } |
|
| 2806 | - |
|
| 2807 | - /** |
|
| 2808 | - * Set the invoice total. |
|
| 2809 | - * |
|
| 2810 | - * @since 1.0.19 |
|
| 2811 | - * @param float $value sub total. |
|
| 2812 | - */ |
|
| 2813 | - public function set_total( $value ) { |
|
| 2814 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
| 2815 | - } |
|
| 2816 | - |
|
| 2817 | - /** |
|
| 2818 | - * Set the invoice discount amount. |
|
| 2819 | - * |
|
| 2820 | - * @since 1.0.19 |
|
| 2821 | - * @param float $value discount total. |
|
| 2822 | - */ |
|
| 2823 | - public function set_total_discount( $value ) { |
|
| 2824 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
| 2817 | + /** |
|
| 2818 | + * Set the invoice discount amount. |
|
| 2819 | + * |
|
| 2820 | + * @since 1.0.19 |
|
| 2821 | + * @param float $value discount total. |
|
| 2822 | + */ |
|
| 2823 | + public function set_total_discount( $value ) { |
|
| 2824 | + $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
| 2825 | 2825 | } |
| 2826 | 2826 | |
| 2827 | 2827 | /** |
| 2828 | - * Alias of self::set_total_discount(). |
|
| 2829 | - * |
|
| 2830 | - * @since 1.0.19 |
|
| 2831 | - * @param float $value discount total. |
|
| 2832 | - */ |
|
| 2833 | - public function set_discount( $value ) { |
|
| 2834 | - $this->set_total_discount( $value ); |
|
| 2828 | + * Alias of self::set_total_discount(). |
|
| 2829 | + * |
|
| 2830 | + * @since 1.0.19 |
|
| 2831 | + * @param float $value discount total. |
|
| 2832 | + */ |
|
| 2833 | + public function set_discount( $value ) { |
|
| 2834 | + $this->set_total_discount( $value ); |
|
| 2835 | 2835 | } |
| 2836 | 2836 | |
| 2837 | 2837 | /** |
| 2838 | - * Set the invoice tax amount. |
|
| 2839 | - * |
|
| 2840 | - * @since 1.0.19 |
|
| 2841 | - * @param float $value tax total. |
|
| 2842 | - */ |
|
| 2843 | - public function set_total_tax( $value ) { |
|
| 2844 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
| 2838 | + * Set the invoice tax amount. |
|
| 2839 | + * |
|
| 2840 | + * @since 1.0.19 |
|
| 2841 | + * @param float $value tax total. |
|
| 2842 | + */ |
|
| 2843 | + public function set_total_tax( $value ) { |
|
| 2844 | + $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
| 2845 | 2845 | } |
| 2846 | 2846 | |
| 2847 | 2847 | /** |
| 2848 | - * Alias of self::set_total_tax(). |
|
| 2849 | - * |
|
| 2850 | - * @since 1.0.19 |
|
| 2851 | - * @param float $value tax total. |
|
| 2852 | - */ |
|
| 2853 | - public function set_tax_total( $value ) { |
|
| 2854 | - $this->set_total_tax( $value ); |
|
| 2848 | + * Alias of self::set_total_tax(). |
|
| 2849 | + * |
|
| 2850 | + * @since 1.0.19 |
|
| 2851 | + * @param float $value tax total. |
|
| 2852 | + */ |
|
| 2853 | + public function set_tax_total( $value ) { |
|
| 2854 | + $this->set_total_tax( $value ); |
|
| 2855 | 2855 | } |
| 2856 | 2856 | |
| 2857 | 2857 | /** |
| 2858 | - * Set the invoice fees amount. |
|
| 2859 | - * |
|
| 2860 | - * @since 1.0.19 |
|
| 2861 | - * @param float $value fees total. |
|
| 2862 | - */ |
|
| 2863 | - public function set_total_fees( $value ) { |
|
| 2864 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
| 2858 | + * Set the invoice fees amount. |
|
| 2859 | + * |
|
| 2860 | + * @since 1.0.19 |
|
| 2861 | + * @param float $value fees total. |
|
| 2862 | + */ |
|
| 2863 | + public function set_total_fees( $value ) { |
|
| 2864 | + $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
| 2865 | 2865 | } |
| 2866 | 2866 | |
| 2867 | 2867 | /** |
| 2868 | - * Alias of self::set_total_fees(). |
|
| 2869 | - * |
|
| 2870 | - * @since 1.0.19 |
|
| 2871 | - * @param float $value fees total. |
|
| 2872 | - */ |
|
| 2873 | - public function set_fees_total( $value ) { |
|
| 2874 | - $this->set_total_fees( $value ); |
|
| 2868 | + * Alias of self::set_total_fees(). |
|
| 2869 | + * |
|
| 2870 | + * @since 1.0.19 |
|
| 2871 | + * @param float $value fees total. |
|
| 2872 | + */ |
|
| 2873 | + public function set_fees_total( $value ) { |
|
| 2874 | + $this->set_total_fees( $value ); |
|
| 2875 | 2875 | } |
| 2876 | 2876 | |
| 2877 | 2877 | /** |
| 2878 | - * Set the invoice fees. |
|
| 2879 | - * |
|
| 2880 | - * @since 1.0.19 |
|
| 2881 | - * @param array $value fees. |
|
| 2882 | - */ |
|
| 2883 | - public function set_fees( $value ) { |
|
| 2878 | + * Set the invoice fees. |
|
| 2879 | + * |
|
| 2880 | + * @since 1.0.19 |
|
| 2881 | + * @param array $value fees. |
|
| 2882 | + */ |
|
| 2883 | + public function set_fees( $value ) { |
|
| 2884 | 2884 | |
| 2885 | - if ( ! is_array( $value ) ) { |
|
| 2886 | - $value = array(); |
|
| 2887 | - } |
|
| 2885 | + if ( ! is_array( $value ) ) { |
|
| 2886 | + $value = array(); |
|
| 2887 | + } |
|
| 2888 | 2888 | |
| 2889 | - $this->set_prop( 'fees', $value ); |
|
| 2889 | + $this->set_prop( 'fees', $value ); |
|
| 2890 | 2890 | |
| 2891 | 2891 | } |
| 2892 | 2892 | |
| 2893 | 2893 | /** |
| 2894 | - * Set the invoice taxes. |
|
| 2895 | - * |
|
| 2896 | - * @since 1.0.19 |
|
| 2897 | - * @param array $value taxes. |
|
| 2898 | - */ |
|
| 2899 | - public function set_taxes( $value ) { |
|
| 2894 | + * Set the invoice taxes. |
|
| 2895 | + * |
|
| 2896 | + * @since 1.0.19 |
|
| 2897 | + * @param array $value taxes. |
|
| 2898 | + */ |
|
| 2899 | + public function set_taxes( $value ) { |
|
| 2900 | 2900 | |
| 2901 | - if ( ! is_array( $value ) ) { |
|
| 2902 | - $value = array(); |
|
| 2903 | - } |
|
| 2901 | + if ( ! is_array( $value ) ) { |
|
| 2902 | + $value = array(); |
|
| 2903 | + } |
|
| 2904 | 2904 | |
| 2905 | - $this->set_prop( 'taxes', $value ); |
|
| 2905 | + $this->set_prop( 'taxes', $value ); |
|
| 2906 | 2906 | |
| 2907 | 2907 | } |
| 2908 | 2908 | |
| 2909 | 2909 | /** |
| 2910 | - * Set the invoice discounts. |
|
| 2911 | - * |
|
| 2912 | - * @since 1.0.19 |
|
| 2913 | - * @param array $value discounts. |
|
| 2914 | - */ |
|
| 2915 | - public function set_discounts( $value ) { |
|
| 2910 | + * Set the invoice discounts. |
|
| 2911 | + * |
|
| 2912 | + * @since 1.0.19 |
|
| 2913 | + * @param array $value discounts. |
|
| 2914 | + */ |
|
| 2915 | + public function set_discounts( $value ) { |
|
| 2916 | 2916 | |
| 2917 | - if ( ! is_array( $value ) ) { |
|
| 2918 | - $value = array(); |
|
| 2919 | - } |
|
| 2917 | + if ( ! is_array( $value ) ) { |
|
| 2918 | + $value = array(); |
|
| 2919 | + } |
|
| 2920 | 2920 | |
| 2921 | - $this->set_prop( 'discounts', $value ); |
|
| 2921 | + $this->set_prop( 'discounts', $value ); |
|
| 2922 | 2922 | } |
| 2923 | 2923 | |
| 2924 | 2924 | /** |
| 2925 | - * Set the invoice items. |
|
| 2926 | - * |
|
| 2927 | - * @since 1.0.19 |
|
| 2928 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2929 | - */ |
|
| 2930 | - public function set_items( $value ) { |
|
| 2925 | + * Set the invoice items. |
|
| 2926 | + * |
|
| 2927 | + * @since 1.0.19 |
|
| 2928 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2929 | + */ |
|
| 2930 | + public function set_items( $value ) { |
|
| 2931 | 2931 | |
| 2932 | 2932 | // Remove existing items. |
| 2933 | 2933 | $this->set_prop( 'items', array() ); |
| 2934 | - $this->recurring_item = null; |
|
| 2934 | + $this->recurring_item = null; |
|
| 2935 | 2935 | |
| 2936 | 2936 | // Ensure that we have an array. |
| 2937 | 2937 | if ( ! is_array( $value ) ) { |
@@ -2945,95 +2945,95 @@ discard block |
||
| 2945 | 2945 | } |
| 2946 | 2946 | |
| 2947 | 2947 | /** |
| 2948 | - * Set the payment form. |
|
| 2949 | - * |
|
| 2950 | - * @since 1.0.19 |
|
| 2951 | - * @param int $value payment form. |
|
| 2952 | - */ |
|
| 2953 | - public function set_payment_form( $value ) { |
|
| 2954 | - $this->set_prop( 'payment_form', $value ); |
|
| 2948 | + * Set the payment form. |
|
| 2949 | + * |
|
| 2950 | + * @since 1.0.19 |
|
| 2951 | + * @param int $value payment form. |
|
| 2952 | + */ |
|
| 2953 | + public function set_payment_form( $value ) { |
|
| 2954 | + $this->set_prop( 'payment_form', $value ); |
|
| 2955 | 2955 | } |
| 2956 | 2956 | |
| 2957 | 2957 | /** |
| 2958 | - * Set the submission id. |
|
| 2959 | - * |
|
| 2960 | - * @since 1.0.19 |
|
| 2961 | - * @param string $value submission id. |
|
| 2962 | - */ |
|
| 2963 | - public function set_submission_id( $value ) { |
|
| 2964 | - $this->set_prop( 'submission_id', $value ); |
|
| 2958 | + * Set the submission id. |
|
| 2959 | + * |
|
| 2960 | + * @since 1.0.19 |
|
| 2961 | + * @param string $value submission id. |
|
| 2962 | + */ |
|
| 2963 | + public function set_submission_id( $value ) { |
|
| 2964 | + $this->set_prop( 'submission_id', $value ); |
|
| 2965 | 2965 | } |
| 2966 | 2966 | |
| 2967 | 2967 | /** |
| 2968 | - * Set the discount code. |
|
| 2969 | - * |
|
| 2970 | - * @since 1.0.19 |
|
| 2971 | - * @param string $value discount code. |
|
| 2972 | - */ |
|
| 2973 | - public function set_discount_code( $value ) { |
|
| 2974 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
| 2968 | + * Set the discount code. |
|
| 2969 | + * |
|
| 2970 | + * @since 1.0.19 |
|
| 2971 | + * @param string $value discount code. |
|
| 2972 | + */ |
|
| 2973 | + public function set_discount_code( $value ) { |
|
| 2974 | + $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
| 2975 | 2975 | } |
| 2976 | 2976 | |
| 2977 | 2977 | /** |
| 2978 | - * Set the gateway. |
|
| 2979 | - * |
|
| 2980 | - * @since 1.0.19 |
|
| 2981 | - * @param string $value gateway. |
|
| 2982 | - */ |
|
| 2983 | - public function set_gateway( $value ) { |
|
| 2984 | - $this->set_prop( 'gateway', $value ); |
|
| 2978 | + * Set the gateway. |
|
| 2979 | + * |
|
| 2980 | + * @since 1.0.19 |
|
| 2981 | + * @param string $value gateway. |
|
| 2982 | + */ |
|
| 2983 | + public function set_gateway( $value ) { |
|
| 2984 | + $this->set_prop( 'gateway', $value ); |
|
| 2985 | 2985 | } |
| 2986 | 2986 | |
| 2987 | 2987 | /** |
| 2988 | - * Set the transaction id. |
|
| 2989 | - * |
|
| 2990 | - * @since 1.0.19 |
|
| 2991 | - * @param string $value transaction id. |
|
| 2992 | - */ |
|
| 2993 | - public function set_transaction_id( $value ) { |
|
| 2994 | - if ( ! empty( $value ) ) { |
|
| 2995 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2996 | - } |
|
| 2988 | + * Set the transaction id. |
|
| 2989 | + * |
|
| 2990 | + * @since 1.0.19 |
|
| 2991 | + * @param string $value transaction id. |
|
| 2992 | + */ |
|
| 2993 | + public function set_transaction_id( $value ) { |
|
| 2994 | + if ( ! empty( $value ) ) { |
|
| 2995 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2996 | + } |
|
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | 2999 | /** |
| 3000 | - * Set the currency id. |
|
| 3001 | - * |
|
| 3002 | - * @since 1.0.19 |
|
| 3003 | - * @param string $value currency id. |
|
| 3004 | - */ |
|
| 3005 | - public function set_currency( $value ) { |
|
| 3006 | - $this->set_prop( 'currency', $value ); |
|
| 3000 | + * Set the currency id. |
|
| 3001 | + * |
|
| 3002 | + * @since 1.0.19 |
|
| 3003 | + * @param string $value currency id. |
|
| 3004 | + */ |
|
| 3005 | + public function set_currency( $value ) { |
|
| 3006 | + $this->set_prop( 'currency', $value ); |
|
| 3007 | 3007 | } |
| 3008 | 3008 | |
| 3009 | - /** |
|
| 3010 | - * Set whether to disable taxes. |
|
| 3011 | - * |
|
| 3012 | - * @since 1.0.19 |
|
| 3013 | - * @param bool $value value. |
|
| 3014 | - */ |
|
| 3015 | - public function set_disable_taxes( $value ) { |
|
| 3016 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 3017 | - } |
|
| 3009 | + /** |
|
| 3010 | + * Set whether to disable taxes. |
|
| 3011 | + * |
|
| 3012 | + * @since 1.0.19 |
|
| 3013 | + * @param bool $value value. |
|
| 3014 | + */ |
|
| 3015 | + public function set_disable_taxes( $value ) { |
|
| 3016 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 3017 | + } |
|
| 3018 | 3018 | |
| 3019 | 3019 | /** |
| 3020 | - * Set the subscription id. |
|
| 3021 | - * |
|
| 3022 | - * @since 1.0.19 |
|
| 3023 | - * @param string $value subscription id. |
|
| 3024 | - */ |
|
| 3025 | - public function set_subscription_id( $value ) { |
|
| 3026 | - $this->set_prop( 'subscription_id', $value ); |
|
| 3027 | - } |
|
| 3020 | + * Set the subscription id. |
|
| 3021 | + * |
|
| 3022 | + * @since 1.0.19 |
|
| 3023 | + * @param string $value subscription id. |
|
| 3024 | + */ |
|
| 3025 | + public function set_subscription_id( $value ) { |
|
| 3026 | + $this->set_prop( 'subscription_id', $value ); |
|
| 3027 | + } |
|
| 3028 | 3028 | |
| 3029 | - /** |
|
| 3030 | - * Set the remote subscription id. |
|
| 3031 | - * |
|
| 3032 | - * @since 1.0.19 |
|
| 3033 | - * @param string $value subscription id. |
|
| 3034 | - */ |
|
| 3035 | - public function set_remote_subscription_id( $value ) { |
|
| 3036 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 3029 | + /** |
|
| 3030 | + * Set the remote subscription id. |
|
| 3031 | + * |
|
| 3032 | + * @since 1.0.19 |
|
| 3033 | + * @param string $value subscription id. |
|
| 3034 | + */ |
|
| 3035 | + public function set_remote_subscription_id( $value ) { |
|
| 3036 | + $this->set_prop( 'remote_subscription_id', $value ); |
|
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | 3039 | /* |
@@ -3072,24 +3072,24 @@ discard block |
||
| 3072 | 3072 | */ |
| 3073 | 3073 | public function is_taxable() { |
| 3074 | 3074 | return ! $this->get_disable_taxes(); |
| 3075 | - } |
|
| 3075 | + } |
|
| 3076 | 3076 | |
| 3077 | - /** |
|
| 3078 | - * @deprecated |
|
| 3079 | - */ |
|
| 3080 | - public function has_vat() { |
|
| 3077 | + /** |
|
| 3078 | + * @deprecated |
|
| 3079 | + */ |
|
| 3080 | + public function has_vat() { |
|
| 3081 | 3081 | return $this->is_taxable(); |
| 3082 | - } |
|
| 3082 | + } |
|
| 3083 | 3083 | |
| 3084 | - /** |
|
| 3085 | - * Checks to see if the invoice requires payment. |
|
| 3086 | - */ |
|
| 3087 | - public function is_free() { |
|
| 3084 | + /** |
|
| 3085 | + * Checks to see if the invoice requires payment. |
|
| 3086 | + */ |
|
| 3087 | + public function is_free() { |
|
| 3088 | 3088 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 3089 | 3089 | |
| 3090 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 3091 | - $is_free = false; |
|
| 3092 | - } |
|
| 3090 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 3091 | + $is_free = false; |
|
| 3092 | + } |
|
| 3093 | 3093 | |
| 3094 | 3094 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 3095 | 3095 | } |
@@ -3100,46 +3100,46 @@ discard block |
||
| 3100 | 3100 | public function is_paid() { |
| 3101 | 3101 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 3102 | 3102 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 3103 | - } |
|
| 3103 | + } |
|
| 3104 | 3104 | |
| 3105 | - /** |
|
| 3105 | + /** |
|
| 3106 | 3106 | * Checks if the invoice needs payment. |
| 3107 | 3107 | */ |
| 3108 | - public function needs_payment() { |
|
| 3109 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3108 | + public function needs_payment() { |
|
| 3109 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3110 | 3110 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 3111 | 3111 | } |
| 3112 | 3112 | |
| 3113 | - /** |
|
| 3113 | + /** |
|
| 3114 | 3114 | * Checks if the invoice is refunded. |
| 3115 | 3115 | */ |
| 3116 | - public function is_refunded() { |
|
| 3116 | + public function is_refunded() { |
|
| 3117 | 3117 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 3118 | 3118 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 3119 | - } |
|
| 3119 | + } |
|
| 3120 | 3120 | |
| 3121 | - /** |
|
| 3121 | + /** |
|
| 3122 | 3122 | * Checks if the invoice is held. |
| 3123 | 3123 | */ |
| 3124 | - public function is_held() { |
|
| 3124 | + public function is_held() { |
|
| 3125 | 3125 | $is_held = $this->has_status( 'wpi-onhold' ); |
| 3126 | 3126 | return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
| 3127 | - } |
|
| 3127 | + } |
|
| 3128 | 3128 | |
| 3129 | - /** |
|
| 3129 | + /** |
|
| 3130 | 3130 | * Checks if the invoice is due. |
| 3131 | 3131 | */ |
| 3132 | - public function is_due() { |
|
| 3133 | - $due_date = $this->get_due_date(); |
|
| 3134 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3135 | - } |
|
| 3132 | + public function is_due() { |
|
| 3133 | + $due_date = $this->get_due_date(); |
|
| 3134 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3135 | + } |
|
| 3136 | 3136 | |
| 3137 | - /** |
|
| 3137 | + /** |
|
| 3138 | 3138 | * Checks if the invoice is draft. |
| 3139 | 3139 | */ |
| 3140 | - public function is_draft() { |
|
| 3140 | + public function is_draft() { |
|
| 3141 | 3141 | return $this->has_status( 'draft, auto-draft' ); |
| 3142 | - } |
|
| 3142 | + } |
|
| 3143 | 3143 | |
| 3144 | 3144 | /** |
| 3145 | 3145 | * Checks if the invoice has a given status. |
@@ -3147,9 +3147,9 @@ discard block |
||
| 3147 | 3147 | public function has_status( $status ) { |
| 3148 | 3148 | $status = wpinv_parse_list( $status ); |
| 3149 | 3149 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 3150 | - } |
|
| 3150 | + } |
|
| 3151 | 3151 | |
| 3152 | - /** |
|
| 3152 | + /** |
|
| 3153 | 3153 | * Checks if the invoice is of a given type. |
| 3154 | 3154 | */ |
| 3155 | 3155 | public function is_type( $type ) { |
@@ -3172,25 +3172,25 @@ discard block |
||
| 3172 | 3172 | */ |
| 3173 | 3173 | public function has_free_trial() { |
| 3174 | 3174 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 3175 | - } |
|
| 3175 | + } |
|
| 3176 | 3176 | |
| 3177 | - /** |
|
| 3177 | + /** |
|
| 3178 | 3178 | * @deprecated |
| 3179 | 3179 | */ |
| 3180 | 3180 | public function is_free_trial() { |
| 3181 | 3181 | $this->has_free_trial(); |
| 3182 | 3182 | } |
| 3183 | 3183 | |
| 3184 | - /** |
|
| 3184 | + /** |
|
| 3185 | 3185 | * Check if the initial payment if 0. |
| 3186 | 3186 | * |
| 3187 | 3187 | */ |
| 3188 | - public function is_initial_free() { |
|
| 3188 | + public function is_initial_free() { |
|
| 3189 | 3189 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3190 | 3190 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3191 | 3191 | } |
| 3192 | 3192 | |
| 3193 | - /** |
|
| 3193 | + /** |
|
| 3194 | 3194 | * Check if the recurring item has a free trial. |
| 3195 | 3195 | * |
| 3196 | 3196 | */ |
@@ -3203,21 +3203,21 @@ discard block |
||
| 3203 | 3203 | |
| 3204 | 3204 | $item = $this->get_recurring( true ); |
| 3205 | 3205 | return $item->has_free_trial(); |
| 3206 | - } |
|
| 3206 | + } |
|
| 3207 | 3207 | |
| 3208 | - /** |
|
| 3208 | + /** |
|
| 3209 | 3209 | * Check if the free trial is a result of a discount. |
| 3210 | 3210 | */ |
| 3211 | 3211 | public function is_free_trial_from_discount() { |
| 3212 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3213 | - } |
|
| 3212 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3213 | + } |
|
| 3214 | 3214 | |
| 3215 | - /** |
|
| 3215 | + /** |
|
| 3216 | 3216 | * @deprecated |
| 3217 | 3217 | */ |
| 3218 | 3218 | public function discount_first_payment_only() { |
| 3219 | 3219 | |
| 3220 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3220 | + $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3221 | 3221 | if ( ! $discount->exists() || ! $this->is_recurring() ) { |
| 3222 | 3222 | return true; |
| 3223 | 3223 | } |
@@ -3242,143 +3242,143 @@ discard block |
||
| 3242 | 3242 | */ |
| 3243 | 3243 | public function add_item( $item ) { |
| 3244 | 3244 | |
| 3245 | - if ( is_array( $item ) ) { |
|
| 3246 | - $item = $this->process_array_item( $item ); |
|
| 3247 | - } |
|
| 3245 | + if ( is_array( $item ) ) { |
|
| 3246 | + $item = $this->process_array_item( $item ); |
|
| 3247 | + } |
|
| 3248 | 3248 | |
| 3249 | - if ( is_numeric( $item ) ) { |
|
| 3250 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3251 | - } |
|
| 3249 | + if ( is_numeric( $item ) ) { |
|
| 3250 | + $item = new GetPaid_Form_Item( $item ); |
|
| 3251 | + } |
|
| 3252 | 3252 | |
| 3253 | 3253 | // Make sure that it is available for purchase. |
| 3254 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3255 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3254 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3255 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | // Do we have a recurring item? |
| 3259 | - if ( $item->is_recurring() ) { |
|
| 3260 | - $this->recurring_item = $item->get_id(); |
|
| 3259 | + if ( $item->is_recurring() ) { |
|
| 3260 | + $this->recurring_item = $item->get_id(); |
|
| 3261 | 3261 | } |
| 3262 | 3262 | |
| 3263 | 3263 | // Invoice id. |
| 3264 | 3264 | $item->invoice_id = (int) $this->get_id(); |
| 3265 | 3265 | |
| 3266 | - // Remove duplicates. |
|
| 3267 | - $this->remove_item( $item->get_id() ); |
|
| 3266 | + // Remove duplicates. |
|
| 3267 | + $this->remove_item( $item->get_id() ); |
|
| 3268 | 3268 | |
| 3269 | - // Retrieve all items. |
|
| 3269 | + // Retrieve all items. |
|
| 3270 | 3270 | $items = $this->get_items(); |
| 3271 | 3271 | |
| 3272 | - // Add new item. |
|
| 3272 | + // Add new item. |
|
| 3273 | 3273 | $items[] = $item; |
| 3274 | 3274 | |
| 3275 | 3275 | $this->set_prop( 'items', $items ); |
| 3276 | 3276 | |
| 3277 | - return true; |
|
| 3278 | - } |
|
| 3277 | + return true; |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | - /** |
|
| 3281 | - * Converts an array to an item. |
|
| 3282 | - * |
|
| 3283 | - * @since 1.0.19 |
|
| 3284 | - * @return GetPaid_Form_Item |
|
| 3285 | - */ |
|
| 3286 | - protected function process_array_item( $array ) { |
|
| 3280 | + /** |
|
| 3281 | + * Converts an array to an item. |
|
| 3282 | + * |
|
| 3283 | + * @since 1.0.19 |
|
| 3284 | + * @return GetPaid_Form_Item |
|
| 3285 | + */ |
|
| 3286 | + protected function process_array_item( $array ) { |
|
| 3287 | 3287 | |
| 3288 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3289 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3288 | + $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3289 | + $item = new GetPaid_Form_Item( $item_id ); |
|
| 3290 | 3290 | |
| 3291 | - // Set item data. |
|
| 3292 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3293 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3294 | - $method = "set_$key"; |
|
| 3295 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3296 | - } |
|
| 3297 | - } |
|
| 3291 | + // Set item data. |
|
| 3292 | + foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3293 | + if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3294 | + $method = "set_$key"; |
|
| 3295 | + $item->$method( $array[ "item_$key" ] ); |
|
| 3296 | + } |
|
| 3297 | + } |
|
| 3298 | 3298 | |
| 3299 | - if ( isset( $array['quantity'] ) ) { |
|
| 3300 | - $item->set_quantity( $array['quantity'] ); |
|
| 3301 | - } |
|
| 3299 | + if ( isset( $array['quantity'] ) ) { |
|
| 3300 | + $item->set_quantity( $array['quantity'] ); |
|
| 3301 | + } |
|
| 3302 | 3302 | |
| 3303 | - // Set item meta. |
|
| 3304 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3305 | - $item->set_item_meta( $array['meta'] ); |
|
| 3306 | - } |
|
| 3303 | + // Set item meta. |
|
| 3304 | + if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3305 | + $item->set_item_meta( $array['meta'] ); |
|
| 3306 | + } |
|
| 3307 | 3307 | |
| 3308 | - return $item; |
|
| 3308 | + return $item; |
|
| 3309 | 3309 | |
| 3310 | - } |
|
| 3310 | + } |
|
| 3311 | 3311 | |
| 3312 | 3312 | /** |
| 3313 | - * Retrieves a specific item. |
|
| 3314 | - * |
|
| 3315 | - * @since 1.0.19 |
|
| 3316 | - * @return GetPaid_Form_Item|null |
|
| 3317 | - */ |
|
| 3318 | - public function get_item( $item_id ) { |
|
| 3313 | + * Retrieves a specific item. |
|
| 3314 | + * |
|
| 3315 | + * @since 1.0.19 |
|
| 3316 | + * @return GetPaid_Form_Item|null |
|
| 3317 | + */ |
|
| 3318 | + public function get_item( $item_id ) { |
|
| 3319 | 3319 | |
| 3320 | - foreach ( $this->get_items() as $item ) { |
|
| 3321 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3322 | - return $item; |
|
| 3323 | - } |
|
| 3324 | - } |
|
| 3320 | + foreach ( $this->get_items() as $item ) { |
|
| 3321 | + if ( (int) $item_id == $item->get_id() ) { |
|
| 3322 | + return $item; |
|
| 3323 | + } |
|
| 3324 | + } |
|
| 3325 | 3325 | |
| 3326 | - return null; |
|
| 3326 | + return null; |
|
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | 3329 | /** |
| 3330 | - * Removes a specific item. |
|
| 3331 | - * |
|
| 3332 | - * @since 1.0.19 |
|
| 3333 | - */ |
|
| 3334 | - public function remove_item( $item_id ) { |
|
| 3335 | - $items = $this->get_items(); |
|
| 3336 | - $item_id = (int) $item_id; |
|
| 3330 | + * Removes a specific item. |
|
| 3331 | + * |
|
| 3332 | + * @since 1.0.19 |
|
| 3333 | + */ |
|
| 3334 | + public function remove_item( $item_id ) { |
|
| 3335 | + $items = $this->get_items(); |
|
| 3336 | + $item_id = (int) $item_id; |
|
| 3337 | 3337 | |
| 3338 | - foreach ( $items as $index => $item ) { |
|
| 3339 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3340 | - unset( $items[ $index ] ); |
|
| 3341 | - $this->set_prop( 'items', $items ); |
|
| 3338 | + foreach ( $items as $index => $item ) { |
|
| 3339 | + if ( (int) $item_id == $item->get_id() ) { |
|
| 3340 | + unset( $items[ $index ] ); |
|
| 3341 | + $this->set_prop( 'items', $items ); |
|
| 3342 | 3342 | |
| 3343 | - if ( $item_id == $this->recurring_item ) { |
|
| 3344 | - $this->recurring_item = null; |
|
| 3345 | - } |
|
| 3343 | + if ( $item_id == $this->recurring_item ) { |
|
| 3344 | + $this->recurring_item = null; |
|
| 3345 | + } |
|
| 3346 | 3346 | |
| 3347 | - } |
|
| 3348 | - } |
|
| 3347 | + } |
|
| 3348 | + } |
|
| 3349 | 3349 | |
| 3350 | 3350 | } |
| 3351 | 3351 | |
| 3352 | 3352 | /** |
| 3353 | - * Adds a fee to the invoice. |
|
| 3354 | - * |
|
| 3355 | - * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3356 | - * @since 1.0.19 |
|
| 3357 | - */ |
|
| 3353 | + * Adds a fee to the invoice. |
|
| 3354 | + * |
|
| 3355 | + * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3356 | + * @since 1.0.19 |
|
| 3357 | + */ |
|
| 3358 | 3358 | public function add_fee( $fee ) { |
| 3359 | 3359 | |
| 3360 | - $fees = $this->get_fees(); |
|
| 3361 | - $fees[ $fee['name'] ] = $fee; |
|
| 3362 | - $this->set_prop( 'fees', $fees ); |
|
| 3360 | + $fees = $this->get_fees(); |
|
| 3361 | + $fees[ $fee['name'] ] = $fee; |
|
| 3362 | + $this->set_prop( 'fees', $fees ); |
|
| 3363 | 3363 | |
| 3364 | 3364 | } |
| 3365 | 3365 | |
| 3366 | 3366 | /** |
| 3367 | - * Retrieves a specific fee. |
|
| 3368 | - * |
|
| 3369 | - * @since 1.0.19 |
|
| 3370 | - */ |
|
| 3371 | - public function get_fee( $fee ) { |
|
| 3367 | + * Retrieves a specific fee. |
|
| 3368 | + * |
|
| 3369 | + * @since 1.0.19 |
|
| 3370 | + */ |
|
| 3371 | + public function get_fee( $fee ) { |
|
| 3372 | 3372 | $fees = $this->get_fees(); |
| 3373 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3373 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3374 | 3374 | } |
| 3375 | 3375 | |
| 3376 | 3376 | /** |
| 3377 | - * Removes a specific fee. |
|
| 3378 | - * |
|
| 3379 | - * @since 1.0.19 |
|
| 3380 | - */ |
|
| 3381 | - public function remove_fee( $fee ) { |
|
| 3377 | + * Removes a specific fee. |
|
| 3378 | + * |
|
| 3379 | + * @since 1.0.19 |
|
| 3380 | + */ |
|
| 3381 | + public function remove_fee( $fee ) { |
|
| 3382 | 3382 | $fees = $this->get_fees(); |
| 3383 | 3383 | if ( isset( $fees[ $fee ] ) ) { |
| 3384 | 3384 | unset( $fees[ $fee ] ); |
@@ -3386,55 +3386,55 @@ discard block |
||
| 3386 | 3386 | } |
| 3387 | 3387 | } |
| 3388 | 3388 | |
| 3389 | - /** |
|
| 3390 | - * Adds a discount to the invoice. |
|
| 3391 | - * |
|
| 3392 | - * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3393 | - * @since 1.0.19 |
|
| 3394 | - */ |
|
| 3395 | - public function add_discount( $discount ) { |
|
| 3389 | + /** |
|
| 3390 | + * Adds a discount to the invoice. |
|
| 3391 | + * |
|
| 3392 | + * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3393 | + * @since 1.0.19 |
|
| 3394 | + */ |
|
| 3395 | + public function add_discount( $discount ) { |
|
| 3396 | 3396 | |
| 3397 | - $discounts = $this->get_discounts(); |
|
| 3398 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3399 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3397 | + $discounts = $this->get_discounts(); |
|
| 3398 | + $discounts[ $discount['name'] ] = $discount; |
|
| 3399 | + $this->set_prop( 'discounts', $discounts ); |
|
| 3400 | 3400 | |
| 3401 | - } |
|
| 3401 | + } |
|
| 3402 | 3402 | |
| 3403 | 3403 | /** |
| 3404 | - * Retrieves a specific discount. |
|
| 3405 | - * |
|
| 3406 | - * @since 1.0.19 |
|
| 3407 | - * @return float |
|
| 3408 | - */ |
|
| 3409 | - public function get_discount( $discount = false ) { |
|
| 3404 | + * Retrieves a specific discount. |
|
| 3405 | + * |
|
| 3406 | + * @since 1.0.19 |
|
| 3407 | + * @return float |
|
| 3408 | + */ |
|
| 3409 | + public function get_discount( $discount = false ) { |
|
| 3410 | 3410 | |
| 3411 | - // Backwards compatibilty. |
|
| 3412 | - if ( empty( $discount ) ) { |
|
| 3413 | - return $this->get_total_discount(); |
|
| 3414 | - } |
|
| 3411 | + // Backwards compatibilty. |
|
| 3412 | + if ( empty( $discount ) ) { |
|
| 3413 | + return $this->get_total_discount(); |
|
| 3414 | + } |
|
| 3415 | 3415 | |
| 3416 | 3416 | $discounts = $this->get_discounts(); |
| 3417 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3417 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3418 | 3418 | } |
| 3419 | 3419 | |
| 3420 | 3420 | /** |
| 3421 | - * Removes a specific discount. |
|
| 3422 | - * |
|
| 3423 | - * @since 1.0.19 |
|
| 3424 | - */ |
|
| 3425 | - public function remove_discount( $discount ) { |
|
| 3421 | + * Removes a specific discount. |
|
| 3422 | + * |
|
| 3423 | + * @since 1.0.19 |
|
| 3424 | + */ |
|
| 3425 | + public function remove_discount( $discount ) { |
|
| 3426 | 3426 | $discounts = $this->get_discounts(); |
| 3427 | 3427 | if ( isset( $discounts[ $discount ] ) ) { |
| 3428 | 3428 | unset( $discounts[ $discount ] ); |
| 3429 | 3429 | $this->set_prop( 'discounts', $discounts ); |
| 3430 | 3430 | } |
| 3431 | 3431 | |
| 3432 | - if ( 'discount_code' == $discount ) { |
|
| 3433 | - foreach ( $this->get_items() as $item ) { |
|
| 3434 | - $item->item_discount = 0; |
|
| 3435 | - $item->recurring_item_discount = 0; |
|
| 3436 | - } |
|
| 3437 | - } |
|
| 3432 | + if ( 'discount_code' == $discount ) { |
|
| 3433 | + foreach ( $this->get_items() as $item ) { |
|
| 3434 | + $item->item_discount = 0; |
|
| 3435 | + $item->recurring_item_discount = 0; |
|
| 3436 | + } |
|
| 3437 | + } |
|
| 3438 | 3438 | |
| 3439 | 3439 | } |
| 3440 | 3440 | |
@@ -3447,34 +3447,34 @@ discard block |
||
| 3447 | 3447 | if ( $this->is_taxable() ) { |
| 3448 | 3448 | |
| 3449 | 3449 | $taxes = $this->get_taxes(); |
| 3450 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3451 | - $this->set_prop( 'taxes', $tax ); |
|
| 3450 | + $taxes[ $tax['name'] ] = $tax; |
|
| 3451 | + $this->set_prop( 'taxes', $tax ); |
|
| 3452 | 3452 | |
| 3453 | 3453 | } |
| 3454 | 3454 | } |
| 3455 | 3455 | |
| 3456 | 3456 | /** |
| 3457 | - * Retrieves a specific tax. |
|
| 3458 | - * |
|
| 3459 | - * @since 1.0.19 |
|
| 3460 | - */ |
|
| 3461 | - public function get_tax( $tax = null ) { |
|
| 3457 | + * Retrieves a specific tax. |
|
| 3458 | + * |
|
| 3459 | + * @since 1.0.19 |
|
| 3460 | + */ |
|
| 3461 | + public function get_tax( $tax = null ) { |
|
| 3462 | 3462 | |
| 3463 | - // Backwards compatility. |
|
| 3464 | - if ( empty( $tax ) ) { |
|
| 3465 | - return $this->get_total_tax(); |
|
| 3466 | - } |
|
| 3463 | + // Backwards compatility. |
|
| 3464 | + if ( empty( $tax ) ) { |
|
| 3465 | + return $this->get_total_tax(); |
|
| 3466 | + } |
|
| 3467 | 3467 | |
| 3468 | 3468 | $taxes = $this->get_taxes(); |
| 3469 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3469 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3470 | 3470 | } |
| 3471 | 3471 | |
| 3472 | 3472 | /** |
| 3473 | - * Removes a specific tax. |
|
| 3474 | - * |
|
| 3475 | - * @since 1.0.19 |
|
| 3476 | - */ |
|
| 3477 | - public function remove_tax( $tax ) { |
|
| 3473 | + * Removes a specific tax. |
|
| 3474 | + * |
|
| 3475 | + * @since 1.0.19 |
|
| 3476 | + */ |
|
| 3477 | + public function remove_tax( $tax ) { |
|
| 3478 | 3478 | $taxes = $this->get_taxes(); |
| 3479 | 3479 | if ( isset( $taxes[ $tax ] ) ) { |
| 3480 | 3480 | unset( $taxes[ $tax ] ); |
@@ -3483,185 +3483,185 @@ discard block |
||
| 3483 | 3483 | } |
| 3484 | 3484 | |
| 3485 | 3485 | /** |
| 3486 | - * Recalculates the invoice subtotal. |
|
| 3487 | - * |
|
| 3488 | - * @since 1.0.19 |
|
| 3489 | - * @return float The recalculated subtotal |
|
| 3490 | - */ |
|
| 3491 | - public function recalculate_subtotal() { |
|
| 3486 | + * Recalculates the invoice subtotal. |
|
| 3487 | + * |
|
| 3488 | + * @since 1.0.19 |
|
| 3489 | + * @return float The recalculated subtotal |
|
| 3490 | + */ |
|
| 3491 | + public function recalculate_subtotal() { |
|
| 3492 | 3492 | $items = $this->get_items(); |
| 3493 | - $subtotal = 0; |
|
| 3494 | - $recurring = 0; |
|
| 3493 | + $subtotal = 0; |
|
| 3494 | + $recurring = 0; |
|
| 3495 | 3495 | |
| 3496 | 3496 | foreach ( $items as $item ) { |
| 3497 | - $subtotal += $item->get_sub_total(); |
|
| 3498 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3497 | + $subtotal += $item->get_sub_total(); |
|
| 3498 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3499 | 3499 | } |
| 3500 | 3500 | |
| 3501 | - if ( wpinv_prices_include_tax() ) { |
|
| 3502 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
| 3503 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
| 3504 | - } |
|
| 3501 | + if ( wpinv_prices_include_tax() ) { |
|
| 3502 | + $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
| 3503 | + $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
| 3504 | + } |
|
| 3505 | 3505 | |
| 3506 | - $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3507 | - $this->set_subtotal( $current ); |
|
| 3506 | + $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3507 | + $this->set_subtotal( $current ); |
|
| 3508 | 3508 | |
| 3509 | - $this->totals['subtotal'] = array( |
|
| 3510 | - 'initial' => $subtotal, |
|
| 3511 | - 'recurring' => $recurring, |
|
| 3512 | - ); |
|
| 3509 | + $this->totals['subtotal'] = array( |
|
| 3510 | + 'initial' => $subtotal, |
|
| 3511 | + 'recurring' => $recurring, |
|
| 3512 | + ); |
|
| 3513 | 3513 | |
| 3514 | 3514 | return $current; |
| 3515 | 3515 | } |
| 3516 | 3516 | |
| 3517 | 3517 | /** |
| 3518 | - * Recalculates the invoice discount total. |
|
| 3519 | - * |
|
| 3520 | - * @since 1.0.19 |
|
| 3521 | - * @return float The recalculated discount |
|
| 3522 | - */ |
|
| 3523 | - public function recalculate_total_discount() { |
|
| 3518 | + * Recalculates the invoice discount total. |
|
| 3519 | + * |
|
| 3520 | + * @since 1.0.19 |
|
| 3521 | + * @return float The recalculated discount |
|
| 3522 | + */ |
|
| 3523 | + public function recalculate_total_discount() { |
|
| 3524 | 3524 | $discounts = $this->get_discounts(); |
| 3525 | - $discount = 0; |
|
| 3526 | - $recurring = 0; |
|
| 3525 | + $discount = 0; |
|
| 3526 | + $recurring = 0; |
|
| 3527 | 3527 | |
| 3528 | 3528 | foreach ( $discounts as $data ) { |
| 3529 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3530 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3531 | - } |
|
| 3529 | + $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3530 | + $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3531 | + } |
|
| 3532 | 3532 | |
| 3533 | - $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3533 | + $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3534 | 3534 | |
| 3535 | - $this->set_total_discount( $current ); |
|
| 3535 | + $this->set_total_discount( $current ); |
|
| 3536 | 3536 | |
| 3537 | - $this->totals['discount'] = array( |
|
| 3538 | - 'initial' => $discount, |
|
| 3539 | - 'recurring' => $recurring, |
|
| 3540 | - ); |
|
| 3537 | + $this->totals['discount'] = array( |
|
| 3538 | + 'initial' => $discount, |
|
| 3539 | + 'recurring' => $recurring, |
|
| 3540 | + ); |
|
| 3541 | 3541 | |
| 3542 | - return $current; |
|
| 3542 | + return $current; |
|
| 3543 | 3543 | |
| 3544 | 3544 | } |
| 3545 | 3545 | |
| 3546 | 3546 | /** |
| 3547 | - * Recalculates the invoice tax total. |
|
| 3548 | - * |
|
| 3549 | - * @since 1.0.19 |
|
| 3550 | - * @return float The recalculated tax |
|
| 3551 | - */ |
|
| 3552 | - public function recalculate_total_tax() { |
|
| 3547 | + * Recalculates the invoice tax total. |
|
| 3548 | + * |
|
| 3549 | + * @since 1.0.19 |
|
| 3550 | + * @return float The recalculated tax |
|
| 3551 | + */ |
|
| 3552 | + public function recalculate_total_tax() { |
|
| 3553 | 3553 | |
| 3554 | - // Maybe disable taxes. |
|
| 3555 | - $vat_number = $this->get_vat_number(); |
|
| 3556 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
| 3554 | + // Maybe disable taxes. |
|
| 3555 | + $vat_number = $this->get_vat_number(); |
|
| 3556 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
| 3557 | 3557 | |
| 3558 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 3559 | - $skip_tax = false; |
|
| 3560 | - } |
|
| 3558 | + if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 3559 | + $skip_tax = false; |
|
| 3560 | + } |
|
| 3561 | 3561 | |
| 3562 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
| 3562 | + if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
| 3563 | 3563 | |
| 3564 | - $this->totals['tax'] = array( |
|
| 3565 | - 'initial' => 0, |
|
| 3566 | - 'recurring' => 0, |
|
| 3567 | - ); |
|
| 3564 | + $this->totals['tax'] = array( |
|
| 3565 | + 'initial' => 0, |
|
| 3566 | + 'recurring' => 0, |
|
| 3567 | + ); |
|
| 3568 | 3568 | |
| 3569 | - $this->tax_rate = 0; |
|
| 3569 | + $this->tax_rate = 0; |
|
| 3570 | 3570 | |
| 3571 | - $this->set_taxes( array() ); |
|
| 3572 | - $current = 0; |
|
| 3573 | - } else { |
|
| 3571 | + $this->set_taxes( array() ); |
|
| 3572 | + $current = 0; |
|
| 3573 | + } else { |
|
| 3574 | 3574 | |
| 3575 | - $item_taxes = array(); |
|
| 3575 | + $item_taxes = array(); |
|
| 3576 | 3576 | |
| 3577 | - foreach ( $this->get_items() as $item ) { |
|
| 3578 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
| 3579 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 3580 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 3581 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 3582 | - foreach ( $taxes as $name => $amount ) { |
|
| 3583 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 3584 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 3577 | + foreach ( $this->get_items() as $item ) { |
|
| 3578 | + $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
| 3579 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 3580 | + $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 3581 | + $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 3582 | + foreach ( $taxes as $name => $amount ) { |
|
| 3583 | + $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 3584 | + $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 3585 | 3585 | |
| 3586 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
| 3587 | - $item_taxes[ $name ] = $tax; |
|
| 3588 | - continue; |
|
| 3589 | - } |
|
| 3586 | + if ( ! isset( $item_taxes[ $name ] ) ) { |
|
| 3587 | + $item_taxes[ $name ] = $tax; |
|
| 3588 | + continue; |
|
| 3589 | + } |
|
| 3590 | 3590 | |
| 3591 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 3592 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3591 | + $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 3592 | + $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3593 | 3593 | |
| 3594 | - } |
|
| 3594 | + } |
|
| 3595 | 3595 | |
| 3596 | - } |
|
| 3596 | + } |
|
| 3597 | 3597 | |
| 3598 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
| 3599 | - $this->set_taxes( $item_taxes ); |
|
| 3598 | + $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
| 3599 | + $this->set_taxes( $item_taxes ); |
|
| 3600 | 3600 | |
| 3601 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
| 3602 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
| 3601 | + $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
| 3602 | + $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
| 3603 | 3603 | |
| 3604 | - $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
|
| 3604 | + $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
|
| 3605 | 3605 | |
| 3606 | - $this->totals['tax'] = array( |
|
| 3607 | - 'initial' => $initial_tax, |
|
| 3608 | - 'recurring' => $recurring_tax, |
|
| 3609 | - ); |
|
| 3606 | + $this->totals['tax'] = array( |
|
| 3607 | + 'initial' => $initial_tax, |
|
| 3608 | + 'recurring' => $recurring_tax, |
|
| 3609 | + ); |
|
| 3610 | 3610 | |
| 3611 | - } |
|
| 3611 | + } |
|
| 3612 | 3612 | |
| 3613 | - $this->set_total_tax( $current ); |
|
| 3613 | + $this->set_total_tax( $current ); |
|
| 3614 | 3614 | |
| 3615 | - return $current; |
|
| 3615 | + return $current; |
|
| 3616 | 3616 | |
| 3617 | 3617 | } |
| 3618 | 3618 | |
| 3619 | 3619 | /** |
| 3620 | - * Recalculates the invoice fees total. |
|
| 3621 | - * |
|
| 3622 | - * @since 1.0.19 |
|
| 3623 | - * @return float The recalculated fee |
|
| 3624 | - */ |
|
| 3625 | - public function recalculate_total_fees() { |
|
| 3626 | - $fees = $this->get_fees(); |
|
| 3627 | - $fee = 0; |
|
| 3628 | - $recurring = 0; |
|
| 3620 | + * Recalculates the invoice fees total. |
|
| 3621 | + * |
|
| 3622 | + * @since 1.0.19 |
|
| 3623 | + * @return float The recalculated fee |
|
| 3624 | + */ |
|
| 3625 | + public function recalculate_total_fees() { |
|
| 3626 | + $fees = $this->get_fees(); |
|
| 3627 | + $fee = 0; |
|
| 3628 | + $recurring = 0; |
|
| 3629 | 3629 | |
| 3630 | 3630 | foreach ( $fees as $data ) { |
| 3631 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3632 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3633 | - } |
|
| 3631 | + $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3632 | + $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3633 | + } |
|
| 3634 | 3634 | |
| 3635 | - $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3636 | - $this->set_total_fees( $current ); |
|
| 3635 | + $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3636 | + $this->set_total_fees( $current ); |
|
| 3637 | 3637 | |
| 3638 | - $this->totals['fee'] = array( |
|
| 3639 | - 'initial' => $fee, |
|
| 3640 | - 'recurring' => $recurring, |
|
| 3641 | - ); |
|
| 3638 | + $this->totals['fee'] = array( |
|
| 3639 | + 'initial' => $fee, |
|
| 3640 | + 'recurring' => $recurring, |
|
| 3641 | + ); |
|
| 3642 | 3642 | |
| 3643 | 3643 | $this->set_total_fees( $fee ); |
| 3644 | 3644 | return $current; |
| 3645 | 3645 | } |
| 3646 | 3646 | |
| 3647 | 3647 | /** |
| 3648 | - * Recalculates the invoice total. |
|
| 3649 | - * |
|
| 3650 | - * @since 1.0.19 |
|
| 3648 | + * Recalculates the invoice total. |
|
| 3649 | + * |
|
| 3650 | + * @since 1.0.19 |
|
| 3651 | 3651 | * @return float The invoice total |
| 3652 | - */ |
|
| 3653 | - public function recalculate_total() { |
|
| 3652 | + */ |
|
| 3653 | + public function recalculate_total() { |
|
| 3654 | 3654 | $this->recalculate_total_fees(); |
| 3655 | 3655 | $this->recalculate_total_discount(); |
| 3656 | - $this->recalculate_total_tax(); |
|
| 3657 | - $this->recalculate_subtotal(); |
|
| 3658 | - $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
| 3659 | - return $this->get_total(); |
|
| 3660 | - } |
|
| 3661 | - |
|
| 3662 | - /** |
|
| 3663 | - * @deprecated |
|
| 3664 | - */ |
|
| 3656 | + $this->recalculate_total_tax(); |
|
| 3657 | + $this->recalculate_subtotal(); |
|
| 3658 | + $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
| 3659 | + return $this->get_total(); |
|
| 3660 | + } |
|
| 3661 | + |
|
| 3662 | + /** |
|
| 3663 | + * @deprecated |
|
| 3664 | + */ |
|
| 3665 | 3665 | public function recalculate_totals() { |
| 3666 | 3666 | $this->recalculate_total(); |
| 3667 | 3667 | $this->save( true ); |
@@ -3675,22 +3675,22 @@ discard block |
||
| 3675 | 3675 | return $this->get_data(); |
| 3676 | 3676 | } |
| 3677 | 3677 | |
| 3678 | - /** |
|
| 3678 | + /** |
|
| 3679 | 3679 | * Adds a system note to an invoice. |
| 3680 | 3680 | * |
| 3681 | 3681 | * @param string $note The note being added. |
| 3682 | - * @return int|false The new note's ID on success, false on failure. |
|
| 3682 | + * @return int|false The new note's ID on success, false on failure. |
|
| 3683 | 3683 | * |
| 3684 | 3684 | */ |
| 3685 | 3685 | public function add_system_note( $note ) { |
| 3686 | - return $this->add_note( $note, false, false, true ); |
|
| 3687 | - } |
|
| 3686 | + return $this->add_note( $note, false, false, true ); |
|
| 3687 | + } |
|
| 3688 | 3688 | |
| 3689 | 3689 | /** |
| 3690 | 3690 | * Adds a note to an invoice. |
| 3691 | 3691 | * |
| 3692 | 3692 | * @param string $note The note being added. |
| 3693 | - * @return int|false The new note's ID on success, false on failure. |
|
| 3693 | + * @return int|false The new note's ID on success, false on failure. |
|
| 3694 | 3694 | * |
| 3695 | 3695 | */ |
| 3696 | 3696 | public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
@@ -3700,21 +3700,21 @@ discard block |
||
| 3700 | 3700 | return false; |
| 3701 | 3701 | } |
| 3702 | 3702 | |
| 3703 | - $author = 'System'; |
|
| 3704 | - $author_email = '[email protected]'; |
|
| 3703 | + $author = 'System'; |
|
| 3704 | + $author_email = '[email protected]'; |
|
| 3705 | 3705 | |
| 3706 | - // If this is an admin comment or it has been added by the user. |
|
| 3707 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3708 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3706 | + // If this is an admin comment or it has been added by the user. |
|
| 3707 | + if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3708 | + $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3709 | 3709 | $author = $user->display_name; |
| 3710 | 3710 | $author_email = $user->user_email; |
| 3711 | - } |
|
| 3711 | + } |
|
| 3712 | 3712 | |
| 3713 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3713 | + return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3714 | 3714 | |
| 3715 | - } |
|
| 3715 | + } |
|
| 3716 | 3716 | |
| 3717 | - /** |
|
| 3717 | + /** |
|
| 3718 | 3718 | * Generates a unique key for the invoice. |
| 3719 | 3719 | */ |
| 3720 | 3720 | public function generate_key( $string = '' ) { |
@@ -3734,113 +3734,113 @@ discard block |
||
| 3734 | 3734 | $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
| 3735 | 3735 | } |
| 3736 | 3736 | |
| 3737 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3738 | - |
|
| 3739 | - } |
|
| 3740 | - |
|
| 3741 | - /** |
|
| 3742 | - * Handle the status transition. |
|
| 3743 | - */ |
|
| 3744 | - protected function status_transition() { |
|
| 3745 | - $status_transition = $this->status_transition; |
|
| 3746 | - |
|
| 3747 | - // Reset status transition variable. |
|
| 3748 | - $this->status_transition = false; |
|
| 3737 | + return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3749 | 3738 | |
| 3750 | - if ( $status_transition ) { |
|
| 3751 | - try { |
|
| 3752 | - |
|
| 3753 | - // Fire a hook for the status change. |
|
| 3754 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3755 | - |
|
| 3756 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3757 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3758 | - |
|
| 3759 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3760 | - |
|
| 3761 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3762 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3763 | - |
|
| 3764 | - // Fire another hook. |
|
| 3765 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3766 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3767 | - |
|
| 3768 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3769 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3770 | - |
|
| 3771 | - // Note the transition occurred. |
|
| 3772 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3773 | - |
|
| 3774 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3775 | - if ( |
|
| 3776 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3777 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3778 | - ) { |
|
| 3779 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3780 | - } |
|
| 3781 | - |
|
| 3782 | - // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3783 | - if ( |
|
| 3784 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3785 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3786 | - ) { |
|
| 3787 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3788 | - } |
|
| 3789 | - } else { |
|
| 3790 | - /* translators: %s: new invoice status */ |
|
| 3791 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3792 | - |
|
| 3793 | - // Note the transition occurred. |
|
| 3794 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3739 | + } |
|
| 3795 | 3740 | |
| 3796 | - } |
|
| 3797 | - } catch ( Exception $e ) { |
|
| 3798 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3799 | - } |
|
| 3800 | - } |
|
| 3801 | - } |
|
| 3741 | + /** |
|
| 3742 | + * Handle the status transition. |
|
| 3743 | + */ |
|
| 3744 | + protected function status_transition() { |
|
| 3745 | + $status_transition = $this->status_transition; |
|
| 3746 | + |
|
| 3747 | + // Reset status transition variable. |
|
| 3748 | + $this->status_transition = false; |
|
| 3749 | + |
|
| 3750 | + if ( $status_transition ) { |
|
| 3751 | + try { |
|
| 3752 | + |
|
| 3753 | + // Fire a hook for the status change. |
|
| 3754 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3755 | + |
|
| 3756 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3757 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3758 | + |
|
| 3759 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3760 | + |
|
| 3761 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3762 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3763 | + |
|
| 3764 | + // Fire another hook. |
|
| 3765 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3766 | + do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3767 | + |
|
| 3768 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3769 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3770 | + |
|
| 3771 | + // Note the transition occurred. |
|
| 3772 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3773 | + |
|
| 3774 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3775 | + if ( |
|
| 3776 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3777 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3778 | + ) { |
|
| 3779 | + do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3780 | + } |
|
| 3781 | + |
|
| 3782 | + // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3783 | + if ( |
|
| 3784 | + in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3785 | + && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3786 | + ) { |
|
| 3787 | + do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3788 | + } |
|
| 3789 | + } else { |
|
| 3790 | + /* translators: %s: new invoice status */ |
|
| 3791 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3792 | + |
|
| 3793 | + // Note the transition occurred. |
|
| 3794 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3795 | + |
|
| 3796 | + } |
|
| 3797 | + } catch ( Exception $e ) { |
|
| 3798 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3799 | + } |
|
| 3800 | + } |
|
| 3801 | + } |
|
| 3802 | 3802 | |
| 3803 | - /** |
|
| 3804 | - * Updates an invoice status. |
|
| 3805 | - */ |
|
| 3806 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3803 | + /** |
|
| 3804 | + * Updates an invoice status. |
|
| 3805 | + */ |
|
| 3806 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3807 | 3807 | |
| 3808 | - // Fires before updating a status. |
|
| 3809 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3808 | + // Fires before updating a status. |
|
| 3809 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3810 | 3810 | |
| 3811 | - // Update the status. |
|
| 3812 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3811 | + // Update the status. |
|
| 3812 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3813 | 3813 | |
| 3814 | - // Save the order. |
|
| 3815 | - return $this->save(); |
|
| 3814 | + // Save the order. |
|
| 3815 | + return $this->save(); |
|
| 3816 | 3816 | |
| 3817 | - } |
|
| 3817 | + } |
|
| 3818 | 3818 | |
| 3819 | - /** |
|
| 3820 | - * @deprecated |
|
| 3821 | - */ |
|
| 3822 | - public function refresh_item_ids() { |
|
| 3819 | + /** |
|
| 3820 | + * @deprecated |
|
| 3821 | + */ |
|
| 3822 | + public function refresh_item_ids() { |
|
| 3823 | 3823 | $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
| 3824 | 3824 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3825 | - } |
|
| 3825 | + } |
|
| 3826 | 3826 | |
| 3827 | - /** |
|
| 3828 | - * @deprecated |
|
| 3829 | - */ |
|
| 3830 | - public function update_items( $temp = false ) { |
|
| 3827 | + /** |
|
| 3828 | + * @deprecated |
|
| 3829 | + */ |
|
| 3830 | + public function update_items( $temp = false ) { |
|
| 3831 | 3831 | |
| 3832 | - $this->set_items( $this->get_items() ); |
|
| 3832 | + $this->set_items( $this->get_items() ); |
|
| 3833 | 3833 | |
| 3834 | - if ( ! $temp ) { |
|
| 3835 | - $this->save(); |
|
| 3836 | - } |
|
| 3834 | + if ( ! $temp ) { |
|
| 3835 | + $this->save(); |
|
| 3836 | + } |
|
| 3837 | 3837 | |
| 3838 | 3838 | return $this; |
| 3839 | - } |
|
| 3839 | + } |
|
| 3840 | 3840 | |
| 3841 | - /** |
|
| 3842 | - * @deprecated |
|
| 3843 | - */ |
|
| 3841 | + /** |
|
| 3842 | + * @deprecated |
|
| 3843 | + */ |
|
| 3844 | 3844 | public function validate_discount() { |
| 3845 | 3845 | |
| 3846 | 3846 | $discount_code = $this->get_discount_code(); |
@@ -3856,93 +3856,93 @@ discard block |
||
| 3856 | 3856 | |
| 3857 | 3857 | } |
| 3858 | 3858 | |
| 3859 | - /** |
|
| 3860 | - * Refunds an invoice. |
|
| 3861 | - */ |
|
| 3859 | + /** |
|
| 3860 | + * Refunds an invoice. |
|
| 3861 | + */ |
|
| 3862 | 3862 | public function refund() { |
| 3863 | - $this->set_status( 'wpi-refunded' ); |
|
| 3863 | + $this->set_status( 'wpi-refunded' ); |
|
| 3864 | 3864 | $this->save(); |
| 3865 | - } |
|
| 3865 | + } |
|
| 3866 | 3866 | |
| 3867 | - /** |
|
| 3868 | - * Marks an invoice as paid. |
|
| 3869 | - * |
|
| 3870 | - * @param string $transaction_id |
|
| 3871 | - */ |
|
| 3867 | + /** |
|
| 3868 | + * Marks an invoice as paid. |
|
| 3869 | + * |
|
| 3870 | + * @param string $transaction_id |
|
| 3871 | + */ |
|
| 3872 | 3872 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3873 | 3873 | |
| 3874 | - // Set the transaction id. |
|
| 3875 | - if ( empty( $transaction_id ) ) { |
|
| 3876 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3877 | - } |
|
| 3874 | + // Set the transaction id. |
|
| 3875 | + if ( empty( $transaction_id ) ) { |
|
| 3876 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3877 | + } |
|
| 3878 | 3878 | |
| 3879 | - if ( ! $this->get_transaction_id() ) { |
|
| 3880 | - $this->set_transaction_id( $transaction_id ); |
|
| 3881 | - } |
|
| 3879 | + if ( ! $this->get_transaction_id() ) { |
|
| 3880 | + $this->set_transaction_id( $transaction_id ); |
|
| 3881 | + } |
|
| 3882 | 3882 | |
| 3883 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3884 | - return $this->save(); |
|
| 3885 | - } |
|
| 3883 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3884 | + return $this->save(); |
|
| 3885 | + } |
|
| 3886 | 3886 | |
| 3887 | - // Set the completed date. |
|
| 3888 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3887 | + // Set the completed date. |
|
| 3888 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3889 | 3889 | |
| 3890 | - // Set the new status. |
|
| 3891 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
| 3892 | - if ( $this->is_renewal() || ! $this->is_parent() ) { |
|
| 3890 | + // Set the new status. |
|
| 3891 | + $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
| 3892 | + if ( $this->is_renewal() || ! $this->is_parent() ) { |
|
| 3893 | 3893 | |
| 3894 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
| 3895 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3894 | + $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
| 3895 | + $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3896 | 3896 | |
| 3897 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3898 | - $_note = $note; |
|
| 3899 | - } |
|
| 3897 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3898 | + $_note = $note; |
|
| 3899 | + } |
|
| 3900 | 3900 | |
| 3901 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3901 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3902 | 3902 | |
| 3903 | - } else { |
|
| 3903 | + } else { |
|
| 3904 | 3904 | |
| 3905 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 3906 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3905 | + $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 3906 | + $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3907 | 3907 | |
| 3908 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3909 | - $_note = $note; |
|
| 3910 | - } |
|
| 3908 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3909 | + $_note = $note; |
|
| 3910 | + } |
|
| 3911 | 3911 | |
| 3912 | - $this->set_status( 'publish', $_note ); |
|
| 3912 | + $this->set_status( 'publish', $_note ); |
|
| 3913 | 3913 | |
| 3914 | - } |
|
| 3914 | + } |
|
| 3915 | 3915 | |
| 3916 | - // Set checkout mode. |
|
| 3917 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3918 | - $this->set_mode( $mode ); |
|
| 3916 | + // Set checkout mode. |
|
| 3917 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3918 | + $this->set_mode( $mode ); |
|
| 3919 | 3919 | |
| 3920 | - // Save the invoice. |
|
| 3920 | + // Save the invoice. |
|
| 3921 | 3921 | $this->save(); |
| 3922 | - } |
|
| 3923 | - |
|
| 3924 | - /** |
|
| 3925 | - * Save data to the database. |
|
| 3926 | - * |
|
| 3927 | - * @since 1.0.19 |
|
| 3928 | - * @return int invoice ID |
|
| 3929 | - */ |
|
| 3930 | - public function save() { |
|
| 3931 | - $this->maybe_set_date_paid(); |
|
| 3932 | - $this->maybe_set_key(); |
|
| 3933 | - parent::save(); |
|
| 3934 | - $this->clear_cache(); |
|
| 3935 | - $this->status_transition(); |
|
| 3936 | - return $this->get_id(); |
|
| 3937 | - } |
|
| 3938 | - |
|
| 3939 | - /** |
|
| 3922 | + } |
|
| 3923 | + |
|
| 3924 | + /** |
|
| 3925 | + * Save data to the database. |
|
| 3926 | + * |
|
| 3927 | + * @since 1.0.19 |
|
| 3928 | + * @return int invoice ID |
|
| 3929 | + */ |
|
| 3930 | + public function save() { |
|
| 3931 | + $this->maybe_set_date_paid(); |
|
| 3932 | + $this->maybe_set_key(); |
|
| 3933 | + parent::save(); |
|
| 3934 | + $this->clear_cache(); |
|
| 3935 | + $this->status_transition(); |
|
| 3936 | + return $this->get_id(); |
|
| 3937 | + } |
|
| 3938 | + |
|
| 3939 | + /** |
|
| 3940 | 3940 | * Clears the subscription's cache. |
| 3941 | 3941 | */ |
| 3942 | 3942 | public function clear_cache() { |
| 3943 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3944 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3945 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3946 | - } |
|
| 3943 | + wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3944 | + wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3945 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3946 | + } |
|
| 3947 | 3947 | |
| 3948 | 3948 | } |
@@ -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 | * Invoice class. |
@@ -144,40 +144,40 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 146 | 146 | */ |
| 147 | - public function __construct( $invoice = 0 ) { |
|
| 147 | + public function __construct($invoice = 0) { |
|
| 148 | 148 | |
| 149 | - parent::__construct( $invoice ); |
|
| 149 | + parent::__construct($invoice); |
|
| 150 | 150 | |
| 151 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 152 | - $this->set_id( (int) $invoice ); |
|
| 153 | - } elseif ( $invoice instanceof self ) { |
|
| 154 | - $this->set_id( $invoice->get_id() ); |
|
| 155 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 156 | - $this->set_id( $invoice->ID ); |
|
| 157 | - } elseif ( is_array( $invoice ) ) { |
|
| 158 | - $this->set_props( $invoice ); |
|
| 151 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
| 152 | + $this->set_id((int) $invoice); |
|
| 153 | + } elseif ($invoice instanceof self) { |
|
| 154 | + $this->set_id($invoice->get_id()); |
|
| 155 | + } elseif (!empty($invoice->ID)) { |
|
| 156 | + $this->set_id($invoice->ID); |
|
| 157 | + } elseif (is_array($invoice)) { |
|
| 158 | + $this->set_props($invoice); |
|
| 159 | 159 | |
| 160 | - if ( isset( $invoice['ID'] ) ) { |
|
| 161 | - $this->set_id( $invoice['ID'] ); |
|
| 160 | + if (isset($invoice['ID'])) { |
|
| 161 | + $this->set_id($invoice['ID']); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 165 | - $this->set_id( $invoice_id ); |
|
| 166 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 167 | - $this->set_id( $invoice_id ); |
|
| 168 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 169 | - $this->set_id( $invoice_id ); |
|
| 164 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 165 | + $this->set_id($invoice_id); |
|
| 166 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 167 | + $this->set_id($invoice_id); |
|
| 168 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 169 | + $this->set_id($invoice_id); |
|
| 170 | 170 | } else { |
| 171 | - $this->set_object_read( true ); |
|
| 171 | + $this->set_object_read(true); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Load the datastore. |
| 175 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 175 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 176 | 176 | |
| 177 | - if ( $this->get_id() > 0 ) { |
|
| 178 | - $this->post = get_post( $this->get_id() ); |
|
| 177 | + if ($this->get_id() > 0) { |
|
| 178 | + $this->post = get_post($this->get_id()); |
|
| 179 | 179 | $this->ID = $this->get_id(); |
| 180 | - $this->data_store->read( $this ); |
|
| 180 | + $this->data_store->read($this); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
@@ -192,38 +192,38 @@ discard block |
||
| 192 | 192 | * @since 1.0.15 |
| 193 | 193 | * @return int |
| 194 | 194 | */ |
| 195 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 195 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 196 | 196 | global $wpdb; |
| 197 | 197 | |
| 198 | 198 | // Trim the value. |
| 199 | - $value = trim( $value ); |
|
| 199 | + $value = trim($value); |
|
| 200 | 200 | |
| 201 | - if ( empty( $value ) ) { |
|
| 201 | + if (empty($value)) { |
|
| 202 | 202 | return 0; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Valid fields. |
| 206 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 206 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 207 | 207 | |
| 208 | 208 | // Ensure a field has been passed. |
| 209 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 209 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 210 | 210 | return 0; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Maybe retrieve from the cache. |
| 214 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 215 | - if ( false !== $invoice_id ) { |
|
| 214 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 215 | + if (false !== $invoice_id) { |
|
| 216 | 216 | return $invoice_id; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Fetch from the db. |
| 220 | 220 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 221 | 221 | $invoice_id = (int) $wpdb->get_var( |
| 222 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 222 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | 225 | // Update the cache with our data |
| 226 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 226 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 227 | 227 | |
| 228 | 228 | return $invoice_id; |
| 229 | 229 | } |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | /** |
| 232 | 232 | * Checks if an invoice key is set. |
| 233 | 233 | */ |
| 234 | - public function _isset( $key ) { |
|
| 235 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 234 | + public function _isset($key) { |
|
| 235 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /* |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | * @param string $context View or edit context. |
| 258 | 258 | * @return int |
| 259 | 259 | */ |
| 260 | - public function get_parent_id( $context = 'view' ) { |
|
| 261 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 260 | + public function get_parent_id($context = 'view') { |
|
| 261 | + return (int) $this->get_prop('parent_id', $context); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @return WPInv_Invoice |
| 269 | 269 | */ |
| 270 | 270 | public function get_parent_payment() { |
| 271 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 271 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | * @param string $context View or edit context. |
| 289 | 289 | * @return string |
| 290 | 290 | */ |
| 291 | - public function get_status( $context = 'view' ) { |
|
| 292 | - return $this->get_prop( 'status', $context ); |
|
| 291 | + public function get_status($context = 'view') { |
|
| 292 | + return $this->get_prop('status', $context); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return array |
| 300 | 300 | */ |
| 301 | 301 | public function get_all_statuses() { |
| 302 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 302 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | public function get_status_nicename() { |
| 312 | 312 | $statuses = $this->get_all_statuses(); |
| 313 | 313 | |
| 314 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 314 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 315 | 315 | |
| 316 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 316 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public function get_status_class() { |
| 326 | 326 | $statuses = getpaid_get_invoice_status_classes(); |
| 327 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
| 327 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -335,9 +335,9 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function get_status_label_html() { |
| 337 | 337 | |
| 338 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 339 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 340 | - $class = esc_attr( $this->get_status_class() ); |
|
| 338 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
| 339 | + $status = sanitize_html_class($this->get_status()); |
|
| 340 | + $class = esc_attr($this->get_status_class()); |
|
| 341 | 341 | |
| 342 | 342 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
| 343 | 343 | } |
@@ -349,23 +349,23 @@ discard block |
||
| 349 | 349 | * @param string $context View or edit context. |
| 350 | 350 | * @return string |
| 351 | 351 | */ |
| 352 | - public function get_version( $context = 'view' ) { |
|
| 353 | - return $this->get_prop( 'version', $context ); |
|
| 352 | + public function get_version($context = 'view') { |
|
| 353 | + return $this->get_prop('version', $context); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * @deprecated |
| 358 | 358 | */ |
| 359 | - public function get_invoice_date( $format = true ) { |
|
| 360 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 361 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 362 | - $formatted = getpaid_format_date( $date ); |
|
| 359 | + public function get_invoice_date($format = true) { |
|
| 360 | + $date = getpaid_format_date($this->get_date_completed()); |
|
| 361 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 362 | + $formatted = getpaid_format_date($date); |
|
| 363 | 363 | |
| 364 | - if ( $format ) { |
|
| 364 | + if ($format) { |
|
| 365 | 365 | return $formatted; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - return empty( $formatted ) ? '' : $date; |
|
| 368 | + return empty($formatted) ? '' : $date; |
|
| 369 | 369 | |
| 370 | 370 | } |
| 371 | 371 | |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | * @param string $context View or edit context. |
| 377 | 377 | * @return string |
| 378 | 378 | */ |
| 379 | - public function get_date_created( $context = 'view' ) { |
|
| 380 | - return $this->get_prop( 'date_created', $context ); |
|
| 379 | + public function get_date_created($context = 'view') { |
|
| 380 | + return $this->get_prop('date_created', $context); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | * @param string $context View or edit context. |
| 388 | 388 | * @return string |
| 389 | 389 | */ |
| 390 | - public function get_created_date( $context = 'view' ) { |
|
| 391 | - return $this->get_date_created( $context ); |
|
| 390 | + public function get_created_date($context = 'view') { |
|
| 391 | + return $this->get_date_created($context); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -398,11 +398,11 @@ discard block |
||
| 398 | 398 | * @param string $context View or edit context. |
| 399 | 399 | * @return string |
| 400 | 400 | */ |
| 401 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 402 | - $date = $this->get_date_created( $context ); |
|
| 401 | + public function get_date_created_gmt($context = 'view') { |
|
| 402 | + $date = $this->get_date_created($context); |
|
| 403 | 403 | |
| 404 | - if ( $date ) { |
|
| 405 | - $date = get_gmt_from_date( $date ); |
|
| 404 | + if ($date) { |
|
| 405 | + $date = get_gmt_from_date($date); |
|
| 406 | 406 | } |
| 407 | 407 | return $date; |
| 408 | 408 | } |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | * @param string $context View or edit context. |
| 415 | 415 | * @return string |
| 416 | 416 | */ |
| 417 | - public function get_date_modified( $context = 'view' ) { |
|
| 418 | - return $this->get_prop( 'date_modified', $context ); |
|
| 417 | + public function get_date_modified($context = 'view') { |
|
| 418 | + return $this->get_prop('date_modified', $context); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -425,8 +425,8 @@ discard block |
||
| 425 | 425 | * @param string $context View or edit context. |
| 426 | 426 | * @return string |
| 427 | 427 | */ |
| 428 | - public function get_modified_date( $context = 'view' ) { |
|
| 429 | - return $this->get_date_modified( $context ); |
|
| 428 | + public function get_modified_date($context = 'view') { |
|
| 429 | + return $this->get_date_modified($context); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -436,11 +436,11 @@ discard block |
||
| 436 | 436 | * @param string $context View or edit context. |
| 437 | 437 | * @return string |
| 438 | 438 | */ |
| 439 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 440 | - $date = $this->get_date_modified( $context ); |
|
| 439 | + public function get_date_modified_gmt($context = 'view') { |
|
| 440 | + $date = $this->get_date_modified($context); |
|
| 441 | 441 | |
| 442 | - if ( $date ) { |
|
| 443 | - $date = get_gmt_from_date( $date ); |
|
| 442 | + if ($date) { |
|
| 443 | + $date = get_gmt_from_date($date); |
|
| 444 | 444 | } |
| 445 | 445 | return $date; |
| 446 | 446 | } |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | * @param string $context View or edit context. |
| 453 | 453 | * @return string |
| 454 | 454 | */ |
| 455 | - public function get_due_date( $context = 'view' ) { |
|
| 456 | - return $this->get_prop( 'due_date', $context ); |
|
| 455 | + public function get_due_date($context = 'view') { |
|
| 456 | + return $this->get_prop('due_date', $context); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -463,8 +463,8 @@ discard block |
||
| 463 | 463 | * @param string $context View or edit context. |
| 464 | 464 | * @return string |
| 465 | 465 | */ |
| 466 | - public function get_date_due( $context = 'view' ) { |
|
| 467 | - return $this->get_due_date( $context ); |
|
| 466 | + public function get_date_due($context = 'view') { |
|
| 467 | + return $this->get_due_date($context); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -474,11 +474,11 @@ discard block |
||
| 474 | 474 | * @param string $context View or edit context. |
| 475 | 475 | * @return string |
| 476 | 476 | */ |
| 477 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 478 | - $date = $this->get_due_date( $context ); |
|
| 477 | + public function get_due_date_gmt($context = 'view') { |
|
| 478 | + $date = $this->get_due_date($context); |
|
| 479 | 479 | |
| 480 | - if ( $date ) { |
|
| 481 | - $date = get_gmt_from_date( $date ); |
|
| 480 | + if ($date) { |
|
| 481 | + $date = get_gmt_from_date($date); |
|
| 482 | 482 | } |
| 483 | 483 | return $date; |
| 484 | 484 | } |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | * @param string $context View or edit context. |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 494 | - return $this->get_due_date_gmt( $context ); |
|
| 493 | + public function get_gmt_date_due($context = 'view') { |
|
| 494 | + return $this->get_due_date_gmt($context); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
@@ -501,8 +501,8 @@ discard block |
||
| 501 | 501 | * @param string $context View or edit context. |
| 502 | 502 | * @return string |
| 503 | 503 | */ |
| 504 | - public function get_completed_date( $context = 'view' ) { |
|
| 505 | - return $this->get_prop( 'completed_date', $context ); |
|
| 504 | + public function get_completed_date($context = 'view') { |
|
| 505 | + return $this->get_prop('completed_date', $context); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -512,8 +512,8 @@ discard block |
||
| 512 | 512 | * @param string $context View or edit context. |
| 513 | 513 | * @return string |
| 514 | 514 | */ |
| 515 | - public function get_date_completed( $context = 'view' ) { |
|
| 516 | - return $this->get_completed_date( $context ); |
|
| 515 | + public function get_date_completed($context = 'view') { |
|
| 516 | + return $this->get_completed_date($context); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -523,11 +523,11 @@ discard block |
||
| 523 | 523 | * @param string $context View or edit context. |
| 524 | 524 | * @return string |
| 525 | 525 | */ |
| 526 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 527 | - $date = $this->get_completed_date( $context ); |
|
| 526 | + public function get_completed_date_gmt($context = 'view') { |
|
| 527 | + $date = $this->get_completed_date($context); |
|
| 528 | 528 | |
| 529 | - if ( $date ) { |
|
| 530 | - $date = get_gmt_from_date( $date ); |
|
| 529 | + if ($date) { |
|
| 530 | + $date = get_gmt_from_date($date); |
|
| 531 | 531 | } |
| 532 | 532 | return $date; |
| 533 | 533 | } |
@@ -539,8 +539,8 @@ discard block |
||
| 539 | 539 | * @param string $context View or edit context. |
| 540 | 540 | * @return string |
| 541 | 541 | */ |
| 542 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 543 | - return $this->get_completed_date_gmt( $context ); |
|
| 542 | + public function get_gmt_completed_date($context = 'view') { |
|
| 543 | + return $this->get_completed_date_gmt($context); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -550,12 +550,12 @@ discard block |
||
| 550 | 550 | * @param string $context View or edit context. |
| 551 | 551 | * @return string |
| 552 | 552 | */ |
| 553 | - public function get_number( $context = 'view' ) { |
|
| 554 | - $number = $this->get_prop( 'number', $context ); |
|
| 553 | + public function get_number($context = 'view') { |
|
| 554 | + $number = $this->get_prop('number', $context); |
|
| 555 | 555 | |
| 556 | - if ( empty( $number ) ) { |
|
| 556 | + if (empty($number)) { |
|
| 557 | 557 | $number = $this->generate_number(); |
| 558 | - $this->set_number( $this->generate_number() ); |
|
| 558 | + $this->set_number($this->generate_number()); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | return $number; |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | public function maybe_set_number() { |
| 570 | 570 | $number = $this->get_number(); |
| 571 | 571 | |
| 572 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
| 573 | - $this->set_number( $this->generate_number() ); |
|
| 572 | + if (empty($number) || $this->get_id() == $number) { |
|
| 573 | + $this->set_number($this->generate_number()); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | } |
@@ -582,8 +582,8 @@ discard block |
||
| 582 | 582 | * @param string $context View or edit context. |
| 583 | 583 | * @return string |
| 584 | 584 | */ |
| 585 | - public function get_key( $context = 'view' ) { |
|
| 586 | - return $this->get_prop( 'key', $context ); |
|
| 585 | + public function get_key($context = 'view') { |
|
| 586 | + return $this->get_prop('key', $context); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -594,9 +594,9 @@ discard block |
||
| 594 | 594 | public function maybe_set_key() { |
| 595 | 595 | $key = $this->get_key(); |
| 596 | 596 | |
| 597 | - if ( empty( $key ) ) { |
|
| 598 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 599 | - $this->set_key( $key ); |
|
| 597 | + if (empty($key)) { |
|
| 598 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 599 | + $this->set_key($key); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | } |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | * @param string $context View or edit context. |
| 609 | 609 | * @return string |
| 610 | 610 | */ |
| 611 | - public function get_type( $context = 'view' ) { |
|
| 612 | - return $this->get_prop( 'type', $context ); |
|
| 611 | + public function get_type($context = 'view') { |
|
| 612 | + return $this->get_prop('type', $context); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @return string |
| 620 | 620 | */ |
| 621 | 621 | public function get_invoice_quote_type() { |
| 622 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
| 622 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
@@ -629,8 +629,8 @@ discard block |
||
| 629 | 629 | * @param string $context View or edit context. |
| 630 | 630 | * @return string |
| 631 | 631 | */ |
| 632 | - public function get_label( $context = 'view' ) { |
|
| 633 | - return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
|
| 632 | + public function get_label($context = 'view') { |
|
| 633 | + return getpaid_get_post_type_label($this->get_post_type($context), false); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -640,8 +640,8 @@ discard block |
||
| 640 | 640 | * @param string $context View or edit context. |
| 641 | 641 | * @return string |
| 642 | 642 | */ |
| 643 | - public function get_post_type( $context = 'view' ) { |
|
| 644 | - return $this->get_prop( 'post_type', $context ); |
|
| 643 | + public function get_post_type($context = 'view') { |
|
| 644 | + return $this->get_prop('post_type', $context); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
@@ -651,8 +651,8 @@ discard block |
||
| 651 | 651 | * @param string $context View or edit context. |
| 652 | 652 | * @return string |
| 653 | 653 | */ |
| 654 | - public function get_mode( $context = 'view' ) { |
|
| 655 | - return $this->get_prop( 'mode', $context ); |
|
| 654 | + public function get_mode($context = 'view') { |
|
| 655 | + return $this->get_prop('mode', $context); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -662,13 +662,13 @@ discard block |
||
| 662 | 662 | * @param string $context View or edit context. |
| 663 | 663 | * @return string |
| 664 | 664 | */ |
| 665 | - public function get_path( $context = 'view' ) { |
|
| 666 | - $path = $this->get_prop( 'path', $context ); |
|
| 665 | + public function get_path($context = 'view') { |
|
| 666 | + $path = $this->get_prop('path', $context); |
|
| 667 | 667 | $prefix = $this->get_type(); |
| 668 | 668 | |
| 669 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 670 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 671 | - $this->set_path( $path ); |
|
| 669 | + if (0 !== strpos($path, $prefix)) { |
|
| 670 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
| 671 | + $this->set_path($path); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | return $path; |
@@ -681,8 +681,8 @@ discard block |
||
| 681 | 681 | * @param string $context View or edit context. |
| 682 | 682 | * @return string |
| 683 | 683 | */ |
| 684 | - public function get_name( $context = 'view' ) { |
|
| 685 | - return $this->get_prop( 'title', $context ); |
|
| 684 | + public function get_name($context = 'view') { |
|
| 685 | + return $this->get_prop('title', $context); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | * @param string $context View or edit context. |
| 693 | 693 | * @return string |
| 694 | 694 | */ |
| 695 | - public function get_title( $context = 'view' ) { |
|
| 696 | - return $this->get_name( $context ); |
|
| 695 | + public function get_title($context = 'view') { |
|
| 696 | + return $this->get_name($context); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
@@ -703,8 +703,8 @@ discard block |
||
| 703 | 703 | * @param string $context View or edit context. |
| 704 | 704 | * @return string |
| 705 | 705 | */ |
| 706 | - public function get_description( $context = 'view' ) { |
|
| 707 | - return $this->get_prop( 'description', $context ); |
|
| 706 | + public function get_description($context = 'view') { |
|
| 707 | + return $this->get_prop('description', $context); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /** |
@@ -714,8 +714,8 @@ discard block |
||
| 714 | 714 | * @param string $context View or edit context. |
| 715 | 715 | * @return string |
| 716 | 716 | */ |
| 717 | - public function get_excerpt( $context = 'view' ) { |
|
| 718 | - return $this->get_description( $context ); |
|
| 717 | + public function get_excerpt($context = 'view') { |
|
| 718 | + return $this->get_description($context); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -725,8 +725,8 @@ discard block |
||
| 725 | 725 | * @param string $context View or edit context. |
| 726 | 726 | * @return string |
| 727 | 727 | */ |
| 728 | - public function get_summary( $context = 'view' ) { |
|
| 729 | - return $this->get_description( $context ); |
|
| 728 | + public function get_summary($context = 'view') { |
|
| 729 | + return $this->get_description($context); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -736,26 +736,26 @@ discard block |
||
| 736 | 736 | * @param string $context View or edit context. |
| 737 | 737 | * @return array |
| 738 | 738 | */ |
| 739 | - public function get_user_info( $context = 'view' ) { |
|
| 739 | + public function get_user_info($context = 'view') { |
|
| 740 | 740 | |
| 741 | 741 | $user_info = array( |
| 742 | - 'user_id' => $this->get_user_id( $context ), |
|
| 743 | - 'email' => $this->get_email( $context ), |
|
| 744 | - 'first_name' => $this->get_first_name( $context ), |
|
| 745 | - 'last_name' => $this->get_last_name( $context ), |
|
| 746 | - 'address' => $this->get_address( $context ), |
|
| 747 | - 'phone' => $this->get_phone( $context ), |
|
| 748 | - 'city' => $this->get_city( $context ), |
|
| 749 | - 'country' => $this->get_country( $context ), |
|
| 750 | - 'state' => $this->get_state( $context ), |
|
| 751 | - 'zip' => $this->get_zip( $context ), |
|
| 752 | - 'company' => $this->get_company( $context ), |
|
| 753 | - 'company_id' => $this->get_company_id( $context ), |
|
| 754 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 755 | - 'discount' => $this->get_discount_code( $context ), |
|
| 742 | + 'user_id' => $this->get_user_id($context), |
|
| 743 | + 'email' => $this->get_email($context), |
|
| 744 | + 'first_name' => $this->get_first_name($context), |
|
| 745 | + 'last_name' => $this->get_last_name($context), |
|
| 746 | + 'address' => $this->get_address($context), |
|
| 747 | + 'phone' => $this->get_phone($context), |
|
| 748 | + 'city' => $this->get_city($context), |
|
| 749 | + 'country' => $this->get_country($context), |
|
| 750 | + 'state' => $this->get_state($context), |
|
| 751 | + 'zip' => $this->get_zip($context), |
|
| 752 | + 'company' => $this->get_company($context), |
|
| 753 | + 'company_id' => $this->get_company_id($context), |
|
| 754 | + 'vat_number' => $this->get_vat_number($context), |
|
| 755 | + 'discount' => $this->get_discount_code($context), |
|
| 756 | 756 | ); |
| 757 | 757 | |
| 758 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 758 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 759 | 759 | |
| 760 | 760 | } |
| 761 | 761 | |
@@ -766,8 +766,8 @@ discard block |
||
| 766 | 766 | * @param string $context View or edit context. |
| 767 | 767 | * @return int |
| 768 | 768 | */ |
| 769 | - public function get_author( $context = 'view' ) { |
|
| 770 | - return (int) $this->get_prop( 'author', $context ); |
|
| 769 | + public function get_author($context = 'view') { |
|
| 770 | + return (int) $this->get_prop('author', $context); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | * @param string $context View or edit context. |
| 778 | 778 | * @return int |
| 779 | 779 | */ |
| 780 | - public function get_user_id( $context = 'view' ) { |
|
| 781 | - return $this->get_author( $context ); |
|
| 780 | + public function get_user_id($context = 'view') { |
|
| 781 | + return $this->get_author($context); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
@@ -788,8 +788,8 @@ discard block |
||
| 788 | 788 | * @param string $context View or edit context. |
| 789 | 789 | * @return int |
| 790 | 790 | */ |
| 791 | - public function get_customer_id( $context = 'view' ) { |
|
| 792 | - return $this->get_author( $context ); |
|
| 791 | + public function get_customer_id($context = 'view') { |
|
| 792 | + return $this->get_author($context); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -799,8 +799,8 @@ discard block |
||
| 799 | 799 | * @param string $context View or edit context. |
| 800 | 800 | * @return string |
| 801 | 801 | */ |
| 802 | - public function get_ip( $context = 'view' ) { |
|
| 803 | - return $this->get_prop( 'user_ip', $context ); |
|
| 802 | + public function get_ip($context = 'view') { |
|
| 803 | + return $this->get_prop('user_ip', $context); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /** |
@@ -810,8 +810,8 @@ discard block |
||
| 810 | 810 | * @param string $context View or edit context. |
| 811 | 811 | * @return string |
| 812 | 812 | */ |
| 813 | - public function get_user_ip( $context = 'view' ) { |
|
| 814 | - return $this->get_ip( $context ); |
|
| 813 | + public function get_user_ip($context = 'view') { |
|
| 814 | + return $this->get_ip($context); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -821,8 +821,8 @@ discard block |
||
| 821 | 821 | * @param string $context View or edit context. |
| 822 | 822 | * @return string |
| 823 | 823 | */ |
| 824 | - public function get_customer_ip( $context = 'view' ) { |
|
| 825 | - return $this->get_ip( $context ); |
|
| 824 | + public function get_customer_ip($context = 'view') { |
|
| 825 | + return $this->get_ip($context); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
@@ -832,8 +832,8 @@ discard block |
||
| 832 | 832 | * @param string $context View or edit context. |
| 833 | 833 | * @return string |
| 834 | 834 | */ |
| 835 | - public function get_first_name( $context = 'view' ) { |
|
| 836 | - return $this->get_prop( 'first_name', $context ); |
|
| 835 | + public function get_first_name($context = 'view') { |
|
| 836 | + return $this->get_prop('first_name', $context); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -843,8 +843,8 @@ discard block |
||
| 843 | 843 | * @param string $context View or edit context. |
| 844 | 844 | * @return string |
| 845 | 845 | */ |
| 846 | - public function get_user_first_name( $context = 'view' ) { |
|
| 847 | - return $this->get_first_name( $context ); |
|
| 846 | + public function get_user_first_name($context = 'view') { |
|
| 847 | + return $this->get_first_name($context); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | /** |
@@ -854,8 +854,8 @@ discard block |
||
| 854 | 854 | * @param string $context View or edit context. |
| 855 | 855 | * @return string |
| 856 | 856 | */ |
| 857 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 858 | - return $this->get_first_name( $context ); |
|
| 857 | + public function get_customer_first_name($context = 'view') { |
|
| 858 | + return $this->get_first_name($context); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
@@ -865,8 +865,8 @@ discard block |
||
| 865 | 865 | * @param string $context View or edit context. |
| 866 | 866 | * @return string |
| 867 | 867 | */ |
| 868 | - public function get_last_name( $context = 'view' ) { |
|
| 869 | - return $this->get_prop( 'last_name', $context ); |
|
| 868 | + public function get_last_name($context = 'view') { |
|
| 869 | + return $this->get_prop('last_name', $context); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | /** |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | * @param string $context View or edit context. |
| 877 | 877 | * @return string |
| 878 | 878 | */ |
| 879 | - public function get_user_last_name( $context = 'view' ) { |
|
| 880 | - return $this->get_last_name( $context ); |
|
| 879 | + public function get_user_last_name($context = 'view') { |
|
| 880 | + return $this->get_last_name($context); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /** |
@@ -887,8 +887,8 @@ discard block |
||
| 887 | 887 | * @param string $context View or edit context. |
| 888 | 888 | * @return string |
| 889 | 889 | */ |
| 890 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 891 | - return $this->get_last_name( $context ); |
|
| 890 | + public function get_customer_last_name($context = 'view') { |
|
| 891 | + return $this->get_last_name($context); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |
@@ -898,8 +898,8 @@ discard block |
||
| 898 | 898 | * @param string $context View or edit context. |
| 899 | 899 | * @return string |
| 900 | 900 | */ |
| 901 | - public function get_full_name( $context = 'view' ) { |
|
| 902 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 901 | + public function get_full_name($context = 'view') { |
|
| 902 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
@@ -909,8 +909,8 @@ discard block |
||
| 909 | 909 | * @param string $context View or edit context. |
| 910 | 910 | * @return string |
| 911 | 911 | */ |
| 912 | - public function get_user_full_name( $context = 'view' ) { |
|
| 913 | - return $this->get_full_name( $context ); |
|
| 912 | + public function get_user_full_name($context = 'view') { |
|
| 913 | + return $this->get_full_name($context); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | /** |
@@ -920,8 +920,8 @@ discard block |
||
| 920 | 920 | * @param string $context View or edit context. |
| 921 | 921 | * @return string |
| 922 | 922 | */ |
| 923 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 924 | - return $this->get_full_name( $context ); |
|
| 923 | + public function get_customer_full_name($context = 'view') { |
|
| 924 | + return $this->get_full_name($context); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
@@ -931,8 +931,8 @@ discard block |
||
| 931 | 931 | * @param string $context View or edit context. |
| 932 | 932 | * @return string |
| 933 | 933 | */ |
| 934 | - public function get_phone( $context = 'view' ) { |
|
| 935 | - return $this->get_prop( 'phone', $context ); |
|
| 934 | + public function get_phone($context = 'view') { |
|
| 935 | + return $this->get_prop('phone', $context); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -942,8 +942,8 @@ discard block |
||
| 942 | 942 | * @param string $context View or edit context. |
| 943 | 943 | * @return string |
| 944 | 944 | */ |
| 945 | - public function get_phone_number( $context = 'view' ) { |
|
| 946 | - return $this->get_phone( $context ); |
|
| 945 | + public function get_phone_number($context = 'view') { |
|
| 946 | + return $this->get_phone($context); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | * @param string $context View or edit context. |
| 954 | 954 | * @return string |
| 955 | 955 | */ |
| 956 | - public function get_user_phone( $context = 'view' ) { |
|
| 957 | - return $this->get_phone( $context ); |
|
| 956 | + public function get_user_phone($context = 'view') { |
|
| 957 | + return $this->get_phone($context); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -964,8 +964,8 @@ discard block |
||
| 964 | 964 | * @param string $context View or edit context. |
| 965 | 965 | * @return string |
| 966 | 966 | */ |
| 967 | - public function get_customer_phone( $context = 'view' ) { |
|
| 968 | - return $this->get_phone( $context ); |
|
| 967 | + public function get_customer_phone($context = 'view') { |
|
| 968 | + return $this->get_phone($context); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | /** |
@@ -975,8 +975,8 @@ discard block |
||
| 975 | 975 | * @param string $context View or edit context. |
| 976 | 976 | * @return string |
| 977 | 977 | */ |
| 978 | - public function get_email( $context = 'view' ) { |
|
| 979 | - return $this->get_prop( 'email', $context ); |
|
| 978 | + public function get_email($context = 'view') { |
|
| 979 | + return $this->get_prop('email', $context); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
@@ -986,8 +986,8 @@ discard block |
||
| 986 | 986 | * @param string $context View or edit context. |
| 987 | 987 | * @return string |
| 988 | 988 | */ |
| 989 | - public function get_email_address( $context = 'view' ) { |
|
| 990 | - return $this->get_email( $context ); |
|
| 989 | + public function get_email_address($context = 'view') { |
|
| 990 | + return $this->get_email($context); |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | /** |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | * @param string $context View or edit context. |
| 998 | 998 | * @return string |
| 999 | 999 | */ |
| 1000 | - public function get_user_email( $context = 'view' ) { |
|
| 1001 | - return $this->get_email( $context ); |
|
| 1000 | + public function get_user_email($context = 'view') { |
|
| 1001 | + return $this->get_email($context); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | /** |
@@ -1008,8 +1008,8 @@ discard block |
||
| 1008 | 1008 | * @param string $context View or edit context. |
| 1009 | 1009 | * @return string |
| 1010 | 1010 | */ |
| 1011 | - public function get_customer_email( $context = 'view' ) { |
|
| 1012 | - return $this->get_email( $context ); |
|
| 1011 | + public function get_customer_email($context = 'view') { |
|
| 1012 | + return $this->get_email($context); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /** |
@@ -1019,9 +1019,9 @@ discard block |
||
| 1019 | 1019 | * @param string $context View or edit context. |
| 1020 | 1020 | * @return string |
| 1021 | 1021 | */ |
| 1022 | - public function get_country( $context = 'view' ) { |
|
| 1023 | - $country = $this->get_prop( 'country', $context ); |
|
| 1024 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1022 | + public function get_country($context = 'view') { |
|
| 1023 | + $country = $this->get_prop('country', $context); |
|
| 1024 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | /** |
@@ -1031,8 +1031,8 @@ discard block |
||
| 1031 | 1031 | * @param string $context View or edit context. |
| 1032 | 1032 | * @return string |
| 1033 | 1033 | */ |
| 1034 | - public function get_user_country( $context = 'view' ) { |
|
| 1035 | - return $this->get_country( $context ); |
|
| 1034 | + public function get_user_country($context = 'view') { |
|
| 1035 | + return $this->get_country($context); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | /** |
@@ -1042,8 +1042,8 @@ discard block |
||
| 1042 | 1042 | * @param string $context View or edit context. |
| 1043 | 1043 | * @return string |
| 1044 | 1044 | */ |
| 1045 | - public function get_customer_country( $context = 'view' ) { |
|
| 1046 | - return $this->get_country( $context ); |
|
| 1045 | + public function get_customer_country($context = 'view') { |
|
| 1046 | + return $this->get_country($context); |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | /** |
@@ -1053,9 +1053,9 @@ discard block |
||
| 1053 | 1053 | * @param string $context View or edit context. |
| 1054 | 1054 | * @return string |
| 1055 | 1055 | */ |
| 1056 | - public function get_state( $context = 'view' ) { |
|
| 1057 | - $state = $this->get_prop( 'state', $context ); |
|
| 1058 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1056 | + public function get_state($context = 'view') { |
|
| 1057 | + $state = $this->get_prop('state', $context); |
|
| 1058 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | /** |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | * @param string $context View or edit context. |
| 1066 | 1066 | * @return string |
| 1067 | 1067 | */ |
| 1068 | - public function get_user_state( $context = 'view' ) { |
|
| 1069 | - return $this->get_state( $context ); |
|
| 1068 | + public function get_user_state($context = 'view') { |
|
| 1069 | + return $this->get_state($context); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | /** |
@@ -1076,8 +1076,8 @@ discard block |
||
| 1076 | 1076 | * @param string $context View or edit context. |
| 1077 | 1077 | * @return string |
| 1078 | 1078 | */ |
| 1079 | - public function get_customer_state( $context = 'view' ) { |
|
| 1080 | - return $this->get_state( $context ); |
|
| 1079 | + public function get_customer_state($context = 'view') { |
|
| 1080 | + return $this->get_state($context); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | /** |
@@ -1087,8 +1087,8 @@ discard block |
||
| 1087 | 1087 | * @param string $context View or edit context. |
| 1088 | 1088 | * @return string |
| 1089 | 1089 | */ |
| 1090 | - public function get_city( $context = 'view' ) { |
|
| 1091 | - return $this->get_prop( 'city', $context ); |
|
| 1090 | + public function get_city($context = 'view') { |
|
| 1091 | + return $this->get_prop('city', $context); |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | /** |
@@ -1098,8 +1098,8 @@ discard block |
||
| 1098 | 1098 | * @param string $context View or edit context. |
| 1099 | 1099 | * @return string |
| 1100 | 1100 | */ |
| 1101 | - public function get_user_city( $context = 'view' ) { |
|
| 1102 | - return $this->get_city( $context ); |
|
| 1101 | + public function get_user_city($context = 'view') { |
|
| 1102 | + return $this->get_city($context); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | /** |
@@ -1109,8 +1109,8 @@ discard block |
||
| 1109 | 1109 | * @param string $context View or edit context. |
| 1110 | 1110 | * @return string |
| 1111 | 1111 | */ |
| 1112 | - public function get_customer_city( $context = 'view' ) { |
|
| 1113 | - return $this->get_city( $context ); |
|
| 1112 | + public function get_customer_city($context = 'view') { |
|
| 1113 | + return $this->get_city($context); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | /** |
@@ -1120,8 +1120,8 @@ discard block |
||
| 1120 | 1120 | * @param string $context View or edit context. |
| 1121 | 1121 | * @return string |
| 1122 | 1122 | */ |
| 1123 | - public function get_zip( $context = 'view' ) { |
|
| 1124 | - return $this->get_prop( 'zip', $context ); |
|
| 1123 | + public function get_zip($context = 'view') { |
|
| 1124 | + return $this->get_prop('zip', $context); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | /** |
@@ -1131,8 +1131,8 @@ discard block |
||
| 1131 | 1131 | * @param string $context View or edit context. |
| 1132 | 1132 | * @return string |
| 1133 | 1133 | */ |
| 1134 | - public function get_user_zip( $context = 'view' ) { |
|
| 1135 | - return $this->get_zip( $context ); |
|
| 1134 | + public function get_user_zip($context = 'view') { |
|
| 1135 | + return $this->get_zip($context); |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | /** |
@@ -1142,8 +1142,8 @@ discard block |
||
| 1142 | 1142 | * @param string $context View or edit context. |
| 1143 | 1143 | * @return string |
| 1144 | 1144 | */ |
| 1145 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1146 | - return $this->get_zip( $context ); |
|
| 1145 | + public function get_customer_zip($context = 'view') { |
|
| 1146 | + return $this->get_zip($context); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /** |
@@ -1153,8 +1153,8 @@ discard block |
||
| 1153 | 1153 | * @param string $context View or edit context. |
| 1154 | 1154 | * @return string |
| 1155 | 1155 | */ |
| 1156 | - public function get_company( $context = 'view' ) { |
|
| 1157 | - return $this->get_prop( 'company', $context ); |
|
| 1156 | + public function get_company($context = 'view') { |
|
| 1157 | + return $this->get_prop('company', $context); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | /** |
@@ -1164,8 +1164,8 @@ discard block |
||
| 1164 | 1164 | * @param string $context View or edit context. |
| 1165 | 1165 | * @return string |
| 1166 | 1166 | */ |
| 1167 | - public function get_user_company( $context = 'view' ) { |
|
| 1168 | - return $this->get_company( $context ); |
|
| 1167 | + public function get_user_company($context = 'view') { |
|
| 1168 | + return $this->get_company($context); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | /** |
@@ -1175,8 +1175,8 @@ discard block |
||
| 1175 | 1175 | * @param string $context View or edit context. |
| 1176 | 1176 | * @return string |
| 1177 | 1177 | */ |
| 1178 | - public function get_customer_company( $context = 'view' ) { |
|
| 1179 | - return $this->get_company( $context ); |
|
| 1178 | + public function get_customer_company($context = 'view') { |
|
| 1179 | + return $this->get_company($context); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | /** |
@@ -1186,8 +1186,8 @@ discard block |
||
| 1186 | 1186 | * @param string $context View or edit context. |
| 1187 | 1187 | * @return string |
| 1188 | 1188 | */ |
| 1189 | - public function get_company_id( $context = 'view' ) { |
|
| 1190 | - return $this->get_prop( 'company_id', $context ); |
|
| 1189 | + public function get_company_id($context = 'view') { |
|
| 1190 | + return $this->get_prop('company_id', $context); |
|
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | 1193 | /** |
@@ -1197,8 +1197,8 @@ discard block |
||
| 1197 | 1197 | * @param string $context View or edit context. |
| 1198 | 1198 | * @return string |
| 1199 | 1199 | */ |
| 1200 | - public function get_vat_number( $context = 'view' ) { |
|
| 1201 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1200 | + public function get_vat_number($context = 'view') { |
|
| 1201 | + return $this->get_prop('vat_number', $context); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1208,8 +1208,8 @@ discard block |
||
| 1208 | 1208 | * @param string $context View or edit context. |
| 1209 | 1209 | * @return string |
| 1210 | 1210 | */ |
| 1211 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1212 | - return $this->get_vat_number( $context ); |
|
| 1211 | + public function get_user_vat_number($context = 'view') { |
|
| 1212 | + return $this->get_vat_number($context); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | /** |
@@ -1219,8 +1219,8 @@ discard block |
||
| 1219 | 1219 | * @param string $context View or edit context. |
| 1220 | 1220 | * @return string |
| 1221 | 1221 | */ |
| 1222 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1223 | - return $this->get_vat_number( $context ); |
|
| 1222 | + public function get_customer_vat_number($context = 'view') { |
|
| 1223 | + return $this->get_vat_number($context); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1230,8 +1230,8 @@ discard block |
||
| 1230 | 1230 | * @param string $context View or edit context. |
| 1231 | 1231 | * @return string |
| 1232 | 1232 | */ |
| 1233 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1234 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1233 | + public function get_vat_rate($context = 'view') { |
|
| 1234 | + return $this->get_prop('vat_rate', $context); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | /** |
@@ -1241,8 +1241,8 @@ discard block |
||
| 1241 | 1241 | * @param string $context View or edit context. |
| 1242 | 1242 | * @return string |
| 1243 | 1243 | */ |
| 1244 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1245 | - return $this->get_vat_rate( $context ); |
|
| 1244 | + public function get_user_vat_rate($context = 'view') { |
|
| 1245 | + return $this->get_vat_rate($context); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |
@@ -1252,8 +1252,8 @@ discard block |
||
| 1252 | 1252 | * @param string $context View or edit context. |
| 1253 | 1253 | * @return string |
| 1254 | 1254 | */ |
| 1255 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1256 | - return $this->get_vat_rate( $context ); |
|
| 1255 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1256 | + return $this->get_vat_rate($context); |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | /** |
@@ -1263,8 +1263,8 @@ discard block |
||
| 1263 | 1263 | * @param string $context View or edit context. |
| 1264 | 1264 | * @return string |
| 1265 | 1265 | */ |
| 1266 | - public function get_address( $context = 'view' ) { |
|
| 1267 | - return $this->get_prop( 'address', $context ); |
|
| 1266 | + public function get_address($context = 'view') { |
|
| 1267 | + return $this->get_prop('address', $context); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | /** |
@@ -1274,8 +1274,8 @@ discard block |
||
| 1274 | 1274 | * @param string $context View or edit context. |
| 1275 | 1275 | * @return string |
| 1276 | 1276 | */ |
| 1277 | - public function get_user_address( $context = 'view' ) { |
|
| 1278 | - return $this->get_address( $context ); |
|
| 1277 | + public function get_user_address($context = 'view') { |
|
| 1278 | + return $this->get_address($context); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | /** |
@@ -1285,8 +1285,8 @@ discard block |
||
| 1285 | 1285 | * @param string $context View or edit context. |
| 1286 | 1286 | * @return string |
| 1287 | 1287 | */ |
| 1288 | - public function get_customer_address( $context = 'view' ) { |
|
| 1289 | - return $this->get_address( $context ); |
|
| 1288 | + public function get_customer_address($context = 'view') { |
|
| 1289 | + return $this->get_address($context); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | /** |
@@ -1296,8 +1296,8 @@ discard block |
||
| 1296 | 1296 | * @param string $context View or edit context. |
| 1297 | 1297 | * @return bool |
| 1298 | 1298 | */ |
| 1299 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1300 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1299 | + public function get_is_viewed($context = 'view') { |
|
| 1300 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | * @param string $context View or edit context. |
| 1308 | 1308 | * @return bool |
| 1309 | 1309 | */ |
| 1310 | - public function get_email_cc( $context = 'view' ) { |
|
| 1311 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1310 | + public function get_email_cc($context = 'view') { |
|
| 1311 | + return $this->get_prop('email_cc', $context); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | /** |
@@ -1318,8 +1318,8 @@ discard block |
||
| 1318 | 1318 | * @param string $context View or edit context. |
| 1319 | 1319 | * @return bool |
| 1320 | 1320 | */ |
| 1321 | - public function get_template( $context = 'view' ) { |
|
| 1322 | - return $this->get_prop( 'template', $context ); |
|
| 1321 | + public function get_template($context = 'view') { |
|
| 1322 | + return $this->get_prop('template', $context); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | /** |
@@ -1329,8 +1329,8 @@ discard block |
||
| 1329 | 1329 | * @param string $context View or edit context. |
| 1330 | 1330 | * @return bool |
| 1331 | 1331 | */ |
| 1332 | - public function get_created_via( $context = 'view' ) { |
|
| 1333 | - return $this->get_prop( 'created_via', $context ); |
|
| 1332 | + public function get_created_via($context = 'view') { |
|
| 1333 | + return $this->get_prop('created_via', $context); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | /** |
@@ -1340,8 +1340,8 @@ discard block |
||
| 1340 | 1340 | * @param string $context View or edit context. |
| 1341 | 1341 | * @return bool |
| 1342 | 1342 | */ |
| 1343 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1344 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1343 | + public function get_address_confirmed($context = 'view') { |
|
| 1344 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | 1347 | /** |
@@ -1351,8 +1351,8 @@ discard block |
||
| 1351 | 1351 | * @param string $context View or edit context. |
| 1352 | 1352 | * @return bool |
| 1353 | 1353 | */ |
| 1354 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1355 | - return $this->get_address_confirmed( $context ); |
|
| 1354 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1355 | + return $this->get_address_confirmed($context); |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | /** |
@@ -1362,8 +1362,8 @@ discard block |
||
| 1362 | 1362 | * @param string $context View or edit context. |
| 1363 | 1363 | * @return bool |
| 1364 | 1364 | */ |
| 1365 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1366 | - return $this->get_address_confirmed( $context ); |
|
| 1365 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1366 | + return $this->get_address_confirmed($context); |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | /** |
@@ -1373,12 +1373,12 @@ discard block |
||
| 1373 | 1373 | * @param string $context View or edit context. |
| 1374 | 1374 | * @return float |
| 1375 | 1375 | */ |
| 1376 | - public function get_subtotal( $context = 'view' ) { |
|
| 1377 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1376 | + public function get_subtotal($context = 'view') { |
|
| 1377 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1378 | 1378 | |
| 1379 | 1379 | // Backwards compatibility. |
| 1380 | - if ( is_bool( $context ) && $context ) { |
|
| 1381 | - return wpinv_price( $subtotal, $this->get_currency() ); |
|
| 1380 | + if (is_bool($context) && $context) { |
|
| 1381 | + return wpinv_price($subtotal, $this->get_currency()); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | return $subtotal; |
@@ -1391,8 +1391,8 @@ discard block |
||
| 1391 | 1391 | * @param string $context View or edit context. |
| 1392 | 1392 | * @return float |
| 1393 | 1393 | */ |
| 1394 | - public function get_total_discount( $context = 'view' ) { |
|
| 1395 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
| 1394 | + public function get_total_discount($context = 'view') { |
|
| 1395 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context))); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | /** |
@@ -1402,18 +1402,18 @@ discard block |
||
| 1402 | 1402 | * @param string $context View or edit context. |
| 1403 | 1403 | * @return float |
| 1404 | 1404 | */ |
| 1405 | - public function get_total_tax( $context = 'view' ) { |
|
| 1406 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
| 1405 | + public function get_total_tax($context = 'view') { |
|
| 1406 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context))); |
|
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | 1409 | /** |
| 1410 | 1410 | * @deprecated |
| 1411 | 1411 | */ |
| 1412 | - public function get_final_tax( $currency = false ) { |
|
| 1412 | + public function get_final_tax($currency = false) { |
|
| 1413 | 1413 | $tax = $this->get_total_tax(); |
| 1414 | 1414 | |
| 1415 | - if ( $currency ) { |
|
| 1416 | - return wpinv_price( $tax, $this->get_currency() ); |
|
| 1415 | + if ($currency) { |
|
| 1416 | + return wpinv_price($tax, $this->get_currency()); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | return $tax; |
@@ -1426,8 +1426,8 @@ discard block |
||
| 1426 | 1426 | * @param string $context View or edit context. |
| 1427 | 1427 | * @return float |
| 1428 | 1428 | */ |
| 1429 | - public function get_total_fees( $context = 'view' ) { |
|
| 1430 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
| 1429 | + public function get_total_fees($context = 'view') { |
|
| 1430 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context))); |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1437,8 +1437,8 @@ discard block |
||
| 1437 | 1437 | * @param string $context View or edit context. |
| 1438 | 1438 | * @return float |
| 1439 | 1439 | */ |
| 1440 | - public function get_fees_total( $context = 'view' ) { |
|
| 1441 | - return $this->get_total_fees( $context ); |
|
| 1440 | + public function get_fees_total($context = 'view') { |
|
| 1441 | + return $this->get_total_fees($context); |
|
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | /** |
@@ -1447,8 +1447,8 @@ discard block |
||
| 1447 | 1447 | * @since 1.0.19 |
| 1448 | 1448 | * @return float |
| 1449 | 1449 | */ |
| 1450 | - public function get_total( $context = 'view' ) { |
|
| 1451 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
| 1450 | + public function get_total($context = 'view') { |
|
| 1451 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total', $context))); |
|
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | /** |
@@ -1460,20 +1460,20 @@ discard block |
||
| 1460 | 1460 | public function get_non_recurring_total() { |
| 1461 | 1461 | |
| 1462 | 1462 | $subtotal = 0; |
| 1463 | - foreach ( $this->get_items() as $item ) { |
|
| 1464 | - if ( ! $item->is_recurring() ) { |
|
| 1463 | + foreach ($this->get_items() as $item) { |
|
| 1464 | + if (!$item->is_recurring()) { |
|
| 1465 | 1465 | $subtotal += $item->get_sub_total(); |
| 1466 | 1466 | } |
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | - foreach ( $this->get_fees() as $fee ) { |
|
| 1470 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
| 1471 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 1469 | + foreach ($this->get_fees() as $fee) { |
|
| 1470 | + if (empty($fee['recurring_fee'])) { |
|
| 1471 | + $subtotal += wpinv_sanitize_amount($fee['initial_fee']); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
| 1476 | - return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
|
| 1475 | + $subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal)); |
|
| 1476 | + return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this); |
|
| 1477 | 1477 | |
| 1478 | 1478 | } |
| 1479 | 1479 | |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | */ |
| 1497 | 1497 | public function get_initial_total() { |
| 1498 | 1498 | |
| 1499 | - if ( empty( $this->totals ) ) { |
|
| 1499 | + if (empty($this->totals)) { |
|
| 1500 | 1500 | $this->recalculate_total(); |
| 1501 | 1501 | } |
| 1502 | 1502 | |
@@ -1506,12 +1506,12 @@ discard block |
||
| 1506 | 1506 | $subtotal = $this->totals['subtotal']['initial']; |
| 1507 | 1507 | $total = $tax + $fee - $discount + $subtotal; |
| 1508 | 1508 | |
| 1509 | - if ( 0 > $total ) { |
|
| 1509 | + if (0 > $total) { |
|
| 1510 | 1510 | $total = 0; |
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1514 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1513 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
| 1514 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | 1517 | /** |
@@ -1523,7 +1523,7 @@ discard block |
||
| 1523 | 1523 | */ |
| 1524 | 1524 | public function get_recurring_total() { |
| 1525 | 1525 | |
| 1526 | - if ( empty( $this->totals ) ) { |
|
| 1526 | + if (empty($this->totals)) { |
|
| 1527 | 1527 | $this->recalculate_total(); |
| 1528 | 1528 | } |
| 1529 | 1529 | |
@@ -1533,12 +1533,12 @@ discard block |
||
| 1533 | 1533 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1534 | 1534 | $total = $tax + $fee - $discount + $subtotal; |
| 1535 | 1535 | |
| 1536 | - if ( 0 > $total ) { |
|
| 1536 | + if (0 > $total) { |
|
| 1537 | 1537 | $total = 0; |
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1541 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1540 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
| 1541 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | /** |
@@ -1549,10 +1549,10 @@ discard block |
||
| 1549 | 1549 | * @param string $currency Whether to include the currency. |
| 1550 | 1550 | * @return float|string |
| 1551 | 1551 | */ |
| 1552 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1552 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1553 | 1553 | |
| 1554 | 1554 | // Maybe recalculate totals. |
| 1555 | - if ( empty( $this->totals ) ) { |
|
| 1555 | + if (empty($this->totals)) { |
|
| 1556 | 1556 | $this->recalculate_total(); |
| 1557 | 1557 | } |
| 1558 | 1558 | |
@@ -1572,8 +1572,8 @@ discard block |
||
| 1572 | 1572 | $currency |
| 1573 | 1573 | ); |
| 1574 | 1574 | |
| 1575 | - if ( isset( $data[$field] ) ) { |
|
| 1576 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1575 | + if (isset($data[$field])) { |
|
| 1576 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | 1579 | return $data; |
@@ -1586,8 +1586,8 @@ discard block |
||
| 1586 | 1586 | * @param string $context View or edit context. |
| 1587 | 1587 | * @return array |
| 1588 | 1588 | */ |
| 1589 | - public function get_fees( $context = 'view' ) { |
|
| 1590 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1589 | + public function get_fees($context = 'view') { |
|
| 1590 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | /** |
@@ -1597,8 +1597,8 @@ discard block |
||
| 1597 | 1597 | * @param string $context View or edit context. |
| 1598 | 1598 | * @return array |
| 1599 | 1599 | */ |
| 1600 | - public function get_discounts( $context = 'view' ) { |
|
| 1601 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1600 | + public function get_discounts($context = 'view') { |
|
| 1601 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | /** |
@@ -1608,8 +1608,8 @@ discard block |
||
| 1608 | 1608 | * @param string $context View or edit context. |
| 1609 | 1609 | * @return array |
| 1610 | 1610 | */ |
| 1611 | - public function get_taxes( $context = 'view' ) { |
|
| 1612 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1611 | + public function get_taxes($context = 'view') { |
|
| 1612 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
@@ -1619,8 +1619,8 @@ discard block |
||
| 1619 | 1619 | * @param string $context View or edit context. |
| 1620 | 1620 | * @return GetPaid_Form_Item[] |
| 1621 | 1621 | */ |
| 1622 | - public function get_items( $context = 'view' ) { |
|
| 1623 | - return $this->get_prop( 'items', $context ); |
|
| 1622 | + public function get_items($context = 'view') { |
|
| 1623 | + return $this->get_prop('items', $context); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | 1626 | /** |
@@ -1630,7 +1630,7 @@ discard block |
||
| 1630 | 1630 | * @return string |
| 1631 | 1631 | */ |
| 1632 | 1632 | public function get_item_ids() { |
| 1633 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
| 1633 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | /** |
@@ -1640,8 +1640,8 @@ discard block |
||
| 1640 | 1640 | * @param string $context View or edit context. |
| 1641 | 1641 | * @return int |
| 1642 | 1642 | */ |
| 1643 | - public function get_payment_form( $context = 'view' ) { |
|
| 1644 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1643 | + public function get_payment_form($context = 'view') { |
|
| 1644 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | /** |
@@ -1651,8 +1651,8 @@ discard block |
||
| 1651 | 1651 | * @param string $context View or edit context. |
| 1652 | 1652 | * @return string |
| 1653 | 1653 | */ |
| 1654 | - public function get_submission_id( $context = 'view' ) { |
|
| 1655 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1654 | + public function get_submission_id($context = 'view') { |
|
| 1655 | + return $this->get_prop('submission_id', $context); |
|
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | 1658 | /** |
@@ -1662,8 +1662,8 @@ discard block |
||
| 1662 | 1662 | * @param string $context View or edit context. |
| 1663 | 1663 | * @return string |
| 1664 | 1664 | */ |
| 1665 | - public function get_discount_code( $context = 'view' ) { |
|
| 1666 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1665 | + public function get_discount_code($context = 'view') { |
|
| 1666 | + return $this->get_prop('discount_code', $context); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | /** |
@@ -1673,8 +1673,8 @@ discard block |
||
| 1673 | 1673 | * @param string $context View or edit context. |
| 1674 | 1674 | * @return string |
| 1675 | 1675 | */ |
| 1676 | - public function get_gateway( $context = 'view' ) { |
|
| 1677 | - return $this->get_prop( 'gateway', $context ); |
|
| 1676 | + public function get_gateway($context = 'view') { |
|
| 1677 | + return $this->get_prop('gateway', $context); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | 1680 | /** |
@@ -1684,8 +1684,8 @@ discard block |
||
| 1684 | 1684 | * @return string |
| 1685 | 1685 | */ |
| 1686 | 1686 | public function get_gateway_title() { |
| 1687 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1688 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1687 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1688 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | 1691 | /** |
@@ -1695,8 +1695,8 @@ discard block |
||
| 1695 | 1695 | * @param string $context View or edit context. |
| 1696 | 1696 | * @return string |
| 1697 | 1697 | */ |
| 1698 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1699 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1698 | + public function get_transaction_id($context = 'view') { |
|
| 1699 | + return $this->get_prop('transaction_id', $context); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | 1702 | /** |
@@ -1706,9 +1706,9 @@ discard block |
||
| 1706 | 1706 | * @param string $context View or edit context. |
| 1707 | 1707 | * @return string |
| 1708 | 1708 | */ |
| 1709 | - public function get_currency( $context = 'view' ) { |
|
| 1710 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1711 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1709 | + public function get_currency($context = 'view') { |
|
| 1710 | + $currency = $this->get_prop('currency', $context); |
|
| 1711 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1718,8 +1718,8 @@ discard block |
||
| 1718 | 1718 | * @param string $context View or edit context. |
| 1719 | 1719 | * @return bool |
| 1720 | 1720 | */ |
| 1721 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1722 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1721 | + public function get_disable_taxes($context = 'view') { |
|
| 1722 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | /** |
@@ -1729,8 +1729,8 @@ discard block |
||
| 1729 | 1729 | * @param string $context View or edit context. |
| 1730 | 1730 | * @return int |
| 1731 | 1731 | */ |
| 1732 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1733 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1732 | + public function get_subscription_id($context = 'view') { |
|
| 1733 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | /** |
@@ -1740,12 +1740,12 @@ discard block |
||
| 1740 | 1740 | * @param string $context View or edit context. |
| 1741 | 1741 | * @return int |
| 1742 | 1742 | */ |
| 1743 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
| 1744 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
| 1743 | + public function get_remote_subscription_id($context = 'view') { |
|
| 1744 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
| 1745 | 1745 | |
| 1746 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1746 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1747 | 1747 | $parent = $this->get_parent(); |
| 1748 | - return $parent->get_remote_subscription_id( $context ); |
|
| 1748 | + return $parent->get_remote_subscription_id($context); |
|
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | return $subscription_id; |
@@ -1758,20 +1758,20 @@ discard block |
||
| 1758 | 1758 | * @param string $context View or edit context. |
| 1759 | 1759 | * @return array |
| 1760 | 1760 | */ |
| 1761 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1761 | + public function get_payment_meta($context = 'view') { |
|
| 1762 | 1762 | |
| 1763 | 1763 | return array( |
| 1764 | - 'price' => $this->get_total( $context ), |
|
| 1765 | - 'date' => $this->get_date_created( $context ), |
|
| 1766 | - 'user_email' => $this->get_email( $context ), |
|
| 1767 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1768 | - 'currency' => $this->get_currency( $context ), |
|
| 1769 | - 'items' => $this->get_items( $context ), |
|
| 1770 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1764 | + 'price' => $this->get_total($context), |
|
| 1765 | + 'date' => $this->get_date_created($context), |
|
| 1766 | + 'user_email' => $this->get_email($context), |
|
| 1767 | + 'invoice_key' => $this->get_key($context), |
|
| 1768 | + 'currency' => $this->get_currency($context), |
|
| 1769 | + 'items' => $this->get_items($context), |
|
| 1770 | + 'user_info' => $this->get_user_info($context), |
|
| 1771 | 1771 | 'cart_details' => $this->get_cart_details(), |
| 1772 | - 'status' => $this->get_status( $context ), |
|
| 1773 | - 'fees' => $this->get_fees( $context ), |
|
| 1774 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1772 | + 'status' => $this->get_status($context), |
|
| 1773 | + 'fees' => $this->get_fees($context), |
|
| 1774 | + 'taxes' => $this->get_taxes($context), |
|
| 1775 | 1775 | ); |
| 1776 | 1776 | |
| 1777 | 1777 | } |
@@ -1786,9 +1786,9 @@ discard block |
||
| 1786 | 1786 | $items = $this->get_items(); |
| 1787 | 1787 | $cart_details = array(); |
| 1788 | 1788 | |
| 1789 | - foreach ( $items as $item ) { |
|
| 1789 | + foreach ($items as $item) { |
|
| 1790 | 1790 | $item->invoice_id = $this->get_id(); |
| 1791 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1791 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | 1794 | return $cart_details; |
@@ -1799,11 +1799,11 @@ discard block |
||
| 1799 | 1799 | * |
| 1800 | 1800 | * @return null|GetPaid_Form_Item|int |
| 1801 | 1801 | */ |
| 1802 | - public function get_recurring( $object = false ) { |
|
| 1802 | + public function get_recurring($object = false) { |
|
| 1803 | 1803 | |
| 1804 | 1804 | // Are we returning an object? |
| 1805 | - if ( $object ) { |
|
| 1806 | - return $this->get_item( $this->recurring_item ); |
|
| 1805 | + if ($object) { |
|
| 1806 | + return $this->get_item($this->recurring_item); |
|
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | 1809 | return $this->recurring_item; |
@@ -1818,15 +1818,15 @@ discard block |
||
| 1818 | 1818 | public function get_subscription_name() { |
| 1819 | 1819 | |
| 1820 | 1820 | // Retrieve the recurring name |
| 1821 | - $item = $this->get_recurring( true ); |
|
| 1821 | + $item = $this->get_recurring(true); |
|
| 1822 | 1822 | |
| 1823 | 1823 | // Abort if it does not exist. |
| 1824 | - if ( empty( $item ) ) { |
|
| 1824 | + if (empty($item)) { |
|
| 1825 | 1825 | return ''; |
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | 1828 | // Return the item name. |
| 1829 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1829 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | /** |
@@ -1836,9 +1836,9 @@ discard block |
||
| 1836 | 1836 | * @return string |
| 1837 | 1837 | */ |
| 1838 | 1838 | public function get_view_url() { |
| 1839 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1840 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1841 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1839 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1840 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1841 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | 1844 | /** |
@@ -1847,25 +1847,25 @@ discard block |
||
| 1847 | 1847 | * @since 1.0.19 |
| 1848 | 1848 | * @return string |
| 1849 | 1849 | */ |
| 1850 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1850 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1851 | 1851 | |
| 1852 | 1852 | // Retrieve the checkout url. |
| 1853 | 1853 | $pay_url = wpinv_get_checkout_uri(); |
| 1854 | 1854 | |
| 1855 | 1855 | // Maybe force ssl. |
| 1856 | - if ( is_ssl() ) { |
|
| 1857 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1856 | + if (is_ssl()) { |
|
| 1857 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | 1860 | // Add the invoice key. |
| 1861 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1861 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1862 | 1862 | |
| 1863 | 1863 | // (Maybe?) add a secret |
| 1864 | - if ( $secret ) { |
|
| 1865 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1864 | + if ($secret) { |
|
| 1865 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1868 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | /** |
@@ -1880,14 +1880,14 @@ discard block |
||
| 1880 | 1880 | $receipt_url = wpinv_get_success_page_uri(); |
| 1881 | 1881 | |
| 1882 | 1882 | // Maybe force ssl. |
| 1883 | - if ( is_ssl() ) { |
|
| 1884 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1883 | + if (is_ssl()) { |
|
| 1884 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | 1887 | // Add the invoice key. |
| 1888 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1888 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1889 | 1889 | |
| 1890 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1890 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | /** |
@@ -1900,7 +1900,7 @@ discard block |
||
| 1900 | 1900 | |
| 1901 | 1901 | $type = $this->get_type(); |
| 1902 | 1902 | $status = "wpi-$type-pending"; |
| 1903 | - return str_replace( '-invoice', '', $status ); |
|
| 1903 | + return str_replace('-invoice', '', $status); |
|
| 1904 | 1904 | |
| 1905 | 1905 | } |
| 1906 | 1906 | |
@@ -1914,8 +1914,8 @@ discard block |
||
| 1914 | 1914 | * @param string $context View or edit context. |
| 1915 | 1915 | * @return mixed Value of the given invoice property (if set). |
| 1916 | 1916 | */ |
| 1917 | - public function get( $key, $context = 'view' ) { |
|
| 1918 | - return $this->get_prop( $key, $context ); |
|
| 1917 | + public function get($key, $context = 'view') { |
|
| 1918 | + return $this->get_prop($key, $context); |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | /* |
@@ -1938,11 +1938,11 @@ discard block |
||
| 1938 | 1938 | * @param mixed $value new value. |
| 1939 | 1939 | * @return mixed Value of the given invoice property (if set). |
| 1940 | 1940 | */ |
| 1941 | - public function set( $key, $value ) { |
|
| 1941 | + public function set($key, $value) { |
|
| 1942 | 1942 | |
| 1943 | 1943 | $setter = "set_$key"; |
| 1944 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1945 | - $this->{$setter}( $value ); |
|
| 1944 | + if (is_callable(array($this, $setter))) { |
|
| 1945 | + $this->{$setter}($value); |
|
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | 1948 | } |
@@ -1956,45 +1956,45 @@ discard block |
||
| 1956 | 1956 | * @param bool $manual_update Is this a manual status change?. |
| 1957 | 1957 | * @return array details of change. |
| 1958 | 1958 | */ |
| 1959 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1959 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1960 | 1960 | $old_status = $this->get_status(); |
| 1961 | 1961 | |
| 1962 | 1962 | $statuses = $this->get_all_statuses(); |
| 1963 | 1963 | |
| 1964 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1965 | - unset( $statuses[ 'draft' ] ); |
|
| 1964 | + if (isset($statuses['draft'])) { |
|
| 1965 | + unset($statuses['draft']); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | - $this->set_prop( 'status', $new_status ); |
|
| 1968 | + $this->set_prop('status', $new_status); |
|
| 1969 | 1969 | |
| 1970 | 1970 | // If setting the status, ensure it's set to a valid status. |
| 1971 | - if ( true === $this->object_read ) { |
|
| 1971 | + if (true === $this->object_read) { |
|
| 1972 | 1972 | |
| 1973 | 1973 | // Only allow valid new status. |
| 1974 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1974 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1975 | 1975 | $new_status = $this->get_default_status(); |
| 1976 | 1976 | } |
| 1977 | 1977 | |
| 1978 | 1978 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1979 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1979 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1980 | 1980 | $old_status = $this->get_default_status(); |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1984 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1984 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
| 1985 | 1985 | $old_status = 'wpi-pending'; |
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | - if ( $old_status !== $new_status ) { |
|
| 1988 | + if ($old_status !== $new_status) { |
|
| 1989 | 1989 | $this->status_transition = array( |
| 1990 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1990 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1991 | 1991 | 'to' => $new_status, |
| 1992 | 1992 | 'note' => $note, |
| 1993 | 1993 | 'manual' => (bool) $manual_update, |
| 1994 | 1994 | ); |
| 1995 | 1995 | |
| 1996 | - if ( $manual_update ) { |
|
| 1997 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1996 | + if ($manual_update) { |
|
| 1997 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1998 | 1998 | } |
| 1999 | 1999 | |
| 2000 | 2000 | $this->maybe_set_date_paid(); |
@@ -2019,8 +2019,8 @@ discard block |
||
| 2019 | 2019 | */ |
| 2020 | 2020 | public function maybe_set_date_paid() { |
| 2021 | 2021 | |
| 2022 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 2023 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 2022 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 2023 | + $this->set_date_completed(current_time('mysql')); |
|
| 2024 | 2024 | } |
| 2025 | 2025 | } |
| 2026 | 2026 | |
@@ -2029,11 +2029,11 @@ discard block |
||
| 2029 | 2029 | * |
| 2030 | 2030 | * @since 1.0.19 |
| 2031 | 2031 | */ |
| 2032 | - public function set_parent_id( $value ) { |
|
| 2033 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 2032 | + public function set_parent_id($value) { |
|
| 2033 | + if ($value && ($value === $this->get_id())) { |
|
| 2034 | 2034 | return; |
| 2035 | 2035 | } |
| 2036 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 2036 | + $this->set_prop('parent_id', absint($value)); |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | /** |
@@ -2041,8 +2041,8 @@ discard block |
||
| 2041 | 2041 | * |
| 2042 | 2042 | * @since 1.0.19 |
| 2043 | 2043 | */ |
| 2044 | - public function set_version( $value ) { |
|
| 2045 | - $this->set_prop( 'version', $value ); |
|
| 2044 | + public function set_version($value) { |
|
| 2045 | + $this->set_prop('version', $value); |
|
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | 2048 | /** |
@@ -2052,15 +2052,15 @@ discard block |
||
| 2052 | 2052 | * @param string $value Value to set. |
| 2053 | 2053 | * @return bool Whether or not the date was set. |
| 2054 | 2054 | */ |
| 2055 | - public function set_date_created( $value ) { |
|
| 2056 | - $date = strtotime( $value ); |
|
| 2055 | + public function set_date_created($value) { |
|
| 2056 | + $date = strtotime($value); |
|
| 2057 | 2057 | |
| 2058 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2059 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2058 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2059 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 2060 | 2060 | return true; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - $this->set_prop( 'date_created', '' ); |
|
| 2063 | + $this->set_prop('date_created', ''); |
|
| 2064 | 2064 | return false; |
| 2065 | 2065 | |
| 2066 | 2066 | } |
@@ -2072,15 +2072,15 @@ discard block |
||
| 2072 | 2072 | * @param string $value Value to set. |
| 2073 | 2073 | * @return bool Whether or not the date was set. |
| 2074 | 2074 | */ |
| 2075 | - public function set_due_date( $value ) { |
|
| 2076 | - $date = strtotime( $value ); |
|
| 2075 | + public function set_due_date($value) { |
|
| 2076 | + $date = strtotime($value); |
|
| 2077 | 2077 | |
| 2078 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2079 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2078 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2079 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 2080 | 2080 | return true; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | - $this->set_prop( 'due_date', '' ); |
|
| 2083 | + $this->set_prop('due_date', ''); |
|
| 2084 | 2084 | return false; |
| 2085 | 2085 | |
| 2086 | 2086 | } |
@@ -2091,8 +2091,8 @@ discard block |
||
| 2091 | 2091 | * @since 1.0.19 |
| 2092 | 2092 | * @param string $value New name. |
| 2093 | 2093 | */ |
| 2094 | - public function set_date_due( $value ) { |
|
| 2095 | - $this->set_due_date( $value ); |
|
| 2094 | + public function set_date_due($value) { |
|
| 2095 | + $this->set_due_date($value); |
|
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | /** |
@@ -2102,15 +2102,15 @@ discard block |
||
| 2102 | 2102 | * @param string $value Value to set. |
| 2103 | 2103 | * @return bool Whether or not the date was set. |
| 2104 | 2104 | */ |
| 2105 | - public function set_completed_date( $value ) { |
|
| 2106 | - $date = strtotime( $value ); |
|
| 2105 | + public function set_completed_date($value) { |
|
| 2106 | + $date = strtotime($value); |
|
| 2107 | 2107 | |
| 2108 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2109 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2108 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2109 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 2110 | 2110 | return true; |
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | - $this->set_prop( 'completed_date', '' ); |
|
| 2113 | + $this->set_prop('completed_date', ''); |
|
| 2114 | 2114 | return false; |
| 2115 | 2115 | |
| 2116 | 2116 | } |
@@ -2121,8 +2121,8 @@ discard block |
||
| 2121 | 2121 | * @since 1.0.19 |
| 2122 | 2122 | * @param string $value New name. |
| 2123 | 2123 | */ |
| 2124 | - public function set_date_completed( $value ) { |
|
| 2125 | - $this->set_completed_date( $value ); |
|
| 2124 | + public function set_date_completed($value) { |
|
| 2125 | + $this->set_completed_date($value); |
|
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | 2128 | /** |
@@ -2132,15 +2132,15 @@ discard block |
||
| 2132 | 2132 | * @param string $value Value to set. |
| 2133 | 2133 | * @return bool Whether or not the date was set. |
| 2134 | 2134 | */ |
| 2135 | - public function set_date_modified( $value ) { |
|
| 2136 | - $date = strtotime( $value ); |
|
| 2135 | + public function set_date_modified($value) { |
|
| 2136 | + $date = strtotime($value); |
|
| 2137 | 2137 | |
| 2138 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2139 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2138 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2139 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 2140 | 2140 | return true; |
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | - $this->set_prop( 'date_modified', '' ); |
|
| 2143 | + $this->set_prop('date_modified', ''); |
|
| 2144 | 2144 | return false; |
| 2145 | 2145 | |
| 2146 | 2146 | } |
@@ -2151,9 +2151,9 @@ discard block |
||
| 2151 | 2151 | * @since 1.0.19 |
| 2152 | 2152 | * @param string $value New number. |
| 2153 | 2153 | */ |
| 2154 | - public function set_number( $value ) { |
|
| 2155 | - $number = sanitize_text_field( $value ); |
|
| 2156 | - $this->set_prop( 'number', $number ); |
|
| 2154 | + public function set_number($value) { |
|
| 2155 | + $number = sanitize_text_field($value); |
|
| 2156 | + $this->set_prop('number', $number); |
|
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | 2159 | /** |
@@ -2162,9 +2162,9 @@ discard block |
||
| 2162 | 2162 | * @since 1.0.19 |
| 2163 | 2163 | * @param string $value Type. |
| 2164 | 2164 | */ |
| 2165 | - public function set_type( $value ) { |
|
| 2166 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2167 | - $this->set_prop( 'type', $type ); |
|
| 2165 | + public function set_type($value) { |
|
| 2166 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2167 | + $this->set_prop('type', $type); |
|
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | /** |
@@ -2173,10 +2173,10 @@ discard block |
||
| 2173 | 2173 | * @since 1.0.19 |
| 2174 | 2174 | * @param string $value Post type. |
| 2175 | 2175 | */ |
| 2176 | - public function set_post_type( $value ) { |
|
| 2177 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2178 | - $this->set_type( $value ); |
|
| 2179 | - $this->set_prop( 'post_type', $value ); |
|
| 2176 | + public function set_post_type($value) { |
|
| 2177 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2178 | + $this->set_type($value); |
|
| 2179 | + $this->set_prop('post_type', $value); |
|
| 2180 | 2180 | } |
| 2181 | 2181 | } |
| 2182 | 2182 | |
@@ -2186,9 +2186,9 @@ discard block |
||
| 2186 | 2186 | * @since 1.0.19 |
| 2187 | 2187 | * @param string $value New key. |
| 2188 | 2188 | */ |
| 2189 | - public function set_key( $value ) { |
|
| 2190 | - $key = sanitize_text_field( $value ); |
|
| 2191 | - $this->set_prop( 'key', $key ); |
|
| 2189 | + public function set_key($value) { |
|
| 2190 | + $key = sanitize_text_field($value); |
|
| 2191 | + $this->set_prop('key', $key); |
|
| 2192 | 2192 | } |
| 2193 | 2193 | |
| 2194 | 2194 | /** |
@@ -2197,9 +2197,9 @@ discard block |
||
| 2197 | 2197 | * @since 1.0.19 |
| 2198 | 2198 | * @param string $value mode. |
| 2199 | 2199 | */ |
| 2200 | - public function set_mode( $value ) { |
|
| 2201 | - if ( in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2202 | - $this->set_prop( 'mode', $value ); |
|
| 2200 | + public function set_mode($value) { |
|
| 2201 | + if (in_array($value, array('live', 'test'))) { |
|
| 2202 | + $this->set_prop('mode', $value); |
|
| 2203 | 2203 | } |
| 2204 | 2204 | } |
| 2205 | 2205 | |
@@ -2209,8 +2209,8 @@ discard block |
||
| 2209 | 2209 | * @since 1.0.19 |
| 2210 | 2210 | * @param string $value path. |
| 2211 | 2211 | */ |
| 2212 | - public function set_path( $value ) { |
|
| 2213 | - $this->set_prop( 'path', $value ); |
|
| 2212 | + public function set_path($value) { |
|
| 2213 | + $this->set_prop('path', $value); |
|
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | /** |
@@ -2219,9 +2219,9 @@ discard block |
||
| 2219 | 2219 | * @since 1.0.19 |
| 2220 | 2220 | * @param string $value New name. |
| 2221 | 2221 | */ |
| 2222 | - public function set_name( $value ) { |
|
| 2223 | - $name = sanitize_text_field( $value ); |
|
| 2224 | - $this->set_prop( 'name', $name ); |
|
| 2222 | + public function set_name($value) { |
|
| 2223 | + $name = sanitize_text_field($value); |
|
| 2224 | + $this->set_prop('name', $name); |
|
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | /** |
@@ -2230,8 +2230,8 @@ discard block |
||
| 2230 | 2230 | * @since 1.0.19 |
| 2231 | 2231 | * @param string $value New name. |
| 2232 | 2232 | */ |
| 2233 | - public function set_title( $value ) { |
|
| 2234 | - $this->set_name( $value ); |
|
| 2233 | + public function set_title($value) { |
|
| 2234 | + $this->set_name($value); |
|
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | 2237 | /** |
@@ -2240,9 +2240,9 @@ discard block |
||
| 2240 | 2240 | * @since 1.0.19 |
| 2241 | 2241 | * @param string $value New description. |
| 2242 | 2242 | */ |
| 2243 | - public function set_description( $value ) { |
|
| 2244 | - $description = wp_kses_post( $value ); |
|
| 2245 | - $this->set_prop( 'description', $description ); |
|
| 2243 | + public function set_description($value) { |
|
| 2244 | + $description = wp_kses_post($value); |
|
| 2245 | + $this->set_prop('description', $description); |
|
| 2246 | 2246 | } |
| 2247 | 2247 | |
| 2248 | 2248 | /** |
@@ -2251,8 +2251,8 @@ discard block |
||
| 2251 | 2251 | * @since 1.0.19 |
| 2252 | 2252 | * @param string $value New description. |
| 2253 | 2253 | */ |
| 2254 | - public function set_excerpt( $value ) { |
|
| 2255 | - $this->set_description( $value ); |
|
| 2254 | + public function set_excerpt($value) { |
|
| 2255 | + $this->set_description($value); |
|
| 2256 | 2256 | } |
| 2257 | 2257 | |
| 2258 | 2258 | /** |
@@ -2261,8 +2261,8 @@ discard block |
||
| 2261 | 2261 | * @since 1.0.19 |
| 2262 | 2262 | * @param string $value New description. |
| 2263 | 2263 | */ |
| 2264 | - public function set_summary( $value ) { |
|
| 2265 | - $this->set_description( $value ); |
|
| 2264 | + public function set_summary($value) { |
|
| 2265 | + $this->set_description($value); |
|
| 2266 | 2266 | } |
| 2267 | 2267 | |
| 2268 | 2268 | /** |
@@ -2271,12 +2271,12 @@ discard block |
||
| 2271 | 2271 | * @since 1.0.19 |
| 2272 | 2272 | * @param int $value New author. |
| 2273 | 2273 | */ |
| 2274 | - public function set_author( $value ) { |
|
| 2275 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2274 | + public function set_author($value) { |
|
| 2275 | + $user = get_user_by('id', (int) $value); |
|
| 2276 | 2276 | |
| 2277 | - if ( $user && $user->ID ) { |
|
| 2278 | - $this->set_prop( 'author', $user->ID ); |
|
| 2279 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2277 | + if ($user && $user->ID) { |
|
| 2278 | + $this->set_prop('author', $user->ID); |
|
| 2279 | + $this->set_prop('email', $user->user_email); |
|
| 2280 | 2280 | } |
| 2281 | 2281 | |
| 2282 | 2282 | } |
@@ -2287,8 +2287,8 @@ discard block |
||
| 2287 | 2287 | * @since 1.0.19 |
| 2288 | 2288 | * @param int $value New user id. |
| 2289 | 2289 | */ |
| 2290 | - public function set_user_id( $value ) { |
|
| 2291 | - $this->set_author( $value ); |
|
| 2290 | + public function set_user_id($value) { |
|
| 2291 | + $this->set_author($value); |
|
| 2292 | 2292 | } |
| 2293 | 2293 | |
| 2294 | 2294 | /** |
@@ -2297,8 +2297,8 @@ discard block |
||
| 2297 | 2297 | * @since 1.0.19 |
| 2298 | 2298 | * @param int $value New user id. |
| 2299 | 2299 | */ |
| 2300 | - public function set_customer_id( $value ) { |
|
| 2301 | - $this->set_author( $value ); |
|
| 2300 | + public function set_customer_id($value) { |
|
| 2301 | + $this->set_author($value); |
|
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | 2304 | /** |
@@ -2307,8 +2307,8 @@ discard block |
||
| 2307 | 2307 | * @since 1.0.19 |
| 2308 | 2308 | * @param string $value ip address. |
| 2309 | 2309 | */ |
| 2310 | - public function set_ip( $value ) { |
|
| 2311 | - $this->set_prop( 'ip', $value ); |
|
| 2310 | + public function set_ip($value) { |
|
| 2311 | + $this->set_prop('ip', $value); |
|
| 2312 | 2312 | } |
| 2313 | 2313 | |
| 2314 | 2314 | /** |
@@ -2317,8 +2317,8 @@ discard block |
||
| 2317 | 2317 | * @since 1.0.19 |
| 2318 | 2318 | * @param string $value ip address. |
| 2319 | 2319 | */ |
| 2320 | - public function set_user_ip( $value ) { |
|
| 2321 | - $this->set_ip( $value ); |
|
| 2320 | + public function set_user_ip($value) { |
|
| 2321 | + $this->set_ip($value); |
|
| 2322 | 2322 | } |
| 2323 | 2323 | |
| 2324 | 2324 | /** |
@@ -2327,8 +2327,8 @@ discard block |
||
| 2327 | 2327 | * @since 1.0.19 |
| 2328 | 2328 | * @param string $value first name. |
| 2329 | 2329 | */ |
| 2330 | - public function set_first_name( $value ) { |
|
| 2331 | - $this->set_prop( 'first_name', $value ); |
|
| 2330 | + public function set_first_name($value) { |
|
| 2331 | + $this->set_prop('first_name', $value); |
|
| 2332 | 2332 | } |
| 2333 | 2333 | |
| 2334 | 2334 | /** |
@@ -2337,8 +2337,8 @@ discard block |
||
| 2337 | 2337 | * @since 1.0.19 |
| 2338 | 2338 | * @param string $value first name. |
| 2339 | 2339 | */ |
| 2340 | - public function set_user_first_name( $value ) { |
|
| 2341 | - $this->set_first_name( $value ); |
|
| 2340 | + public function set_user_first_name($value) { |
|
| 2341 | + $this->set_first_name($value); |
|
| 2342 | 2342 | } |
| 2343 | 2343 | |
| 2344 | 2344 | /** |
@@ -2347,8 +2347,8 @@ discard block |
||
| 2347 | 2347 | * @since 1.0.19 |
| 2348 | 2348 | * @param string $value first name. |
| 2349 | 2349 | */ |
| 2350 | - public function set_customer_first_name( $value ) { |
|
| 2351 | - $this->set_first_name( $value ); |
|
| 2350 | + public function set_customer_first_name($value) { |
|
| 2351 | + $this->set_first_name($value); |
|
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | 2354 | /** |
@@ -2357,8 +2357,8 @@ discard block |
||
| 2357 | 2357 | * @since 1.0.19 |
| 2358 | 2358 | * @param string $value last name. |
| 2359 | 2359 | */ |
| 2360 | - public function set_last_name( $value ) { |
|
| 2361 | - $this->set_prop( 'last_name', $value ); |
|
| 2360 | + public function set_last_name($value) { |
|
| 2361 | + $this->set_prop('last_name', $value); |
|
| 2362 | 2362 | } |
| 2363 | 2363 | |
| 2364 | 2364 | /** |
@@ -2367,8 +2367,8 @@ discard block |
||
| 2367 | 2367 | * @since 1.0.19 |
| 2368 | 2368 | * @param string $value last name. |
| 2369 | 2369 | */ |
| 2370 | - public function set_user_last_name( $value ) { |
|
| 2371 | - $this->set_last_name( $value ); |
|
| 2370 | + public function set_user_last_name($value) { |
|
| 2371 | + $this->set_last_name($value); |
|
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | 2374 | /** |
@@ -2377,8 +2377,8 @@ discard block |
||
| 2377 | 2377 | * @since 1.0.19 |
| 2378 | 2378 | * @param string $value last name. |
| 2379 | 2379 | */ |
| 2380 | - public function set_customer_last_name( $value ) { |
|
| 2381 | - $this->set_last_name( $value ); |
|
| 2380 | + public function set_customer_last_name($value) { |
|
| 2381 | + $this->set_last_name($value); |
|
| 2382 | 2382 | } |
| 2383 | 2383 | |
| 2384 | 2384 | /** |
@@ -2387,8 +2387,8 @@ discard block |
||
| 2387 | 2387 | * @since 1.0.19 |
| 2388 | 2388 | * @param string $value phone. |
| 2389 | 2389 | */ |
| 2390 | - public function set_phone( $value ) { |
|
| 2391 | - $this->set_prop( 'phone', $value ); |
|
| 2390 | + public function set_phone($value) { |
|
| 2391 | + $this->set_prop('phone', $value); |
|
| 2392 | 2392 | } |
| 2393 | 2393 | |
| 2394 | 2394 | /** |
@@ -2397,8 +2397,8 @@ discard block |
||
| 2397 | 2397 | * @since 1.0.19 |
| 2398 | 2398 | * @param string $value phone. |
| 2399 | 2399 | */ |
| 2400 | - public function set_user_phone( $value ) { |
|
| 2401 | - $this->set_phone( $value ); |
|
| 2400 | + public function set_user_phone($value) { |
|
| 2401 | + $this->set_phone($value); |
|
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | 2404 | /** |
@@ -2407,8 +2407,8 @@ discard block |
||
| 2407 | 2407 | * @since 1.0.19 |
| 2408 | 2408 | * @param string $value phone. |
| 2409 | 2409 | */ |
| 2410 | - public function set_customer_phone( $value ) { |
|
| 2411 | - $this->set_phone( $value ); |
|
| 2410 | + public function set_customer_phone($value) { |
|
| 2411 | + $this->set_phone($value); |
|
| 2412 | 2412 | } |
| 2413 | 2413 | |
| 2414 | 2414 | /** |
@@ -2417,8 +2417,8 @@ discard block |
||
| 2417 | 2417 | * @since 1.0.19 |
| 2418 | 2418 | * @param string $value phone. |
| 2419 | 2419 | */ |
| 2420 | - public function set_phone_number( $value ) { |
|
| 2421 | - $this->set_phone( $value ); |
|
| 2420 | + public function set_phone_number($value) { |
|
| 2421 | + $this->set_phone($value); |
|
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | 2424 | /** |
@@ -2427,8 +2427,8 @@ discard block |
||
| 2427 | 2427 | * @since 1.0.19 |
| 2428 | 2428 | * @param string $value email address. |
| 2429 | 2429 | */ |
| 2430 | - public function set_email( $value ) { |
|
| 2431 | - $this->set_prop( 'email', $value ); |
|
| 2430 | + public function set_email($value) { |
|
| 2431 | + $this->set_prop('email', $value); |
|
| 2432 | 2432 | } |
| 2433 | 2433 | |
| 2434 | 2434 | /** |
@@ -2437,8 +2437,8 @@ discard block |
||
| 2437 | 2437 | * @since 1.0.19 |
| 2438 | 2438 | * @param string $value email address. |
| 2439 | 2439 | */ |
| 2440 | - public function set_user_email( $value ) { |
|
| 2441 | - $this->set_email( $value ); |
|
| 2440 | + public function set_user_email($value) { |
|
| 2441 | + $this->set_email($value); |
|
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | 2444 | /** |
@@ -2447,8 +2447,8 @@ discard block |
||
| 2447 | 2447 | * @since 1.0.19 |
| 2448 | 2448 | * @param string $value email address. |
| 2449 | 2449 | */ |
| 2450 | - public function set_email_address( $value ) { |
|
| 2451 | - $this->set_email( $value ); |
|
| 2450 | + public function set_email_address($value) { |
|
| 2451 | + $this->set_email($value); |
|
| 2452 | 2452 | } |
| 2453 | 2453 | |
| 2454 | 2454 | /** |
@@ -2457,8 +2457,8 @@ discard block |
||
| 2457 | 2457 | * @since 1.0.19 |
| 2458 | 2458 | * @param string $value email address. |
| 2459 | 2459 | */ |
| 2460 | - public function set_customer_email( $value ) { |
|
| 2461 | - $this->set_email( $value ); |
|
| 2460 | + public function set_customer_email($value) { |
|
| 2461 | + $this->set_email($value); |
|
| 2462 | 2462 | } |
| 2463 | 2463 | |
| 2464 | 2464 | /** |
@@ -2467,8 +2467,8 @@ discard block |
||
| 2467 | 2467 | * @since 1.0.19 |
| 2468 | 2468 | * @param string $value country. |
| 2469 | 2469 | */ |
| 2470 | - public function set_country( $value ) { |
|
| 2471 | - $this->set_prop( 'country', $value ); |
|
| 2470 | + public function set_country($value) { |
|
| 2471 | + $this->set_prop('country', $value); |
|
| 2472 | 2472 | } |
| 2473 | 2473 | |
| 2474 | 2474 | /** |
@@ -2477,8 +2477,8 @@ discard block |
||
| 2477 | 2477 | * @since 1.0.19 |
| 2478 | 2478 | * @param string $value country. |
| 2479 | 2479 | */ |
| 2480 | - public function set_user_country( $value ) { |
|
| 2481 | - $this->set_country( $value ); |
|
| 2480 | + public function set_user_country($value) { |
|
| 2481 | + $this->set_country($value); |
|
| 2482 | 2482 | } |
| 2483 | 2483 | |
| 2484 | 2484 | /** |
@@ -2487,8 +2487,8 @@ discard block |
||
| 2487 | 2487 | * @since 1.0.19 |
| 2488 | 2488 | * @param string $value country. |
| 2489 | 2489 | */ |
| 2490 | - public function set_customer_country( $value ) { |
|
| 2491 | - $this->set_country( $value ); |
|
| 2490 | + public function set_customer_country($value) { |
|
| 2491 | + $this->set_country($value); |
|
| 2492 | 2492 | } |
| 2493 | 2493 | |
| 2494 | 2494 | /** |
@@ -2497,8 +2497,8 @@ discard block |
||
| 2497 | 2497 | * @since 1.0.19 |
| 2498 | 2498 | * @param string $value state. |
| 2499 | 2499 | */ |
| 2500 | - public function set_state( $value ) { |
|
| 2501 | - $this->set_prop( 'state', $value ); |
|
| 2500 | + public function set_state($value) { |
|
| 2501 | + $this->set_prop('state', $value); |
|
| 2502 | 2502 | } |
| 2503 | 2503 | |
| 2504 | 2504 | /** |
@@ -2507,8 +2507,8 @@ discard block |
||
| 2507 | 2507 | * @since 1.0.19 |
| 2508 | 2508 | * @param string $value state. |
| 2509 | 2509 | */ |
| 2510 | - public function set_user_state( $value ) { |
|
| 2511 | - $this->set_state( $value ); |
|
| 2510 | + public function set_user_state($value) { |
|
| 2511 | + $this->set_state($value); |
|
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | 2514 | /** |
@@ -2517,8 +2517,8 @@ discard block |
||
| 2517 | 2517 | * @since 1.0.19 |
| 2518 | 2518 | * @param string $value state. |
| 2519 | 2519 | */ |
| 2520 | - public function set_customer_state( $value ) { |
|
| 2521 | - $this->set_state( $value ); |
|
| 2520 | + public function set_customer_state($value) { |
|
| 2521 | + $this->set_state($value); |
|
| 2522 | 2522 | } |
| 2523 | 2523 | |
| 2524 | 2524 | /** |
@@ -2527,8 +2527,8 @@ discard block |
||
| 2527 | 2527 | * @since 1.0.19 |
| 2528 | 2528 | * @param string $value city. |
| 2529 | 2529 | */ |
| 2530 | - public function set_city( $value ) { |
|
| 2531 | - $this->set_prop( 'city', $value ); |
|
| 2530 | + public function set_city($value) { |
|
| 2531 | + $this->set_prop('city', $value); |
|
| 2532 | 2532 | } |
| 2533 | 2533 | |
| 2534 | 2534 | /** |
@@ -2537,8 +2537,8 @@ discard block |
||
| 2537 | 2537 | * @since 1.0.19 |
| 2538 | 2538 | * @param string $value city. |
| 2539 | 2539 | */ |
| 2540 | - public function set_user_city( $value ) { |
|
| 2541 | - $this->set_city( $value ); |
|
| 2540 | + public function set_user_city($value) { |
|
| 2541 | + $this->set_city($value); |
|
| 2542 | 2542 | } |
| 2543 | 2543 | |
| 2544 | 2544 | /** |
@@ -2547,8 +2547,8 @@ discard block |
||
| 2547 | 2547 | * @since 1.0.19 |
| 2548 | 2548 | * @param string $value city. |
| 2549 | 2549 | */ |
| 2550 | - public function set_customer_city( $value ) { |
|
| 2551 | - $this->set_city( $value ); |
|
| 2550 | + public function set_customer_city($value) { |
|
| 2551 | + $this->set_city($value); |
|
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | 2554 | /** |
@@ -2557,8 +2557,8 @@ discard block |
||
| 2557 | 2557 | * @since 1.0.19 |
| 2558 | 2558 | * @param string $value zip. |
| 2559 | 2559 | */ |
| 2560 | - public function set_zip( $value ) { |
|
| 2561 | - $this->set_prop( 'zip', $value ); |
|
| 2560 | + public function set_zip($value) { |
|
| 2561 | + $this->set_prop('zip', $value); |
|
| 2562 | 2562 | } |
| 2563 | 2563 | |
| 2564 | 2564 | /** |
@@ -2567,8 +2567,8 @@ discard block |
||
| 2567 | 2567 | * @since 1.0.19 |
| 2568 | 2568 | * @param string $value zip. |
| 2569 | 2569 | */ |
| 2570 | - public function set_user_zip( $value ) { |
|
| 2571 | - $this->set_zip( $value ); |
|
| 2570 | + public function set_user_zip($value) { |
|
| 2571 | + $this->set_zip($value); |
|
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | 2574 | /** |
@@ -2577,8 +2577,8 @@ discard block |
||
| 2577 | 2577 | * @since 1.0.19 |
| 2578 | 2578 | * @param string $value zip. |
| 2579 | 2579 | */ |
| 2580 | - public function set_customer_zip( $value ) { |
|
| 2581 | - $this->set_zip( $value ); |
|
| 2580 | + public function set_customer_zip($value) { |
|
| 2581 | + $this->set_zip($value); |
|
| 2582 | 2582 | } |
| 2583 | 2583 | |
| 2584 | 2584 | /** |
@@ -2587,8 +2587,8 @@ discard block |
||
| 2587 | 2587 | * @since 1.0.19 |
| 2588 | 2588 | * @param string $value company. |
| 2589 | 2589 | */ |
| 2590 | - public function set_company( $value ) { |
|
| 2591 | - $this->set_prop( 'company', $value ); |
|
| 2590 | + public function set_company($value) { |
|
| 2591 | + $this->set_prop('company', $value); |
|
| 2592 | 2592 | } |
| 2593 | 2593 | |
| 2594 | 2594 | /** |
@@ -2597,8 +2597,8 @@ discard block |
||
| 2597 | 2597 | * @since 1.0.19 |
| 2598 | 2598 | * @param string $value company. |
| 2599 | 2599 | */ |
| 2600 | - public function set_user_company( $value ) { |
|
| 2601 | - $this->set_company( $value ); |
|
| 2600 | + public function set_user_company($value) { |
|
| 2601 | + $this->set_company($value); |
|
| 2602 | 2602 | } |
| 2603 | 2603 | |
| 2604 | 2604 | /** |
@@ -2607,8 +2607,8 @@ discard block |
||
| 2607 | 2607 | * @since 1.0.19 |
| 2608 | 2608 | * @param string $value company. |
| 2609 | 2609 | */ |
| 2610 | - public function set_customer_company( $value ) { |
|
| 2611 | - $this->set_company( $value ); |
|
| 2610 | + public function set_customer_company($value) { |
|
| 2611 | + $this->set_company($value); |
|
| 2612 | 2612 | } |
| 2613 | 2613 | |
| 2614 | 2614 | /** |
@@ -2617,8 +2617,8 @@ discard block |
||
| 2617 | 2617 | * @since 1.0.19 |
| 2618 | 2618 | * @param string $value company id. |
| 2619 | 2619 | */ |
| 2620 | - public function set_company_id( $value ) { |
|
| 2621 | - $this->set_prop( 'company_id', $value ); |
|
| 2620 | + public function set_company_id($value) { |
|
| 2621 | + $this->set_prop('company_id', $value); |
|
| 2622 | 2622 | } |
| 2623 | 2623 | |
| 2624 | 2624 | /** |
@@ -2627,8 +2627,8 @@ discard block |
||
| 2627 | 2627 | * @since 1.0.19 |
| 2628 | 2628 | * @param string $value var number. |
| 2629 | 2629 | */ |
| 2630 | - public function set_vat_number( $value ) { |
|
| 2631 | - $this->set_prop( 'vat_number', $value ); |
|
| 2630 | + public function set_vat_number($value) { |
|
| 2631 | + $this->set_prop('vat_number', $value); |
|
| 2632 | 2632 | } |
| 2633 | 2633 | |
| 2634 | 2634 | /** |
@@ -2637,8 +2637,8 @@ discard block |
||
| 2637 | 2637 | * @since 1.0.19 |
| 2638 | 2638 | * @param string $value var number. |
| 2639 | 2639 | */ |
| 2640 | - public function set_user_vat_number( $value ) { |
|
| 2641 | - $this->set_vat_number( $value ); |
|
| 2640 | + public function set_user_vat_number($value) { |
|
| 2641 | + $this->set_vat_number($value); |
|
| 2642 | 2642 | } |
| 2643 | 2643 | |
| 2644 | 2644 | /** |
@@ -2647,8 +2647,8 @@ discard block |
||
| 2647 | 2647 | * @since 1.0.19 |
| 2648 | 2648 | * @param string $value var number. |
| 2649 | 2649 | */ |
| 2650 | - public function set_customer_vat_number( $value ) { |
|
| 2651 | - $this->set_vat_number( $value ); |
|
| 2650 | + public function set_customer_vat_number($value) { |
|
| 2651 | + $this->set_vat_number($value); |
|
| 2652 | 2652 | } |
| 2653 | 2653 | |
| 2654 | 2654 | /** |
@@ -2657,8 +2657,8 @@ discard block |
||
| 2657 | 2657 | * @since 1.0.19 |
| 2658 | 2658 | * @param string $value var rate. |
| 2659 | 2659 | */ |
| 2660 | - public function set_vat_rate( $value ) { |
|
| 2661 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2660 | + public function set_vat_rate($value) { |
|
| 2661 | + $this->set_prop('vat_rate', $value); |
|
| 2662 | 2662 | } |
| 2663 | 2663 | |
| 2664 | 2664 | /** |
@@ -2667,8 +2667,8 @@ discard block |
||
| 2667 | 2667 | * @since 1.0.19 |
| 2668 | 2668 | * @param string $value var number. |
| 2669 | 2669 | */ |
| 2670 | - public function set_user_vat_rate( $value ) { |
|
| 2671 | - $this->set_vat_rate( $value ); |
|
| 2670 | + public function set_user_vat_rate($value) { |
|
| 2671 | + $this->set_vat_rate($value); |
|
| 2672 | 2672 | } |
| 2673 | 2673 | |
| 2674 | 2674 | /** |
@@ -2677,8 +2677,8 @@ discard block |
||
| 2677 | 2677 | * @since 1.0.19 |
| 2678 | 2678 | * @param string $value var number. |
| 2679 | 2679 | */ |
| 2680 | - public function set_customer_vat_rate( $value ) { |
|
| 2681 | - $this->set_vat_rate( $value ); |
|
| 2680 | + public function set_customer_vat_rate($value) { |
|
| 2681 | + $this->set_vat_rate($value); |
|
| 2682 | 2682 | } |
| 2683 | 2683 | |
| 2684 | 2684 | /** |
@@ -2687,8 +2687,8 @@ discard block |
||
| 2687 | 2687 | * @since 1.0.19 |
| 2688 | 2688 | * @param string $value address. |
| 2689 | 2689 | */ |
| 2690 | - public function set_address( $value ) { |
|
| 2691 | - $this->set_prop( 'address', $value ); |
|
| 2690 | + public function set_address($value) { |
|
| 2691 | + $this->set_prop('address', $value); |
|
| 2692 | 2692 | } |
| 2693 | 2693 | |
| 2694 | 2694 | /** |
@@ -2697,8 +2697,8 @@ discard block |
||
| 2697 | 2697 | * @since 1.0.19 |
| 2698 | 2698 | * @param string $value address. |
| 2699 | 2699 | */ |
| 2700 | - public function set_user_address( $value ) { |
|
| 2701 | - $this->set_address( $value ); |
|
| 2700 | + public function set_user_address($value) { |
|
| 2701 | + $this->set_address($value); |
|
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | 2704 | /** |
@@ -2707,8 +2707,8 @@ discard block |
||
| 2707 | 2707 | * @since 1.0.19 |
| 2708 | 2708 | * @param string $value address. |
| 2709 | 2709 | */ |
| 2710 | - public function set_customer_address( $value ) { |
|
| 2711 | - $this->set_address( $value ); |
|
| 2710 | + public function set_customer_address($value) { |
|
| 2711 | + $this->set_address($value); |
|
| 2712 | 2712 | } |
| 2713 | 2713 | |
| 2714 | 2714 | /** |
@@ -2717,8 +2717,8 @@ discard block |
||
| 2717 | 2717 | * @since 1.0.19 |
| 2718 | 2718 | * @param int|bool $value confirmed. |
| 2719 | 2719 | */ |
| 2720 | - public function set_is_viewed( $value ) { |
|
| 2721 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2720 | + public function set_is_viewed($value) { |
|
| 2721 | + $this->set_prop('is_viewed', $value); |
|
| 2722 | 2722 | } |
| 2723 | 2723 | |
| 2724 | 2724 | /** |
@@ -2727,8 +2727,8 @@ discard block |
||
| 2727 | 2727 | * @since 1.0.19 |
| 2728 | 2728 | * @param string $value email recipients. |
| 2729 | 2729 | */ |
| 2730 | - public function set_email_cc( $value ) { |
|
| 2731 | - $this->set_prop( 'email_cc', $value ); |
|
| 2730 | + public function set_email_cc($value) { |
|
| 2731 | + $this->set_prop('email_cc', $value); |
|
| 2732 | 2732 | } |
| 2733 | 2733 | |
| 2734 | 2734 | /** |
@@ -2737,9 +2737,9 @@ discard block |
||
| 2737 | 2737 | * @since 1.0.19 |
| 2738 | 2738 | * @param string $value template. |
| 2739 | 2739 | */ |
| 2740 | - public function set_template( $value ) { |
|
| 2741 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2742 | - $this->set_prop( 'template', $value ); |
|
| 2740 | + public function set_template($value) { |
|
| 2741 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2742 | + $this->set_prop('template', $value); |
|
| 2743 | 2743 | } |
| 2744 | 2744 | } |
| 2745 | 2745 | |
@@ -2750,8 +2750,8 @@ discard block |
||
| 2750 | 2750 | * @param string $value source. |
| 2751 | 2751 | * @deprecated |
| 2752 | 2752 | */ |
| 2753 | - public function created_via( $value ) { |
|
| 2754 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
| 2753 | + public function created_via($value) { |
|
| 2754 | + $this->set_created_via(sanitize_text_field($value)); |
|
| 2755 | 2755 | } |
| 2756 | 2756 | |
| 2757 | 2757 | /** |
@@ -2760,8 +2760,8 @@ discard block |
||
| 2760 | 2760 | * @since 1.0.19 |
| 2761 | 2761 | * @param string $value source. |
| 2762 | 2762 | */ |
| 2763 | - public function set_created_via( $value ) { |
|
| 2764 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2763 | + public function set_created_via($value) { |
|
| 2764 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
| 2765 | 2765 | } |
| 2766 | 2766 | |
| 2767 | 2767 | /** |
@@ -2770,8 +2770,8 @@ discard block |
||
| 2770 | 2770 | * @since 1.0.19 |
| 2771 | 2771 | * @param int|bool $value confirmed. |
| 2772 | 2772 | */ |
| 2773 | - public function set_address_confirmed( $value ) { |
|
| 2774 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2773 | + public function set_address_confirmed($value) { |
|
| 2774 | + $this->set_prop('address_confirmed', $value); |
|
| 2775 | 2775 | } |
| 2776 | 2776 | |
| 2777 | 2777 | /** |
@@ -2780,8 +2780,8 @@ discard block |
||
| 2780 | 2780 | * @since 1.0.19 |
| 2781 | 2781 | * @param int|bool $value confirmed. |
| 2782 | 2782 | */ |
| 2783 | - public function set_user_address_confirmed( $value ) { |
|
| 2784 | - $this->set_address_confirmed( $value ); |
|
| 2783 | + public function set_user_address_confirmed($value) { |
|
| 2784 | + $this->set_address_confirmed($value); |
|
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | 2787 | /** |
@@ -2790,8 +2790,8 @@ discard block |
||
| 2790 | 2790 | * @since 1.0.19 |
| 2791 | 2791 | * @param int|bool $value confirmed. |
| 2792 | 2792 | */ |
| 2793 | - public function set_customer_address_confirmed( $value ) { |
|
| 2794 | - $this->set_address_confirmed( $value ); |
|
| 2793 | + public function set_customer_address_confirmed($value) { |
|
| 2794 | + $this->set_address_confirmed($value); |
|
| 2795 | 2795 | } |
| 2796 | 2796 | |
| 2797 | 2797 | /** |
@@ -2800,8 +2800,8 @@ discard block |
||
| 2800 | 2800 | * @since 1.0.19 |
| 2801 | 2801 | * @param float $value sub total. |
| 2802 | 2802 | */ |
| 2803 | - public function set_subtotal( $value ) { |
|
| 2804 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
| 2803 | + public function set_subtotal($value) { |
|
| 2804 | + $this->set_prop('subtotal', max(0, $value)); |
|
| 2805 | 2805 | } |
| 2806 | 2806 | |
| 2807 | 2807 | /** |
@@ -2810,8 +2810,8 @@ discard block |
||
| 2810 | 2810 | * @since 1.0.19 |
| 2811 | 2811 | * @param float $value sub total. |
| 2812 | 2812 | */ |
| 2813 | - public function set_total( $value ) { |
|
| 2814 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
| 2813 | + public function set_total($value) { |
|
| 2814 | + $this->set_prop('total', max(0, $value)); |
|
| 2815 | 2815 | } |
| 2816 | 2816 | |
| 2817 | 2817 | /** |
@@ -2820,8 +2820,8 @@ discard block |
||
| 2820 | 2820 | * @since 1.0.19 |
| 2821 | 2821 | * @param float $value discount total. |
| 2822 | 2822 | */ |
| 2823 | - public function set_total_discount( $value ) { |
|
| 2824 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
| 2823 | + public function set_total_discount($value) { |
|
| 2824 | + $this->set_prop('total_discount', max(0, $value)); |
|
| 2825 | 2825 | } |
| 2826 | 2826 | |
| 2827 | 2827 | /** |
@@ -2830,8 +2830,8 @@ discard block |
||
| 2830 | 2830 | * @since 1.0.19 |
| 2831 | 2831 | * @param float $value discount total. |
| 2832 | 2832 | */ |
| 2833 | - public function set_discount( $value ) { |
|
| 2834 | - $this->set_total_discount( $value ); |
|
| 2833 | + public function set_discount($value) { |
|
| 2834 | + $this->set_total_discount($value); |
|
| 2835 | 2835 | } |
| 2836 | 2836 | |
| 2837 | 2837 | /** |
@@ -2840,8 +2840,8 @@ discard block |
||
| 2840 | 2840 | * @since 1.0.19 |
| 2841 | 2841 | * @param float $value tax total. |
| 2842 | 2842 | */ |
| 2843 | - public function set_total_tax( $value ) { |
|
| 2844 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
| 2843 | + public function set_total_tax($value) { |
|
| 2844 | + $this->set_prop('total_tax', max(0, $value)); |
|
| 2845 | 2845 | } |
| 2846 | 2846 | |
| 2847 | 2847 | /** |
@@ -2850,8 +2850,8 @@ discard block |
||
| 2850 | 2850 | * @since 1.0.19 |
| 2851 | 2851 | * @param float $value tax total. |
| 2852 | 2852 | */ |
| 2853 | - public function set_tax_total( $value ) { |
|
| 2854 | - $this->set_total_tax( $value ); |
|
| 2853 | + public function set_tax_total($value) { |
|
| 2854 | + $this->set_total_tax($value); |
|
| 2855 | 2855 | } |
| 2856 | 2856 | |
| 2857 | 2857 | /** |
@@ -2860,8 +2860,8 @@ discard block |
||
| 2860 | 2860 | * @since 1.0.19 |
| 2861 | 2861 | * @param float $value fees total. |
| 2862 | 2862 | */ |
| 2863 | - public function set_total_fees( $value ) { |
|
| 2864 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
| 2863 | + public function set_total_fees($value) { |
|
| 2864 | + $this->set_prop('total_fees', max(0, $value)); |
|
| 2865 | 2865 | } |
| 2866 | 2866 | |
| 2867 | 2867 | /** |
@@ -2870,8 +2870,8 @@ discard block |
||
| 2870 | 2870 | * @since 1.0.19 |
| 2871 | 2871 | * @param float $value fees total. |
| 2872 | 2872 | */ |
| 2873 | - public function set_fees_total( $value ) { |
|
| 2874 | - $this->set_total_fees( $value ); |
|
| 2873 | + public function set_fees_total($value) { |
|
| 2874 | + $this->set_total_fees($value); |
|
| 2875 | 2875 | } |
| 2876 | 2876 | |
| 2877 | 2877 | /** |
@@ -2880,13 +2880,13 @@ discard block |
||
| 2880 | 2880 | * @since 1.0.19 |
| 2881 | 2881 | * @param array $value fees. |
| 2882 | 2882 | */ |
| 2883 | - public function set_fees( $value ) { |
|
| 2883 | + public function set_fees($value) { |
|
| 2884 | 2884 | |
| 2885 | - if ( ! is_array( $value ) ) { |
|
| 2885 | + if (!is_array($value)) { |
|
| 2886 | 2886 | $value = array(); |
| 2887 | 2887 | } |
| 2888 | 2888 | |
| 2889 | - $this->set_prop( 'fees', $value ); |
|
| 2889 | + $this->set_prop('fees', $value); |
|
| 2890 | 2890 | |
| 2891 | 2891 | } |
| 2892 | 2892 | |
@@ -2896,13 +2896,13 @@ discard block |
||
| 2896 | 2896 | * @since 1.0.19 |
| 2897 | 2897 | * @param array $value taxes. |
| 2898 | 2898 | */ |
| 2899 | - public function set_taxes( $value ) { |
|
| 2899 | + public function set_taxes($value) { |
|
| 2900 | 2900 | |
| 2901 | - if ( ! is_array( $value ) ) { |
|
| 2901 | + if (!is_array($value)) { |
|
| 2902 | 2902 | $value = array(); |
| 2903 | 2903 | } |
| 2904 | 2904 | |
| 2905 | - $this->set_prop( 'taxes', $value ); |
|
| 2905 | + $this->set_prop('taxes', $value); |
|
| 2906 | 2906 | |
| 2907 | 2907 | } |
| 2908 | 2908 | |
@@ -2912,13 +2912,13 @@ discard block |
||
| 2912 | 2912 | * @since 1.0.19 |
| 2913 | 2913 | * @param array $value discounts. |
| 2914 | 2914 | */ |
| 2915 | - public function set_discounts( $value ) { |
|
| 2915 | + public function set_discounts($value) { |
|
| 2916 | 2916 | |
| 2917 | - if ( ! is_array( $value ) ) { |
|
| 2917 | + if (!is_array($value)) { |
|
| 2918 | 2918 | $value = array(); |
| 2919 | 2919 | } |
| 2920 | 2920 | |
| 2921 | - $this->set_prop( 'discounts', $value ); |
|
| 2921 | + $this->set_prop('discounts', $value); |
|
| 2922 | 2922 | } |
| 2923 | 2923 | |
| 2924 | 2924 | /** |
@@ -2927,19 +2927,19 @@ discard block |
||
| 2927 | 2927 | * @since 1.0.19 |
| 2928 | 2928 | * @param GetPaid_Form_Item[] $value items. |
| 2929 | 2929 | */ |
| 2930 | - public function set_items( $value ) { |
|
| 2930 | + public function set_items($value) { |
|
| 2931 | 2931 | |
| 2932 | 2932 | // Remove existing items. |
| 2933 | - $this->set_prop( 'items', array() ); |
|
| 2933 | + $this->set_prop('items', array()); |
|
| 2934 | 2934 | $this->recurring_item = null; |
| 2935 | 2935 | |
| 2936 | 2936 | // Ensure that we have an array. |
| 2937 | - if ( ! is_array( $value ) ) { |
|
| 2937 | + if (!is_array($value)) { |
|
| 2938 | 2938 | return; |
| 2939 | 2939 | } |
| 2940 | 2940 | |
| 2941 | - foreach ( $value as $item ) { |
|
| 2942 | - $this->add_item( $item ); |
|
| 2941 | + foreach ($value as $item) { |
|
| 2942 | + $this->add_item($item); |
|
| 2943 | 2943 | } |
| 2944 | 2944 | |
| 2945 | 2945 | } |
@@ -2950,8 +2950,8 @@ discard block |
||
| 2950 | 2950 | * @since 1.0.19 |
| 2951 | 2951 | * @param int $value payment form. |
| 2952 | 2952 | */ |
| 2953 | - public function set_payment_form( $value ) { |
|
| 2954 | - $this->set_prop( 'payment_form', $value ); |
|
| 2953 | + public function set_payment_form($value) { |
|
| 2954 | + $this->set_prop('payment_form', $value); |
|
| 2955 | 2955 | } |
| 2956 | 2956 | |
| 2957 | 2957 | /** |
@@ -2960,8 +2960,8 @@ discard block |
||
| 2960 | 2960 | * @since 1.0.19 |
| 2961 | 2961 | * @param string $value submission id. |
| 2962 | 2962 | */ |
| 2963 | - public function set_submission_id( $value ) { |
|
| 2964 | - $this->set_prop( 'submission_id', $value ); |
|
| 2963 | + public function set_submission_id($value) { |
|
| 2964 | + $this->set_prop('submission_id', $value); |
|
| 2965 | 2965 | } |
| 2966 | 2966 | |
| 2967 | 2967 | /** |
@@ -2970,8 +2970,8 @@ discard block |
||
| 2970 | 2970 | * @since 1.0.19 |
| 2971 | 2971 | * @param string $value discount code. |
| 2972 | 2972 | */ |
| 2973 | - public function set_discount_code( $value ) { |
|
| 2974 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
| 2973 | + public function set_discount_code($value) { |
|
| 2974 | + $this->set_prop('discount_code', sanitize_text_field($value)); |
|
| 2975 | 2975 | } |
| 2976 | 2976 | |
| 2977 | 2977 | /** |
@@ -2980,8 +2980,8 @@ discard block |
||
| 2980 | 2980 | * @since 1.0.19 |
| 2981 | 2981 | * @param string $value gateway. |
| 2982 | 2982 | */ |
| 2983 | - public function set_gateway( $value ) { |
|
| 2984 | - $this->set_prop( 'gateway', $value ); |
|
| 2983 | + public function set_gateway($value) { |
|
| 2984 | + $this->set_prop('gateway', $value); |
|
| 2985 | 2985 | } |
| 2986 | 2986 | |
| 2987 | 2987 | /** |
@@ -2990,9 +2990,9 @@ discard block |
||
| 2990 | 2990 | * @since 1.0.19 |
| 2991 | 2991 | * @param string $value transaction id. |
| 2992 | 2992 | */ |
| 2993 | - public function set_transaction_id( $value ) { |
|
| 2994 | - if ( ! empty( $value ) ) { |
|
| 2995 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2993 | + public function set_transaction_id($value) { |
|
| 2994 | + if (!empty($value)) { |
|
| 2995 | + $this->set_prop('transaction_id', $value); |
|
| 2996 | 2996 | } |
| 2997 | 2997 | } |
| 2998 | 2998 | |
@@ -3002,8 +3002,8 @@ discard block |
||
| 3002 | 3002 | * @since 1.0.19 |
| 3003 | 3003 | * @param string $value currency id. |
| 3004 | 3004 | */ |
| 3005 | - public function set_currency( $value ) { |
|
| 3006 | - $this->set_prop( 'currency', $value ); |
|
| 3005 | + public function set_currency($value) { |
|
| 3006 | + $this->set_prop('currency', $value); |
|
| 3007 | 3007 | } |
| 3008 | 3008 | |
| 3009 | 3009 | /** |
@@ -3012,8 +3012,8 @@ discard block |
||
| 3012 | 3012 | * @since 1.0.19 |
| 3013 | 3013 | * @param bool $value value. |
| 3014 | 3014 | */ |
| 3015 | - public function set_disable_taxes( $value ) { |
|
| 3016 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 3015 | + public function set_disable_taxes($value) { |
|
| 3016 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 3017 | 3017 | } |
| 3018 | 3018 | |
| 3019 | 3019 | /** |
@@ -3022,8 +3022,8 @@ discard block |
||
| 3022 | 3022 | * @since 1.0.19 |
| 3023 | 3023 | * @param string $value subscription id. |
| 3024 | 3024 | */ |
| 3025 | - public function set_subscription_id( $value ) { |
|
| 3026 | - $this->set_prop( 'subscription_id', $value ); |
|
| 3025 | + public function set_subscription_id($value) { |
|
| 3026 | + $this->set_prop('subscription_id', $value); |
|
| 3027 | 3027 | } |
| 3028 | 3028 | |
| 3029 | 3029 | /** |
@@ -3032,8 +3032,8 @@ discard block |
||
| 3032 | 3032 | * @since 1.0.19 |
| 3033 | 3033 | * @param string $value subscription id. |
| 3034 | 3034 | */ |
| 3035 | - public function set_remote_subscription_id( $value ) { |
|
| 3036 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 3035 | + public function set_remote_subscription_id($value) { |
|
| 3036 | + $this->set_prop('remote_subscription_id', $value); |
|
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | 3039 | /* |
@@ -3050,28 +3050,28 @@ discard block |
||
| 3050 | 3050 | */ |
| 3051 | 3051 | public function is_parent() { |
| 3052 | 3052 | $parent = $this->get_parent_id(); |
| 3053 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 3053 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 3054 | 3054 | } |
| 3055 | 3055 | |
| 3056 | 3056 | /** |
| 3057 | 3057 | * Checks if this is a renewal invoice. |
| 3058 | 3058 | */ |
| 3059 | 3059 | public function is_renewal() { |
| 3060 | - return $this->is_recurring() && ! $this->is_parent(); |
|
| 3060 | + return $this->is_recurring() && !$this->is_parent(); |
|
| 3061 | 3061 | } |
| 3062 | 3062 | |
| 3063 | 3063 | /** |
| 3064 | 3064 | * Checks if this is a recurring invoice. |
| 3065 | 3065 | */ |
| 3066 | 3066 | public function is_recurring() { |
| 3067 | - return ! empty( $this->recurring_item ); |
|
| 3067 | + return !empty($this->recurring_item); |
|
| 3068 | 3068 | } |
| 3069 | 3069 | |
| 3070 | 3070 | /** |
| 3071 | 3071 | * Checks if this is a taxable invoice. |
| 3072 | 3072 | */ |
| 3073 | 3073 | public function is_taxable() { |
| 3074 | - return ! $this->get_disable_taxes(); |
|
| 3074 | + return !$this->get_disable_taxes(); |
|
| 3075 | 3075 | } |
| 3076 | 3076 | |
| 3077 | 3077 | /** |
@@ -3085,45 +3085,45 @@ discard block |
||
| 3085 | 3085 | * Checks to see if the invoice requires payment. |
| 3086 | 3086 | */ |
| 3087 | 3087 | public function is_free() { |
| 3088 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 3088 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 3089 | 3089 | |
| 3090 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 3090 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 3091 | 3091 | $is_free = false; |
| 3092 | 3092 | } |
| 3093 | 3093 | |
| 3094 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 3094 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 3095 | 3095 | } |
| 3096 | 3096 | |
| 3097 | 3097 | /** |
| 3098 | 3098 | * Checks if the invoice is paid. |
| 3099 | 3099 | */ |
| 3100 | 3100 | public function is_paid() { |
| 3101 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 3102 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 3101 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 3102 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 3103 | 3103 | } |
| 3104 | 3104 | |
| 3105 | 3105 | /** |
| 3106 | 3106 | * Checks if the invoice needs payment. |
| 3107 | 3107 | */ |
| 3108 | 3108 | public function needs_payment() { |
| 3109 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3110 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 3109 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 3110 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 3111 | 3111 | } |
| 3112 | 3112 | |
| 3113 | 3113 | /** |
| 3114 | 3114 | * Checks if the invoice is refunded. |
| 3115 | 3115 | */ |
| 3116 | 3116 | public function is_refunded() { |
| 3117 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 3118 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 3117 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 3118 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 3119 | 3119 | } |
| 3120 | 3120 | |
| 3121 | 3121 | /** |
| 3122 | 3122 | * Checks if the invoice is held. |
| 3123 | 3123 | */ |
| 3124 | 3124 | public function is_held() { |
| 3125 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
| 3126 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
| 3125 | + $is_held = $this->has_status('wpi-onhold'); |
|
| 3126 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
| 3127 | 3127 | } |
| 3128 | 3128 | |
| 3129 | 3129 | /** |
@@ -3131,30 +3131,30 @@ discard block |
||
| 3131 | 3131 | */ |
| 3132 | 3132 | public function is_due() { |
| 3133 | 3133 | $due_date = $this->get_due_date(); |
| 3134 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3134 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 3135 | 3135 | } |
| 3136 | 3136 | |
| 3137 | 3137 | /** |
| 3138 | 3138 | * Checks if the invoice is draft. |
| 3139 | 3139 | */ |
| 3140 | 3140 | public function is_draft() { |
| 3141 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 3141 | + return $this->has_status('draft, auto-draft'); |
|
| 3142 | 3142 | } |
| 3143 | 3143 | |
| 3144 | 3144 | /** |
| 3145 | 3145 | * Checks if the invoice has a given status. |
| 3146 | 3146 | */ |
| 3147 | - public function has_status( $status ) { |
|
| 3148 | - $status = wpinv_parse_list( $status ); |
|
| 3149 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 3147 | + public function has_status($status) { |
|
| 3148 | + $status = wpinv_parse_list($status); |
|
| 3149 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 3150 | 3150 | } |
| 3151 | 3151 | |
| 3152 | 3152 | /** |
| 3153 | 3153 | * Checks if the invoice is of a given type. |
| 3154 | 3154 | */ |
| 3155 | - public function is_type( $type ) { |
|
| 3156 | - $type = wpinv_parse_list( $type ); |
|
| 3157 | - return in_array( $this->get_type(), $type ); |
|
| 3155 | + public function is_type($type) { |
|
| 3156 | + $type = wpinv_parse_list($type); |
|
| 3157 | + return in_array($this->get_type(), $type); |
|
| 3158 | 3158 | } |
| 3159 | 3159 | |
| 3160 | 3160 | /** |
@@ -3186,8 +3186,8 @@ discard block |
||
| 3186 | 3186 | * |
| 3187 | 3187 | */ |
| 3188 | 3188 | public function is_initial_free() { |
| 3189 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3190 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3189 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3190 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3191 | 3191 | } |
| 3192 | 3192 | |
| 3193 | 3193 | /** |
@@ -3197,11 +3197,11 @@ discard block |
||
| 3197 | 3197 | public function item_has_free_trial() { |
| 3198 | 3198 | |
| 3199 | 3199 | // Ensure we have a recurring item. |
| 3200 | - if ( ! $this->is_recurring() ) { |
|
| 3200 | + if (!$this->is_recurring()) { |
|
| 3201 | 3201 | return false; |
| 3202 | 3202 | } |
| 3203 | 3203 | |
| 3204 | - $item = $this->get_recurring( true ); |
|
| 3204 | + $item = $this->get_recurring(true); |
|
| 3205 | 3205 | return $item->has_free_trial(); |
| 3206 | 3206 | } |
| 3207 | 3207 | |
@@ -3209,7 +3209,7 @@ discard block |
||
| 3209 | 3209 | * Check if the free trial is a result of a discount. |
| 3210 | 3210 | */ |
| 3211 | 3211 | public function is_free_trial_from_discount() { |
| 3212 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3212 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3213 | 3213 | } |
| 3214 | 3214 | |
| 3215 | 3215 | /** |
@@ -3217,12 +3217,12 @@ discard block |
||
| 3217 | 3217 | */ |
| 3218 | 3218 | public function discount_first_payment_only() { |
| 3219 | 3219 | |
| 3220 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3221 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
| 3220 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
| 3221 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
| 3222 | 3222 | return true; |
| 3223 | 3223 | } |
| 3224 | 3224 | |
| 3225 | - return ! $discount->get_is_recurring(); |
|
| 3225 | + return !$discount->get_is_recurring(); |
|
| 3226 | 3226 | } |
| 3227 | 3227 | |
| 3228 | 3228 | /* |
@@ -3240,23 +3240,23 @@ discard block |
||
| 3240 | 3240 | * @param GetPaid_Form_Item|array $item |
| 3241 | 3241 | * @return WP_Error|Bool |
| 3242 | 3242 | */ |
| 3243 | - public function add_item( $item ) { |
|
| 3243 | + public function add_item($item) { |
|
| 3244 | 3244 | |
| 3245 | - if ( is_array( $item ) ) { |
|
| 3246 | - $item = $this->process_array_item( $item ); |
|
| 3245 | + if (is_array($item)) { |
|
| 3246 | + $item = $this->process_array_item($item); |
|
| 3247 | 3247 | } |
| 3248 | 3248 | |
| 3249 | - if ( is_numeric( $item ) ) { |
|
| 3250 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3249 | + if (is_numeric($item)) { |
|
| 3250 | + $item = new GetPaid_Form_Item($item); |
|
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | 3253 | // Make sure that it is available for purchase. |
| 3254 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3255 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3254 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3255 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | // Do we have a recurring item? |
| 3259 | - if ( $item->is_recurring() ) { |
|
| 3259 | + if ($item->is_recurring()) { |
|
| 3260 | 3260 | $this->recurring_item = $item->get_id(); |
| 3261 | 3261 | } |
| 3262 | 3262 | |
@@ -3264,7 +3264,7 @@ discard block |
||
| 3264 | 3264 | $item->invoice_id = (int) $this->get_id(); |
| 3265 | 3265 | |
| 3266 | 3266 | // Remove duplicates. |
| 3267 | - $this->remove_item( $item->get_id() ); |
|
| 3267 | + $this->remove_item($item->get_id()); |
|
| 3268 | 3268 | |
| 3269 | 3269 | // Retrieve all items. |
| 3270 | 3270 | $items = $this->get_items(); |
@@ -3272,7 +3272,7 @@ discard block |
||
| 3272 | 3272 | // Add new item. |
| 3273 | 3273 | $items[] = $item; |
| 3274 | 3274 | |
| 3275 | - $this->set_prop( 'items', $items ); |
|
| 3275 | + $this->set_prop('items', $items); |
|
| 3276 | 3276 | |
| 3277 | 3277 | return true; |
| 3278 | 3278 | } |
@@ -3283,26 +3283,26 @@ discard block |
||
| 3283 | 3283 | * @since 1.0.19 |
| 3284 | 3284 | * @return GetPaid_Form_Item |
| 3285 | 3285 | */ |
| 3286 | - protected function process_array_item( $array ) { |
|
| 3286 | + protected function process_array_item($array) { |
|
| 3287 | 3287 | |
| 3288 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3289 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3288 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
| 3289 | + $item = new GetPaid_Form_Item($item_id); |
|
| 3290 | 3290 | |
| 3291 | 3291 | // Set item data. |
| 3292 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3293 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3292 | + foreach (array('name', 'price', 'description') as $key) { |
|
| 3293 | + if (isset($array["item_$key"])) { |
|
| 3294 | 3294 | $method = "set_$key"; |
| 3295 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3295 | + $item->$method($array["item_$key"]); |
|
| 3296 | 3296 | } |
| 3297 | 3297 | } |
| 3298 | 3298 | |
| 3299 | - if ( isset( $array['quantity'] ) ) { |
|
| 3300 | - $item->set_quantity( $array['quantity'] ); |
|
| 3299 | + if (isset($array['quantity'])) { |
|
| 3300 | + $item->set_quantity($array['quantity']); |
|
| 3301 | 3301 | } |
| 3302 | 3302 | |
| 3303 | 3303 | // Set item meta. |
| 3304 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3305 | - $item->set_item_meta( $array['meta'] ); |
|
| 3304 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
| 3305 | + $item->set_item_meta($array['meta']); |
|
| 3306 | 3306 | } |
| 3307 | 3307 | |
| 3308 | 3308 | return $item; |
@@ -3315,10 +3315,10 @@ discard block |
||
| 3315 | 3315 | * @since 1.0.19 |
| 3316 | 3316 | * @return GetPaid_Form_Item|null |
| 3317 | 3317 | */ |
| 3318 | - public function get_item( $item_id ) { |
|
| 3318 | + public function get_item($item_id) { |
|
| 3319 | 3319 | |
| 3320 | - foreach ( $this->get_items() as $item ) { |
|
| 3321 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3320 | + foreach ($this->get_items() as $item) { |
|
| 3321 | + if ((int) $item_id == $item->get_id()) { |
|
| 3322 | 3322 | return $item; |
| 3323 | 3323 | } |
| 3324 | 3324 | } |
@@ -3331,16 +3331,16 @@ discard block |
||
| 3331 | 3331 | * |
| 3332 | 3332 | * @since 1.0.19 |
| 3333 | 3333 | */ |
| 3334 | - public function remove_item( $item_id ) { |
|
| 3334 | + public function remove_item($item_id) { |
|
| 3335 | 3335 | $items = $this->get_items(); |
| 3336 | 3336 | $item_id = (int) $item_id; |
| 3337 | 3337 | |
| 3338 | - foreach ( $items as $index => $item ) { |
|
| 3339 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3340 | - unset( $items[ $index ] ); |
|
| 3341 | - $this->set_prop( 'items', $items ); |
|
| 3338 | + foreach ($items as $index => $item) { |
|
| 3339 | + if ((int) $item_id == $item->get_id()) { |
|
| 3340 | + unset($items[$index]); |
|
| 3341 | + $this->set_prop('items', $items); |
|
| 3342 | 3342 | |
| 3343 | - if ( $item_id == $this->recurring_item ) { |
|
| 3343 | + if ($item_id == $this->recurring_item) { |
|
| 3344 | 3344 | $this->recurring_item = null; |
| 3345 | 3345 | } |
| 3346 | 3346 | |
@@ -3355,11 +3355,11 @@ discard block |
||
| 3355 | 3355 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
| 3356 | 3356 | * @since 1.0.19 |
| 3357 | 3357 | */ |
| 3358 | - public function add_fee( $fee ) { |
|
| 3358 | + public function add_fee($fee) { |
|
| 3359 | 3359 | |
| 3360 | 3360 | $fees = $this->get_fees(); |
| 3361 | - $fees[ $fee['name'] ] = $fee; |
|
| 3362 | - $this->set_prop( 'fees', $fees ); |
|
| 3361 | + $fees[$fee['name']] = $fee; |
|
| 3362 | + $this->set_prop('fees', $fees); |
|
| 3363 | 3363 | |
| 3364 | 3364 | } |
| 3365 | 3365 | |
@@ -3368,9 +3368,9 @@ discard block |
||
| 3368 | 3368 | * |
| 3369 | 3369 | * @since 1.0.19 |
| 3370 | 3370 | */ |
| 3371 | - public function get_fee( $fee ) { |
|
| 3371 | + public function get_fee($fee) { |
|
| 3372 | 3372 | $fees = $this->get_fees(); |
| 3373 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3373 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3374 | 3374 | } |
| 3375 | 3375 | |
| 3376 | 3376 | /** |
@@ -3378,11 +3378,11 @@ discard block |
||
| 3378 | 3378 | * |
| 3379 | 3379 | * @since 1.0.19 |
| 3380 | 3380 | */ |
| 3381 | - public function remove_fee( $fee ) { |
|
| 3381 | + public function remove_fee($fee) { |
|
| 3382 | 3382 | $fees = $this->get_fees(); |
| 3383 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3384 | - unset( $fees[ $fee ] ); |
|
| 3385 | - $this->set_prop( 'fees', $fees ); |
|
| 3383 | + if (isset($fees[$fee])) { |
|
| 3384 | + unset($fees[$fee]); |
|
| 3385 | + $this->set_prop('fees', $fees); |
|
| 3386 | 3386 | } |
| 3387 | 3387 | } |
| 3388 | 3388 | |
@@ -3392,11 +3392,11 @@ discard block |
||
| 3392 | 3392 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
| 3393 | 3393 | * @since 1.0.19 |
| 3394 | 3394 | */ |
| 3395 | - public function add_discount( $discount ) { |
|
| 3395 | + public function add_discount($discount) { |
|
| 3396 | 3396 | |
| 3397 | 3397 | $discounts = $this->get_discounts(); |
| 3398 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3399 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3398 | + $discounts[$discount['name']] = $discount; |
|
| 3399 | + $this->set_prop('discounts', $discounts); |
|
| 3400 | 3400 | |
| 3401 | 3401 | } |
| 3402 | 3402 | |
@@ -3406,15 +3406,15 @@ discard block |
||
| 3406 | 3406 | * @since 1.0.19 |
| 3407 | 3407 | * @return float |
| 3408 | 3408 | */ |
| 3409 | - public function get_discount( $discount = false ) { |
|
| 3409 | + public function get_discount($discount = false) { |
|
| 3410 | 3410 | |
| 3411 | 3411 | // Backwards compatibilty. |
| 3412 | - if ( empty( $discount ) ) { |
|
| 3412 | + if (empty($discount)) { |
|
| 3413 | 3413 | return $this->get_total_discount(); |
| 3414 | 3414 | } |
| 3415 | 3415 | |
| 3416 | 3416 | $discounts = $this->get_discounts(); |
| 3417 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3417 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3418 | 3418 | } |
| 3419 | 3419 | |
| 3420 | 3420 | /** |
@@ -3422,15 +3422,15 @@ discard block |
||
| 3422 | 3422 | * |
| 3423 | 3423 | * @since 1.0.19 |
| 3424 | 3424 | */ |
| 3425 | - public function remove_discount( $discount ) { |
|
| 3425 | + public function remove_discount($discount) { |
|
| 3426 | 3426 | $discounts = $this->get_discounts(); |
| 3427 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3428 | - unset( $discounts[ $discount ] ); |
|
| 3429 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3427 | + if (isset($discounts[$discount])) { |
|
| 3428 | + unset($discounts[$discount]); |
|
| 3429 | + $this->set_prop('discounts', $discounts); |
|
| 3430 | 3430 | } |
| 3431 | 3431 | |
| 3432 | - if ( 'discount_code' == $discount ) { |
|
| 3433 | - foreach ( $this->get_items() as $item ) { |
|
| 3432 | + if ('discount_code' == $discount) { |
|
| 3433 | + foreach ($this->get_items() as $item) { |
|
| 3434 | 3434 | $item->item_discount = 0; |
| 3435 | 3435 | $item->recurring_item_discount = 0; |
| 3436 | 3436 | } |
@@ -3443,12 +3443,12 @@ discard block |
||
| 3443 | 3443 | * |
| 3444 | 3444 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
| 3445 | 3445 | */ |
| 3446 | - public function add_tax( $tax ) { |
|
| 3447 | - if ( $this->is_taxable() ) { |
|
| 3446 | + public function add_tax($tax) { |
|
| 3447 | + if ($this->is_taxable()) { |
|
| 3448 | 3448 | |
| 3449 | - $taxes = $this->get_taxes(); |
|
| 3450 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3451 | - $this->set_prop( 'taxes', $tax ); |
|
| 3449 | + $taxes = $this->get_taxes(); |
|
| 3450 | + $taxes[$tax['name']] = $tax; |
|
| 3451 | + $this->set_prop('taxes', $tax); |
|
| 3452 | 3452 | |
| 3453 | 3453 | } |
| 3454 | 3454 | } |
@@ -3458,15 +3458,15 @@ discard block |
||
| 3458 | 3458 | * |
| 3459 | 3459 | * @since 1.0.19 |
| 3460 | 3460 | */ |
| 3461 | - public function get_tax( $tax = null ) { |
|
| 3461 | + public function get_tax($tax = null) { |
|
| 3462 | 3462 | |
| 3463 | 3463 | // Backwards compatility. |
| 3464 | - if ( empty( $tax ) ) { |
|
| 3464 | + if (empty($tax)) { |
|
| 3465 | 3465 | return $this->get_total_tax(); |
| 3466 | 3466 | } |
| 3467 | 3467 | |
| 3468 | 3468 | $taxes = $this->get_taxes(); |
| 3469 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3469 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3470 | 3470 | } |
| 3471 | 3471 | |
| 3472 | 3472 | /** |
@@ -3474,11 +3474,11 @@ discard block |
||
| 3474 | 3474 | * |
| 3475 | 3475 | * @since 1.0.19 |
| 3476 | 3476 | */ |
| 3477 | - public function remove_tax( $tax ) { |
|
| 3477 | + public function remove_tax($tax) { |
|
| 3478 | 3478 | $taxes = $this->get_taxes(); |
| 3479 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3480 | - unset( $taxes[ $tax ] ); |
|
| 3481 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3479 | + if (isset($taxes[$tax])) { |
|
| 3480 | + unset($taxes[$tax]); |
|
| 3481 | + $this->set_prop('taxes', $taxes); |
|
| 3482 | 3482 | } |
| 3483 | 3483 | } |
| 3484 | 3484 | |
@@ -3489,22 +3489,22 @@ discard block |
||
| 3489 | 3489 | * @return float The recalculated subtotal |
| 3490 | 3490 | */ |
| 3491 | 3491 | public function recalculate_subtotal() { |
| 3492 | - $items = $this->get_items(); |
|
| 3492 | + $items = $this->get_items(); |
|
| 3493 | 3493 | $subtotal = 0; |
| 3494 | 3494 | $recurring = 0; |
| 3495 | 3495 | |
| 3496 | - foreach ( $items as $item ) { |
|
| 3496 | + foreach ($items as $item) { |
|
| 3497 | 3497 | $subtotal += $item->get_sub_total(); |
| 3498 | 3498 | $recurring += $item->get_recurring_sub_total(); |
| 3499 | 3499 | } |
| 3500 | 3500 | |
| 3501 | - if ( wpinv_prices_include_tax() ) { |
|
| 3502 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
| 3503 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
| 3501 | + if (wpinv_prices_include_tax()) { |
|
| 3502 | + $subtotal = max(0, $subtotal - $this->totals['tax']['initial']); |
|
| 3503 | + $recurring = max(0, $recurring - $this->totals['tax']['recurring']); |
|
| 3504 | 3504 | } |
| 3505 | 3505 | |
| 3506 | 3506 | $current = $this->is_renewal() ? $recurring : $subtotal; |
| 3507 | - $this->set_subtotal( $current ); |
|
| 3507 | + $this->set_subtotal($current); |
|
| 3508 | 3508 | |
| 3509 | 3509 | $this->totals['subtotal'] = array( |
| 3510 | 3510 | 'initial' => $subtotal, |
@@ -3525,14 +3525,14 @@ discard block |
||
| 3525 | 3525 | $discount = 0; |
| 3526 | 3526 | $recurring = 0; |
| 3527 | 3527 | |
| 3528 | - foreach ( $discounts as $data ) { |
|
| 3529 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3530 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3528 | + foreach ($discounts as $data) { |
|
| 3529 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
| 3530 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
| 3531 | 3531 | } |
| 3532 | 3532 | |
| 3533 | 3533 | $current = $this->is_renewal() ? $recurring : $discount; |
| 3534 | 3534 | |
| 3535 | - $this->set_total_discount( $current ); |
|
| 3535 | + $this->set_total_discount($current); |
|
| 3536 | 3536 | |
| 3537 | 3537 | $this->totals['discount'] = array( |
| 3538 | 3538 | 'initial' => $discount, |
@@ -3553,13 +3553,13 @@ discard block |
||
| 3553 | 3553 | |
| 3554 | 3554 | // Maybe disable taxes. |
| 3555 | 3555 | $vat_number = $this->get_vat_number(); |
| 3556 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
| 3556 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number); |
|
| 3557 | 3557 | |
| 3558 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 3558 | + if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
| 3559 | 3559 | $skip_tax = false; |
| 3560 | 3560 | } |
| 3561 | 3561 | |
| 3562 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
| 3562 | + if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) { |
|
| 3563 | 3563 | |
| 3564 | 3564 | $this->totals['tax'] = array( |
| 3565 | 3565 | 'initial' => 0, |
@@ -3568,38 +3568,38 @@ discard block |
||
| 3568 | 3568 | |
| 3569 | 3569 | $this->tax_rate = 0; |
| 3570 | 3570 | |
| 3571 | - $this->set_taxes( array() ); |
|
| 3571 | + $this->set_taxes(array()); |
|
| 3572 | 3572 | $current = 0; |
| 3573 | 3573 | } else { |
| 3574 | 3574 | |
| 3575 | 3575 | $item_taxes = array(); |
| 3576 | 3576 | |
| 3577 | - foreach ( $this->get_items() as $item ) { |
|
| 3578 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
| 3579 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 3580 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 3581 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 3582 | - foreach ( $taxes as $name => $amount ) { |
|
| 3583 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 3584 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 3585 | - |
|
| 3586 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
| 3587 | - $item_taxes[ $name ] = $tax; |
|
| 3577 | + foreach ($this->get_items() as $item) { |
|
| 3578 | + $rates = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state()); |
|
| 3579 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
| 3580 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
| 3581 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
| 3582 | + foreach ($taxes as $name => $amount) { |
|
| 3583 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
| 3584 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
| 3585 | + |
|
| 3586 | + if (!isset($item_taxes[$name])) { |
|
| 3587 | + $item_taxes[$name] = $tax; |
|
| 3588 | 3588 | continue; |
| 3589 | 3589 | } |
| 3590 | 3590 | |
| 3591 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 3592 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3591 | + $item_taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
| 3592 | + $item_taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3593 | 3593 | |
| 3594 | 3594 | } |
| 3595 | 3595 | |
| 3596 | 3596 | } |
| 3597 | 3597 | |
| 3598 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
| 3599 | - $this->set_taxes( $item_taxes ); |
|
| 3598 | + $item_taxes = array_replace($this->get_taxes(), $item_taxes); |
|
| 3599 | + $this->set_taxes($item_taxes); |
|
| 3600 | 3600 | |
| 3601 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
| 3602 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
| 3601 | + $initial_tax = array_sum(wp_list_pluck($item_taxes, 'initial_tax')); |
|
| 3602 | + $recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax')); |
|
| 3603 | 3603 | |
| 3604 | 3604 | $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
| 3605 | 3605 | |
@@ -3610,7 +3610,7 @@ discard block |
||
| 3610 | 3610 | |
| 3611 | 3611 | } |
| 3612 | 3612 | |
| 3613 | - $this->set_total_tax( $current ); |
|
| 3613 | + $this->set_total_tax($current); |
|
| 3614 | 3614 | |
| 3615 | 3615 | return $current; |
| 3616 | 3616 | |
@@ -3627,20 +3627,20 @@ discard block |
||
| 3627 | 3627 | $fee = 0; |
| 3628 | 3628 | $recurring = 0; |
| 3629 | 3629 | |
| 3630 | - foreach ( $fees as $data ) { |
|
| 3631 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3632 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3630 | + foreach ($fees as $data) { |
|
| 3631 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
| 3632 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
| 3633 | 3633 | } |
| 3634 | 3634 | |
| 3635 | 3635 | $current = $this->is_renewal() ? $recurring : $fee; |
| 3636 | - $this->set_total_fees( $current ); |
|
| 3636 | + $this->set_total_fees($current); |
|
| 3637 | 3637 | |
| 3638 | 3638 | $this->totals['fee'] = array( |
| 3639 | 3639 | 'initial' => $fee, |
| 3640 | 3640 | 'recurring' => $recurring, |
| 3641 | 3641 | ); |
| 3642 | 3642 | |
| 3643 | - $this->set_total_fees( $fee ); |
|
| 3643 | + $this->set_total_fees($fee); |
|
| 3644 | 3644 | return $current; |
| 3645 | 3645 | } |
| 3646 | 3646 | |
@@ -3655,7 +3655,7 @@ discard block |
||
| 3655 | 3655 | $this->recalculate_total_discount(); |
| 3656 | 3656 | $this->recalculate_total_tax(); |
| 3657 | 3657 | $this->recalculate_subtotal(); |
| 3658 | - $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
| 3658 | + $this->set_total($this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount()); |
|
| 3659 | 3659 | return $this->get_total(); |
| 3660 | 3660 | } |
| 3661 | 3661 | |
@@ -3664,7 +3664,7 @@ discard block |
||
| 3664 | 3664 | */ |
| 3665 | 3665 | public function recalculate_totals() { |
| 3666 | 3666 | $this->recalculate_total(); |
| 3667 | - $this->save( true ); |
|
| 3667 | + $this->save(true); |
|
| 3668 | 3668 | return $this; |
| 3669 | 3669 | } |
| 3670 | 3670 | |
@@ -3682,8 +3682,8 @@ discard block |
||
| 3682 | 3682 | * @return int|false The new note's ID on success, false on failure. |
| 3683 | 3683 | * |
| 3684 | 3684 | */ |
| 3685 | - public function add_system_note( $note ) { |
|
| 3686 | - return $this->add_note( $note, false, false, true ); |
|
| 3685 | + public function add_system_note($note) { |
|
| 3686 | + return $this->add_note($note, false, false, true); |
|
| 3687 | 3687 | } |
| 3688 | 3688 | |
| 3689 | 3689 | /** |
@@ -3693,10 +3693,10 @@ discard block |
||
| 3693 | 3693 | * @return int|false The new note's ID on success, false on failure. |
| 3694 | 3694 | * |
| 3695 | 3695 | */ |
| 3696 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3696 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3697 | 3697 | |
| 3698 | 3698 | // Bail if no note specified or this invoice is not yet saved. |
| 3699 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
| 3699 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
| 3700 | 3700 | return false; |
| 3701 | 3701 | } |
| 3702 | 3702 | |
@@ -3704,23 +3704,23 @@ discard block |
||
| 3704 | 3704 | $author_email = '[email protected]'; |
| 3705 | 3705 | |
| 3706 | 3706 | // If this is an admin comment or it has been added by the user. |
| 3707 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3708 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3707 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
| 3708 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3709 | 3709 | $author = $user->display_name; |
| 3710 | 3710 | $author_email = $user->user_email; |
| 3711 | 3711 | } |
| 3712 | 3712 | |
| 3713 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3713 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
| 3714 | 3714 | |
| 3715 | 3715 | } |
| 3716 | 3716 | |
| 3717 | 3717 | /** |
| 3718 | 3718 | * Generates a unique key for the invoice. |
| 3719 | 3719 | */ |
| 3720 | - public function generate_key( $string = '' ) { |
|
| 3721 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3720 | + public function generate_key($string = '') { |
|
| 3721 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3722 | 3722 | return strtolower( |
| 3723 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3723 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3724 | 3724 | ); |
| 3725 | 3725 | } |
| 3726 | 3726 | |
@@ -3730,11 +3730,11 @@ discard block |
||
| 3730 | 3730 | public function generate_number() { |
| 3731 | 3731 | $number = $this->get_id(); |
| 3732 | 3732 | |
| 3733 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
| 3734 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
| 3733 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
| 3734 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
| 3735 | 3735 | } |
| 3736 | 3736 | |
| 3737 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3737 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
| 3738 | 3738 | |
| 3739 | 3739 | } |
| 3740 | 3740 | |
@@ -3747,55 +3747,55 @@ discard block |
||
| 3747 | 3747 | // Reset status transition variable. |
| 3748 | 3748 | $this->status_transition = false; |
| 3749 | 3749 | |
| 3750 | - if ( $status_transition ) { |
|
| 3750 | + if ($status_transition) { |
|
| 3751 | 3751 | try { |
| 3752 | 3752 | |
| 3753 | 3753 | // Fire a hook for the status change. |
| 3754 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3754 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
| 3755 | 3755 | |
| 3756 | 3756 | // @deprecated this is deprecated and will be removed in the future. |
| 3757 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3757 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3758 | 3758 | |
| 3759 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3759 | + if (!empty($status_transition['from'])) { |
|
| 3760 | 3760 | |
| 3761 | 3761 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3762 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3762 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3763 | 3763 | |
| 3764 | 3764 | // Fire another hook. |
| 3765 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3766 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3765 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
| 3766 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
| 3767 | 3767 | |
| 3768 | 3768 | // @deprecated this is deprecated and will be removed in the future. |
| 3769 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3769 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3770 | 3770 | |
| 3771 | 3771 | // Note the transition occurred. |
| 3772 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3772 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
| 3773 | 3773 | |
| 3774 | 3774 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3775 | 3775 | if ( |
| 3776 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3777 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3776 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3777 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3778 | 3778 | ) { |
| 3779 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3779 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
| 3780 | 3780 | } |
| 3781 | 3781 | |
| 3782 | 3782 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
| 3783 | 3783 | if ( |
| 3784 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3785 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3784 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3785 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3786 | 3786 | ) { |
| 3787 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3787 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
| 3788 | 3788 | } |
| 3789 | 3789 | } else { |
| 3790 | 3790 | /* translators: %s: new invoice status */ |
| 3791 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3791 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3792 | 3792 | |
| 3793 | 3793 | // Note the transition occurred. |
| 3794 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3794 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3795 | 3795 | |
| 3796 | 3796 | } |
| 3797 | - } catch ( Exception $e ) { |
|
| 3798 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3797 | + } catch (Exception $e) { |
|
| 3798 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3799 | 3799 | } |
| 3800 | 3800 | } |
| 3801 | 3801 | } |
@@ -3803,13 +3803,13 @@ discard block |
||
| 3803 | 3803 | /** |
| 3804 | 3804 | * Updates an invoice status. |
| 3805 | 3805 | */ |
| 3806 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3806 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3807 | 3807 | |
| 3808 | 3808 | // Fires before updating a status. |
| 3809 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3809 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3810 | 3810 | |
| 3811 | 3811 | // Update the status. |
| 3812 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3812 | + $this->set_status($new_status, $note, $manual); |
|
| 3813 | 3813 | |
| 3814 | 3814 | // Save the order. |
| 3815 | 3815 | return $this->save(); |
@@ -3820,18 +3820,18 @@ discard block |
||
| 3820 | 3820 | * @deprecated |
| 3821 | 3821 | */ |
| 3822 | 3822 | public function refresh_item_ids() { |
| 3823 | - $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
|
| 3824 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3823 | + $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id'))); |
|
| 3824 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3825 | 3825 | } |
| 3826 | 3826 | |
| 3827 | 3827 | /** |
| 3828 | 3828 | * @deprecated |
| 3829 | 3829 | */ |
| 3830 | - public function update_items( $temp = false ) { |
|
| 3830 | + public function update_items($temp = false) { |
|
| 3831 | 3831 | |
| 3832 | - $this->set_items( $this->get_items() ); |
|
| 3832 | + $this->set_items($this->get_items()); |
|
| 3833 | 3833 | |
| 3834 | - if ( ! $temp ) { |
|
| 3834 | + if (!$temp) { |
|
| 3835 | 3835 | $this->save(); |
| 3836 | 3836 | } |
| 3837 | 3837 | |
@@ -3845,11 +3845,11 @@ discard block |
||
| 3845 | 3845 | |
| 3846 | 3846 | $discount_code = $this->get_discount_code(); |
| 3847 | 3847 | |
| 3848 | - if ( empty( $discount_code ) ) { |
|
| 3848 | + if (empty($discount_code)) { |
|
| 3849 | 3849 | return false; |
| 3850 | 3850 | } |
| 3851 | 3851 | |
| 3852 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3852 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3853 | 3853 | |
| 3854 | 3854 | // Ensure it is active. |
| 3855 | 3855 | return $discount->exists(); |
@@ -3860,7 +3860,7 @@ discard block |
||
| 3860 | 3860 | * Refunds an invoice. |
| 3861 | 3861 | */ |
| 3862 | 3862 | public function refund() { |
| 3863 | - $this->set_status( 'wpi-refunded' ); |
|
| 3863 | + $this->set_status('wpi-refunded'); |
|
| 3864 | 3864 | $this->save(); |
| 3865 | 3865 | } |
| 3866 | 3866 | |
@@ -3869,53 +3869,53 @@ discard block |
||
| 3869 | 3869 | * |
| 3870 | 3870 | * @param string $transaction_id |
| 3871 | 3871 | */ |
| 3872 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3872 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3873 | 3873 | |
| 3874 | 3874 | // Set the transaction id. |
| 3875 | - if ( empty( $transaction_id ) ) { |
|
| 3875 | + if (empty($transaction_id)) { |
|
| 3876 | 3876 | $transaction_id = $this->generate_key('trans_'); |
| 3877 | 3877 | } |
| 3878 | 3878 | |
| 3879 | - if ( ! $this->get_transaction_id() ) { |
|
| 3880 | - $this->set_transaction_id( $transaction_id ); |
|
| 3879 | + if (!$this->get_transaction_id()) { |
|
| 3880 | + $this->set_transaction_id($transaction_id); |
|
| 3881 | 3881 | } |
| 3882 | 3882 | |
| 3883 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3883 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3884 | 3884 | return $this->save(); |
| 3885 | 3885 | } |
| 3886 | 3886 | |
| 3887 | 3887 | // Set the completed date. |
| 3888 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3888 | + $this->set_date_completed(current_time('mysql')); |
|
| 3889 | 3889 | |
| 3890 | 3890 | // Set the new status. |
| 3891 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
| 3892 | - if ( $this->is_renewal() || ! $this->is_parent() ) { |
|
| 3891 | + $gateway = sanitize_text_field($this->get_gateway_title()); |
|
| 3892 | + if ($this->is_renewal() || !$this->is_parent()) { |
|
| 3893 | 3893 | |
| 3894 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
| 3895 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3894 | + $_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway); |
|
| 3895 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
| 3896 | 3896 | |
| 3897 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3897 | + if ('none' == $this->get_gateway()) { |
|
| 3898 | 3898 | $_note = $note; |
| 3899 | 3899 | } |
| 3900 | 3900 | |
| 3901 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3901 | + $this->set_status('wpi-renewal', $_note); |
|
| 3902 | 3902 | |
| 3903 | 3903 | } else { |
| 3904 | 3904 | |
| 3905 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 3906 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3905 | + $_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway); |
|
| 3906 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
| 3907 | 3907 | |
| 3908 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3908 | + if ('none' == $this->get_gateway()) { |
|
| 3909 | 3909 | $_note = $note; |
| 3910 | 3910 | } |
| 3911 | 3911 | |
| 3912 | - $this->set_status( 'publish', $_note ); |
|
| 3912 | + $this->set_status('publish', $_note); |
|
| 3913 | 3913 | |
| 3914 | 3914 | } |
| 3915 | 3915 | |
| 3916 | 3916 | // Set checkout mode. |
| 3917 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3918 | - $this->set_mode( $mode ); |
|
| 3917 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3918 | + $this->set_mode($mode); |
|
| 3919 | 3919 | |
| 3920 | 3920 | // Save the invoice. |
| 3921 | 3921 | $this->save(); |
@@ -3940,9 +3940,9 @@ discard block |
||
| 3940 | 3940 | * Clears the subscription's cache. |
| 3941 | 3941 | */ |
| 3942 | 3942 | public function clear_cache() { |
| 3943 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3944 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3945 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3943 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
| 3944 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
| 3945 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
| 3946 | 3946 | } |
| 3947 | 3947 | |
| 3948 | 3948 | } |
@@ -9,41 +9,41 @@ discard block |
||
| 9 | 9 | * @version 1.0.19 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | 16 | array( |
| 17 | 17 | 'type' => 'heading', |
| 18 | - 'name' => __( 'Heading', 'invoicing' ), |
|
| 18 | + 'name' => __('Heading', 'invoicing'), |
|
| 19 | 19 | 'defaults' => array( |
| 20 | 20 | 'level' => 'h2', |
| 21 | - 'text' => __( 'Heading', 'invoicing' ), |
|
| 21 | + 'text' => __('Heading', 'invoicing'), |
|
| 22 | 22 | ) |
| 23 | 23 | ), |
| 24 | 24 | |
| 25 | 25 | array( |
| 26 | 26 | 'type' => 'paragraph', |
| 27 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
| 27 | + 'name' => __('Paragraph', 'invoicing'), |
|
| 28 | 28 | 'defaults' => array( |
| 29 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
| 29 | + 'text' => __('Paragraph text', 'invoicing'), |
|
| 30 | 30 | ) |
| 31 | 31 | ), |
| 32 | 32 | |
| 33 | 33 | array( |
| 34 | 34 | 'type' => 'alert', |
| 35 | - 'name' => __( 'Alert', 'invoicing' ), |
|
| 35 | + 'name' => __('Alert', 'invoicing'), |
|
| 36 | 36 | 'defaults' => array( |
| 37 | 37 | 'value' => '', |
| 38 | 38 | 'class' => 'alert-warning', |
| 39 | - 'text' => __( 'Alert', 'invoicing' ), |
|
| 39 | + 'text' => __('Alert', 'invoicing'), |
|
| 40 | 40 | 'dismissible' => false, |
| 41 | 41 | ) |
| 42 | 42 | ), |
| 43 | 43 | |
| 44 | 44 | array( |
| 45 | 45 | 'type' => 'separator', |
| 46 | - 'name' => __( 'Separator', 'invoicing' ), |
|
| 46 | + 'name' => __('Separator', 'invoicing'), |
|
| 47 | 47 | 'defaults' => array( |
| 48 | 48 | 'value' => '', |
| 49 | 49 | ), |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | array( |
| 53 | 53 | 'type' => 'text', |
| 54 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
| 54 | + 'name' => __('Text Input', 'invoicing'), |
|
| 55 | 55 | 'defaults' => array( |
| 56 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
| 56 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
| 57 | 57 | 'value' => '', |
| 58 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
| 58 | + 'label' => __('Field Label', 'invoicing'), |
|
| 59 | 59 | 'description' => '', |
| 60 | 60 | 'required' => false, |
| 61 | 61 | ) |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | array( |
| 65 | 65 | 'type' => 'textarea', |
| 66 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
| 66 | + 'name' => __('Textarea', 'invoicing'), |
|
| 67 | 67 | 'defaults' => array( |
| 68 | - 'placeholder' => __( 'Enter your text here', 'invoicing' ), |
|
| 68 | + 'placeholder' => __('Enter your text here', 'invoicing'), |
|
| 69 | 69 | 'value' => '', |
| 70 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
| 70 | + 'label' => __('Textarea Label', 'invoicing'), |
|
| 71 | 71 | 'description' => '', |
| 72 | 72 | 'required' => false, |
| 73 | 73 | ) |
@@ -75,27 +75,27 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | array( |
| 77 | 77 | 'type' => 'select', |
| 78 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
| 78 | + 'name' => __('Dropdown', 'invoicing'), |
|
| 79 | 79 | 'defaults' => array( |
| 80 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
| 80 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
| 81 | 81 | 'value' => '', |
| 82 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
| 82 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
| 83 | 83 | 'description' => '', |
| 84 | 84 | 'required' => false, |
| 85 | 85 | 'options' => array( |
| 86 | - esc_attr__( 'Option One', 'invoicing' ), |
|
| 87 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
| 88 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
| 86 | + esc_attr__('Option One', 'invoicing'), |
|
| 87 | + esc_attr__('Option Two', 'invoicing'), |
|
| 88 | + esc_attr__('Option Three', 'invoicing') |
|
| 89 | 89 | ), |
| 90 | 90 | ) |
| 91 | 91 | ), |
| 92 | 92 | |
| 93 | 93 | array( |
| 94 | 94 | 'type' => 'checkbox', |
| 95 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
| 95 | + 'name' => __('Checkbox', 'invoicing'), |
|
| 96 | 96 | 'defaults' => array( |
| 97 | 97 | 'value' => '', |
| 98 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
| 98 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
| 99 | 99 | 'description' => '', |
| 100 | 100 | 'required' => false, |
| 101 | 101 | ) |
@@ -103,23 +103,23 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | array( |
| 105 | 105 | 'type' => 'radio', |
| 106 | - 'name' => __( 'Radio', 'invoicing' ), |
|
| 106 | + 'name' => __('Radio', 'invoicing'), |
|
| 107 | 107 | 'defaults' => array( |
| 108 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
| 108 | + 'label' => __('Select one choice', 'invoicing'), |
|
| 109 | 109 | 'options' => array( |
| 110 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
| 111 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
| 112 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
| 110 | + esc_attr__('Choice One', 'invoicing'), |
|
| 111 | + esc_attr__('Choice Two', 'invoicing'), |
|
| 112 | + esc_attr__('Choice Three', 'invoicing') |
|
| 113 | 113 | ), |
| 114 | 114 | ) |
| 115 | 115 | ), |
| 116 | 116 | |
| 117 | 117 | array( |
| 118 | 118 | 'type' => 'date', |
| 119 | - 'name' => __( 'Date', 'invoicing' ), |
|
| 119 | + 'name' => __('Date', 'invoicing'), |
|
| 120 | 120 | 'defaults' => array( |
| 121 | 121 | 'value' => '', |
| 122 | - 'label' => __( 'Date', 'invoicing' ), |
|
| 122 | + 'label' => __('Date', 'invoicing'), |
|
| 123 | 123 | 'description' => '', |
| 124 | 124 | 'required' => false, |
| 125 | 125 | ) |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | array( |
| 129 | 129 | 'type' => 'time', |
| 130 | - 'name' => __( 'Time', 'invoicing' ), |
|
| 130 | + 'name' => __('Time', 'invoicing'), |
|
| 131 | 131 | 'defaults' => array( |
| 132 | 132 | 'value' => '', |
| 133 | - 'label' => __( 'Time', 'invoicing' ), |
|
| 133 | + 'label' => __('Time', 'invoicing'), |
|
| 134 | 134 | 'description' => '', |
| 135 | 135 | 'required' => false, |
| 136 | 136 | ) |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | array( |
| 140 | 140 | 'type' => 'number', |
| 141 | - 'name' => __( 'Number', 'invoicing' ), |
|
| 141 | + 'name' => __('Number', 'invoicing'), |
|
| 142 | 142 | 'defaults' => array( |
| 143 | 143 | 'placeholder' => '', |
| 144 | 144 | 'value' => '', |
| 145 | - 'label' => __( 'Number', 'invoicing' ), |
|
| 145 | + 'label' => __('Number', 'invoicing'), |
|
| 146 | 146 | 'description' => '', |
| 147 | 147 | 'required' => false, |
| 148 | 148 | ) |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | array( |
| 152 | 152 | 'type' => 'website', |
| 153 | - 'name' => __( 'Website', 'invoicing' ), |
|
| 153 | + 'name' => __('Website', 'invoicing'), |
|
| 154 | 154 | 'defaults' => array( |
| 155 | 155 | 'placeholder' => 'http://example.com', |
| 156 | 156 | 'value' => '', |
| 157 | - 'label' => __( 'Website', 'invoicing' ), |
|
| 157 | + 'label' => __('Website', 'invoicing'), |
|
| 158 | 158 | 'description' => '', |
| 159 | 159 | 'required' => false, |
| 160 | 160 | ) |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | array( |
| 164 | 164 | 'type' => 'email', |
| 165 | - 'name' => __( 'Email', 'invoicing' ), |
|
| 165 | + 'name' => __('Email', 'invoicing'), |
|
| 166 | 166 | 'defaults' => array( |
| 167 | 167 | 'placeholder' => '[email protected]', |
| 168 | 168 | 'value' => '', |
| 169 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
| 169 | + 'label' => __('Email Address', 'invoicing'), |
|
| 170 | 170 | 'description' => '', |
| 171 | 171 | 'required' => false, |
| 172 | 172 | ) |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | array( |
| 176 | 176 | 'type' => 'address', |
| 177 | - 'name' => __( 'Address', 'invoicing' ), |
|
| 177 | + 'name' => __('Address', 'invoicing'), |
|
| 178 | 178 | 'defaults' => array( |
| 179 | 179 | |
| 180 | 180 | 'address_type' => 'billing', |
| 181 | - 'billing_address_title' => __( 'Billing Address', 'invoicing' ), |
|
| 182 | - 'shipping_address_title' => __( 'Shipping Address', 'invoicing' ), |
|
| 183 | - 'shipping_address_toggle' => __( 'Same billing & shipping address.', 'invoicing' ), |
|
| 181 | + 'billing_address_title' => __('Billing Address', 'invoicing'), |
|
| 182 | + 'shipping_address_title' => __('Shipping Address', 'invoicing'), |
|
| 183 | + 'shipping_address_toggle' => __('Same billing & shipping address.', 'invoicing'), |
|
| 184 | 184 | 'fields' => array( |
| 185 | 185 | array( |
| 186 | 186 | 'placeholder' => 'Jon', |
| 187 | 187 | 'value' => '', |
| 188 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 188 | + 'label' => __('First Name', 'invoicing'), |
|
| 189 | 189 | 'description' => '', |
| 190 | 190 | 'required' => false, |
| 191 | 191 | 'visible' => true, |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | array( |
| 197 | 197 | 'placeholder' => 'Snow', |
| 198 | 198 | 'value' => '', |
| 199 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 199 | + 'label' => __('Last Name', 'invoicing'), |
|
| 200 | 200 | 'description' => '', |
| 201 | 201 | 'required' => false, |
| 202 | 202 | 'visible' => true, |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | array( |
| 208 | 208 | 'placeholder' => '', |
| 209 | 209 | 'value' => '', |
| 210 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 210 | + 'label' => __('Address', 'invoicing'), |
|
| 211 | 211 | 'description' => '', |
| 212 | 212 | 'required' => false, |
| 213 | 213 | 'visible' => true, |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | array( |
| 219 | 219 | 'placeholder' => '', |
| 220 | 220 | 'value' => '', |
| 221 | - 'label' => __( 'City', 'invoicing' ), |
|
| 221 | + 'label' => __('City', 'invoicing'), |
|
| 222 | 222 | 'description' => '', |
| 223 | 223 | 'required' => false, |
| 224 | 224 | 'visible' => true, |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | ), |
| 228 | 228 | |
| 229 | 229 | array( |
| 230 | - 'placeholder' => __( 'Select your country' ), |
|
| 230 | + 'placeholder' => __('Select your country'), |
|
| 231 | 231 | 'value' => '', |
| 232 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 232 | + 'label' => __('Country', 'invoicing'), |
|
| 233 | 233 | 'description' => '', |
| 234 | 234 | 'required' => false, |
| 235 | 235 | 'visible' => true, |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | ), |
| 239 | 239 | |
| 240 | 240 | array( |
| 241 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 241 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 242 | 242 | 'value' => '', |
| 243 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
| 243 | + 'label' => __('State / Province', 'invoicing'), |
|
| 244 | 244 | 'description' => '', |
| 245 | 245 | 'required' => false, |
| 246 | 246 | 'visible' => true, |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | array( |
| 252 | 252 | 'placeholder' => '', |
| 253 | 253 | 'value' => '', |
| 254 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 254 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
| 255 | 255 | 'description' => '', |
| 256 | 256 | 'required' => false, |
| 257 | 257 | 'visible' => true, |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | array( |
| 263 | 263 | 'placeholder' => '', |
| 264 | 264 | 'value' => '', |
| 265 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 265 | + 'label' => __('Phone', 'invoicing'), |
|
| 266 | 266 | 'description' => '', |
| 267 | 267 | 'required' => false, |
| 268 | 268 | 'visible' => true, |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | array( |
| 274 | 274 | 'placeholder' => '', |
| 275 | 275 | 'value' => '', |
| 276 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 276 | + 'label' => __('Company', 'invoicing'), |
|
| 277 | 277 | 'description' => '', |
| 278 | 278 | 'required' => false, |
| 279 | 279 | 'visible' => false, |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | array( |
| 285 | 285 | 'placeholder' => '', |
| 286 | 286 | 'value' => '', |
| 287 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 287 | + 'label' => __('Company ID', 'invoicing'), |
|
| 288 | 288 | 'description' => '', |
| 289 | 289 | 'required' => false, |
| 290 | 290 | 'visible' => false, |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | array( |
| 296 | 296 | 'placeholder' => '', |
| 297 | 297 | 'value' => '', |
| 298 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 298 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 299 | 299 | 'description' => '', |
| 300 | 300 | 'required' => false, |
| 301 | 301 | 'visible' => false, |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | array( |
| 310 | 310 | 'type' => 'billing_email', |
| 311 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
| 311 | + 'name' => __('Billing Email', 'invoicing'), |
|
| 312 | 312 | 'defaults' => array( |
| 313 | 313 | 'placeholder' => '[email protected]', |
| 314 | 314 | 'value' => '', |
| 315 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
| 315 | + 'label' => __('Billing Email', 'invoicing'), |
|
| 316 | 316 | 'description' => '', |
| 317 | 317 | 'premade' => true, |
| 318 | 318 | ) |
@@ -320,18 +320,18 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | array( |
| 322 | 322 | 'type' => 'discount', |
| 323 | - 'name' => __( 'Discount Input', 'invoicing' ), |
|
| 323 | + 'name' => __('Discount Input', 'invoicing'), |
|
| 324 | 324 | 'defaults' => array( |
| 325 | 325 | 'value' => '', |
| 326 | - 'input_label' => __( 'Coupon Code', 'invoicing' ), |
|
| 327 | - 'button_label' => __( 'Apply Coupon', 'invoicing' ), |
|
| 328 | - 'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
|
| 326 | + 'input_label' => __('Coupon Code', 'invoicing'), |
|
| 327 | + 'button_label' => __('Apply Coupon', 'invoicing'), |
|
| 328 | + 'description' => __('Have a discount code? Enter it above.', 'invoicing'), |
|
| 329 | 329 | ) |
| 330 | 330 | ), |
| 331 | 331 | |
| 332 | 332 | array( |
| 333 | 333 | 'type' => 'items', |
| 334 | - 'name' => __( 'Items', 'invoicing' ), |
|
| 334 | + 'name' => __('Items', 'invoicing'), |
|
| 335 | 335 | 'defaults' => array( |
| 336 | 336 | 'value' => '', |
| 337 | 337 | 'items_type' => 'total', |
@@ -343,22 +343,22 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | array( |
| 345 | 345 | 'type' => 'price_input', |
| 346 | - 'name' => __( 'Price Input', 'invoicing' ), |
|
| 346 | + 'name' => __('Price Input', 'invoicing'), |
|
| 347 | 347 | 'defaults' => array( |
| 348 | 348 | 'placeholder' => wpinv_format_amount(0), |
| 349 | 349 | 'value' => wpinv_format_amount(0), |
| 350 | 350 | 'minimum' => wpinv_format_amount(0), |
| 351 | - 'label' => __( 'Enter Amount', 'invoicing' ), |
|
| 351 | + 'label' => __('Enter Amount', 'invoicing'), |
|
| 352 | 352 | 'description' => '', |
| 353 | 353 | ) |
| 354 | 354 | ), |
| 355 | 355 | |
| 356 | 356 | array( |
| 357 | 357 | 'type' => 'price_select', |
| 358 | - 'name' => __( 'Price Select', 'invoicing' ), |
|
| 358 | + 'name' => __('Price Select', 'invoicing'), |
|
| 359 | 359 | 'defaults' => array( |
| 360 | 360 | 'description' => '', |
| 361 | - 'label' => __( 'Select Amount', 'invoicing' ), |
|
| 361 | + 'label' => __('Select Amount', 'invoicing'), |
|
| 362 | 362 | 'options' => 'Option 1|10, Option 2|20', |
| 363 | 363 | 'placeholder' => '', |
| 364 | 364 | 'select_type' => 'select', |
@@ -367,39 +367,39 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | array( |
| 369 | 369 | 'type' => 'pay_button', |
| 370 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
| 370 | + 'name' => __('Payment Button', 'invoicing'), |
|
| 371 | 371 | 'defaults' => array( |
| 372 | 372 | 'value' => '', |
| 373 | 373 | 'class' => 'btn-primary', |
| 374 | - 'label' => __( 'Pay %price% »', 'invoicing' ), |
|
| 375 | - 'free' => __( 'Continue »', 'invoicing' ), |
|
| 376 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
| 374 | + 'label' => __('Pay %price% »', 'invoicing'), |
|
| 375 | + 'free' => __('Continue »', 'invoicing'), |
|
| 376 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
| 377 | 377 | 'premade' => true, |
| 378 | 378 | ) |
| 379 | 379 | ), |
| 380 | 380 | |
| 381 | 381 | array( |
| 382 | 382 | 'type' => 'gateway_select', |
| 383 | - 'name' => __( 'Gateway Select', 'invoicing' ), |
|
| 383 | + 'name' => __('Gateway Select', 'invoicing'), |
|
| 384 | 384 | 'defaults' => array( |
| 385 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 385 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
| 386 | 386 | 'premade' => true, |
| 387 | 387 | ) |
| 388 | 388 | ), |
| 389 | 389 | |
| 390 | 390 | array( |
| 391 | 391 | 'type' => 'total_payable', |
| 392 | - 'name' => __( 'Total Payable', 'invoicing' ), |
|
| 392 | + 'name' => __('Total Payable', 'invoicing'), |
|
| 393 | 393 | 'defaults' => array( |
| 394 | - 'text' => __( 'Total to pay:', 'invoicing' ), |
|
| 394 | + 'text' => __('Total to pay:', 'invoicing'), |
|
| 395 | 395 | ) |
| 396 | 396 | ), |
| 397 | 397 | |
| 398 | 398 | array( |
| 399 | 399 | 'type' => 'ip_address', |
| 400 | - 'name' => __( 'IP Address', 'invoicing' ), |
|
| 400 | + 'name' => __('IP Address', 'invoicing'), |
|
| 401 | 401 | 'defaults' => array( |
| 402 | - 'text' => __( 'Your IP address is:', 'invoicing' ), |
|
| 402 | + 'text' => __('Your IP address is:', 'invoicing'), |
|
| 403 | 403 | ) |
| 404 | 404 | ) |
| 405 | 405 | ); |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters('wpinv_default_country', $country); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
| 27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
| 26 | +function getpaid_get_ip_country($ip_address = '') { |
|
| 27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
| 28 | 28 | return $country['country']; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
| 34 | 34 | * @param string $country The country code to sanitize |
| 35 | 35 | * @return array |
| 36 | 36 | */ |
| 37 | -function wpinv_sanitize_country( $country ) { |
|
| 37 | +function wpinv_sanitize_country($country) { |
|
| 38 | 38 | |
| 39 | 39 | // Enure the country is specified |
| 40 | - if ( empty( $country ) ) { |
|
| 40 | + if (empty($country)) { |
|
| 41 | 41 | $country = wpinv_get_default_country(); |
| 42 | 42 | } |
| 43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
| 43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_is_base_country( $country ) { |
|
| 47 | +function wpinv_is_base_country($country) { |
|
| 48 | 48 | $base_country = wpinv_get_default_country(); |
| 49 | 49 | |
| 50 | - if ( $base_country === 'UK' ) { |
|
| 50 | + if ($base_country === 'UK') { |
|
| 51 | 51 | $base_country = 'GB'; |
| 52 | 52 | } |
| 53 | - if ( $country == 'UK' ) { |
|
| 53 | + if ($country == 'UK') { |
|
| 54 | 54 | $country = 'GB'; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return ( $country && $country === $base_country ) ? true : false; |
|
| 57 | + return ($country && $country === $base_country) ? true : false; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -function wpinv_country_name( $country_code = '' ) { |
|
| 60 | +function wpinv_country_name($country_code = '') { |
|
| 61 | 61 | $countries = wpinv_get_country_list(); |
| 62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
| 63 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
| 63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
| 64 | 64 | |
| 65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
| 65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function wpinv_get_default_state() { |
| 69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
| 69 | + $state = wpinv_get_option('default_state', ''); |
|
| 70 | 70 | |
| 71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 71 | + return apply_filters('wpinv_default_state', $state); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
| 74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
| 75 | 75 | $state = $state_code; |
| 76 | 76 | |
| 77 | - if ( !empty( $country_code ) ) { |
|
| 78 | - $states = wpinv_get_country_states( $country_code ); |
|
| 77 | + if (!empty($country_code)) { |
|
| 78 | + $states = wpinv_get_country_states($country_code); |
|
| 79 | 79 | |
| 80 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
| 80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
| 83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | function wpinv_store_address() { |
| 87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
| 87 | + $address = wpinv_get_option('store_address', ''); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
| 89 | + return apply_filters('wpinv_store_address', $address); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param WPInv_Invoice $invoice |
| 96 | 96 | */ |
| 97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
| 97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
| 98 | 98 | |
| 99 | 99 | $user_id = $invoice->get_user_id(); |
| 100 | 100 | |
| 101 | 101 | // Abort if the invoice belongs to no one. |
| 102 | - if ( empty( $user_id ) ) { |
|
| 102 | + if (empty($user_id)) { |
|
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Fill in defaults whenever necessary. |
| 107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
| 107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
| 108 | 108 | |
| 109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
| 110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
| 109 | + if (is_callable($invoice, "get_$key")) { |
|
| 110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
| 111 | 111 | |
| 112 | - if ( empty( $current ) ) { |
|
| 112 | + if (empty($current)) { |
|
| 113 | 113 | $method = "set_$key"; |
| 114 | - $invoice->$method( $value ); |
|
| 114 | + $invoice->$method($value); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } |
@@ -130,22 +130,22 @@ discard block |
||
| 130 | 130 | $address_fields = apply_filters( |
| 131 | 131 | 'getpaid_user_address_fields', |
| 132 | 132 | array( |
| 133 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
| 134 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
| 135 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 136 | - 'city' => __( 'City', 'invoicing' ), |
|
| 137 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 138 | - 'state' => __( 'State', 'invoicing' ), |
|
| 139 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
| 140 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
| 141 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 142 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
| 143 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
| 133 | + 'first_name' => __('First Name', 'invoicing'), |
|
| 134 | + 'last_name' => __('Last Name', 'invoicing'), |
|
| 135 | + 'address' => __('Address', 'invoicing'), |
|
| 136 | + 'city' => __('City', 'invoicing'), |
|
| 137 | + 'country' => __('Country', 'invoicing'), |
|
| 138 | + 'state' => __('State', 'invoicing'), |
|
| 139 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
| 140 | + 'phone' => __('Phone Number', 'invoicing'), |
|
| 141 | + 'company' => __('Company', 'invoicing'), |
|
| 142 | + 'company_id' => __('Company ID', 'invoicing'), |
|
| 143 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
| 144 | 144 | ) |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) { |
|
| 148 | - unset( $address_fields['vat_number'] ); |
|
| 147 | + if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) { |
|
| 148 | + unset($address_fields['vat_number']); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $address_fields; |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @return bool |
| 158 | 158 | */ |
| 159 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
| 160 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
| 159 | +function getpaid_is_address_field_whitelisted($key) { |
|
| 160 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @param WPInv_Invoice $invoice |
| 169 | 169 | */ |
| 170 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
| 170 | +function getpaid_save_invoice_user_address($invoice) { |
|
| 171 | 171 | |
| 172 | 172 | // Retrieve the invoice. |
| 173 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 173 | + $invoice = wpinv_get_invoice($invoice); |
|
| 174 | 174 | |
| 175 | 175 | // Abort if it does not exist. |
| 176 | - if ( empty( $invoice ) || $invoice->is_renewal() ) { |
|
| 176 | + if (empty($invoice) || $invoice->is_renewal()) { |
|
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 180 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 181 | 181 | |
| 182 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
| 183 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
| 182 | + if (is_callable(array($invoice, "get_$field"))) { |
|
| 183 | + $value = call_user_func(array($invoice, "get_$field")); |
|
| 184 | 184 | |
| 185 | 185 | // Only save if it is not empty. |
| 186 | - if ( ! empty( $value ) ) { |
|
| 187 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
| 186 | + if (!empty($value)) { |
|
| 187 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | } |
| 195 | -add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' ); |
|
| 195 | +add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address'); |
|
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * Retrieves a saved user address. |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | * @param bool $with_default Whether or not we should use the default country and state. |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
| 204 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
| 205 | 205 | |
| 206 | 206 | // Prepare the user id. |
| 207 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
| 208 | - $user_info = get_userdata( $user_id ); |
|
| 207 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
| 208 | + $user_info = get_userdata($user_id); |
|
| 209 | 209 | |
| 210 | 210 | // Abort if non exists. |
| 211 | - if ( empty( $user_info ) ) { |
|
| 211 | + if (empty($user_info)) { |
|
| 212 | 212 | return array(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | 'email' => $user_info->user_email, |
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 222 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
| 221 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 222 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( ! $with_default ) { |
|
| 225 | + if (!$with_default) { |
|
| 226 | 226 | return $address; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'country' => wpinv_get_default_country(), |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
| 236 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param string $field The field to use. |
| 245 | 245 | * @return string|null |
| 246 | 246 | */ |
| 247 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
| 247 | +function getpaid_get_user_address_field($user_id, $field) { |
|
| 248 | 248 | |
| 249 | 249 | $prefixes = array( |
| 250 | 250 | '_wpinv_', |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | '' |
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | - foreach ( $prefixes as $prefix ) { |
|
| 255 | + foreach ($prefixes as $prefix) { |
|
| 256 | 256 | |
| 257 | 257 | // Meta table. |
| 258 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
| 258 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
| 259 | 259 | |
| 260 | 260 | // UWP table. |
| 261 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
| 261 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
| 262 | 262 | |
| 263 | - if ( ! empty( $value ) ) { |
|
| 263 | + if (!empty($value)) { |
|
| 264 | 264 | return $value; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -277,16 +277,16 @@ discard block |
||
| 277 | 277 | * @param string $return What to return. |
| 278 | 278 | * @return array |
| 279 | 279 | */ |
| 280 | -function wpinv_get_continents( $return = 'all' ) { |
|
| 280 | +function wpinv_get_continents($return = 'all') { |
|
| 281 | 281 | |
| 282 | - $continents = wpinv_get_data( 'continents' ); |
|
| 282 | + $continents = wpinv_get_data('continents'); |
|
| 283 | 283 | |
| 284 | - switch( $return ) { |
|
| 284 | + switch ($return) { |
|
| 285 | 285 | case 'name' : |
| 286 | - return wp_list_pluck( $continents, 'name' ); |
|
| 286 | + return wp_list_pluck($continents, 'name'); |
|
| 287 | 287 | break; |
| 288 | 288 | case 'countries' : |
| 289 | - return wp_list_pluck( $continents, 'countries' ); |
|
| 289 | + return wp_list_pluck($continents, 'countries'); |
|
| 290 | 290 | break; |
| 291 | 291 | default : |
| 292 | 292 | return $continents; |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | * @param string $country Country code. If no code is specified, defaults to the default country. |
| 303 | 303 | * @return string |
| 304 | 304 | */ |
| 305 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
| 305 | +function wpinv_get_continent_code_for_country($country = false) { |
|
| 306 | 306 | |
| 307 | - $country = wpinv_sanitize_country( $country ); |
|
| 307 | + $country = wpinv_sanitize_country($country); |
|
| 308 | 308 | |
| 309 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
| 310 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
| 309 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
| 310 | + if (false !== array_search($country, $countries, true)) { |
|
| 311 | 311 | return $continent_code; |
| 312 | 312 | } |
| 313 | 313 | } |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | * @param string $country Country code. If no code is specified, defaults to the default country. |
| 324 | 324 | * @return array |
| 325 | 325 | */ |
| 326 | -function wpinv_get_country_calling_code( $country = null) { |
|
| 326 | +function wpinv_get_country_calling_code($country = null) { |
|
| 327 | 327 | |
| 328 | - $country = wpinv_sanitize_country( $country ); |
|
| 329 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
| 330 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
| 328 | + $country = wpinv_sanitize_country($country); |
|
| 329 | + $codes = wpinv_get_data('phone-codes'); |
|
| 330 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
| 331 | 331 | |
| 332 | - if ( is_array( $code ) ) { |
|
| 332 | + if (is_array($code)) { |
|
| 333 | 333 | return $code[0]; |
| 334 | 334 | } |
| 335 | 335 | return $code; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 343 | 343 | * @return array |
| 344 | 344 | */ |
| 345 | -function wpinv_get_country_list( $first_empty = false ) { |
|
| 346 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
| 345 | +function wpinv_get_country_list($first_empty = false) { |
|
| 346 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -353,22 +353,22 @@ discard block |
||
| 353 | 353 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 354 | 354 | * @return array |
| 355 | 355 | */ |
| 356 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
| 356 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
| 357 | 357 | |
| 358 | 358 | // Prepare the country. |
| 359 | - $country = wpinv_sanitize_country( $country ); |
|
| 359 | + $country = wpinv_sanitize_country($country); |
|
| 360 | 360 | |
| 361 | 361 | // Fetch all states. |
| 362 | - $all_states = wpinv_get_data( 'states' ); |
|
| 362 | + $all_states = wpinv_get_data('states'); |
|
| 363 | 363 | |
| 364 | 364 | // Fetch the specified country's states. |
| 365 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
| 366 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
| 367 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
| 365 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
| 366 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
| 367 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
| 368 | 368 | |
| 369 | - asort( $states ); |
|
| 369 | + asort($states); |
|
| 370 | 370 | |
| 371 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
| 371 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @return array |
| 379 | 379 | */ |
| 380 | 380 | function wpinv_get_us_states_list() { |
| 381 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
| 381 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @return array |
| 389 | 389 | */ |
| 390 | 390 | function wpinv_get_canada_states_list() { |
| 391 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
| 391 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @return array |
| 399 | 399 | */ |
| 400 | 400 | function wpinv_get_australia_states_list() { |
| 401 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
| 401 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @return array |
| 409 | 409 | */ |
| 410 | 410 | function wpinv_get_bangladesh_states_list() { |
| 411 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
| 411 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @return array |
| 419 | 419 | */ |
| 420 | 420 | function wpinv_get_brazil_states_list() { |
| 421 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
| 421 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @return array |
| 429 | 429 | */ |
| 430 | 430 | function wpinv_get_bulgaria_states_list() { |
| 431 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
| 431 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @return array |
| 439 | 439 | */ |
| 440 | 440 | function wpinv_get_hong_kong_states_list() { |
| 441 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
| 441 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @return array |
| 449 | 449 | */ |
| 450 | 450 | function wpinv_get_hungary_states_list() { |
| 451 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
| 451 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @return array |
| 459 | 459 | */ |
| 460 | 460 | function wpinv_get_japan_states_list() { |
| 461 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
| 461 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @return array |
| 469 | 469 | */ |
| 470 | 470 | function wpinv_get_china_states_list() { |
| 471 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
| 471 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @return array |
| 479 | 479 | */ |
| 480 | 480 | function wpinv_get_new_zealand_states_list() { |
| 481 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
| 481 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @return array |
| 489 | 489 | */ |
| 490 | 490 | function wpinv_get_peru_states_list() { |
| 491 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
| 491 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | * @return array |
| 499 | 499 | */ |
| 500 | 500 | function wpinv_get_indonesia_states_list() { |
| 501 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
| 501 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @return array |
| 509 | 509 | */ |
| 510 | 510 | function wpinv_get_india_states_list() { |
| 511 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
| 511 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | * @return array |
| 519 | 519 | */ |
| 520 | 520 | function wpinv_get_iran_states_list() { |
| 521 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
| 521 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | * @return array |
| 529 | 529 | */ |
| 530 | 530 | function wpinv_get_italy_states_list() { |
| 531 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
| 531 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * @return array |
| 539 | 539 | */ |
| 540 | 540 | function wpinv_get_malaysia_states_list() { |
| 541 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
| 541 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return array |
| 549 | 549 | */ |
| 550 | 550 | function wpinv_get_mexico_states_list() { |
| 551 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
| 551 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @return array |
| 559 | 559 | */ |
| 560 | 560 | function wpinv_get_nepal_states_list() { |
| 561 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
| 561 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @return array |
| 569 | 569 | */ |
| 570 | 570 | function wpinv_get_south_africa_states_list() { |
| 571 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
| 571 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @return array |
| 579 | 579 | */ |
| 580 | 580 | function wpinv_get_thailand_states_list() { |
| 581 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
| 581 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function wpinv_get_turkey_states_list() { |
| 591 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
| 591 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -598,31 +598,31 @@ discard block |
||
| 598 | 598 | * @return array |
| 599 | 599 | */ |
| 600 | 600 | function wpinv_get_spain_states_list() { |
| 601 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
| 601 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | function wpinv_get_states_field() { |
| 605 | - if( empty( $_POST['country'] ) ) { |
|
| 605 | + if (empty($_POST['country'])) { |
|
| 606 | 606 | $_POST['country'] = wpinv_get_default_country(); |
| 607 | 607 | } |
| 608 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 608 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
| 609 | 609 | |
| 610 | - if( !empty( $states ) ) { |
|
| 611 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 610 | + if (!empty($states)) { |
|
| 611 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
| 612 | 612 | |
| 613 | - $class = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : ''; |
|
| 613 | + $class = isset($_POST['class']) ? esc_attr($_POST['class']) : ''; |
|
| 614 | 614 | $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2"; |
| 615 | 615 | |
| 616 | - $args = array( |
|
| 616 | + $args = array( |
|
| 617 | 617 | 'name' => $sanitized_field_name, |
| 618 | 618 | 'id' => $sanitized_field_name, |
| 619 | - 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
| 620 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 619 | + 'class' => implode(' ', array_unique(explode(' ', $class))), |
|
| 620 | + 'options' => array_merge(array('' => ''), $states), |
|
| 621 | 621 | 'show_option_all' => false, |
| 622 | 622 | 'show_option_none' => false |
| 623 | 623 | ); |
| 624 | 624 | |
| 625 | - $response = wpinv_html_select( $args ); |
|
| 625 | + $response = wpinv_html_select($args); |
|
| 626 | 626 | |
| 627 | 627 | } else { |
| 628 | 628 | $response = 'nostates'; |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | return $response; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
| 635 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
| 634 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
| 635 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
| 636 | 636 | |
| 637 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
| 637 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | /** |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | function wpinv_get_address_formats() { |
| 648 | 648 | |
| 649 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
| 649 | + return apply_filters('wpinv_localisation_address_formats', |
|
| 650 | 650 | array( |
| 651 | 651 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
| 652 | 652 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | * @see `wpinv_get_invoice_address_replacements` |
| 696 | 696 | * @return string |
| 697 | 697 | */ |
| 698 | -function wpinv_get_full_address_format( $country = false) { |
|
| 698 | +function wpinv_get_full_address_format($country = false) { |
|
| 699 | 699 | |
| 700 | - if( empty( $country ) ) { |
|
| 700 | + if (empty($country)) { |
|
| 701 | 701 | $country = wpinv_get_default_country(); |
| 702 | 702 | } |
| 703 | 703 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $formats = wpinv_get_address_formats(); |
| 706 | 706 | |
| 707 | 707 | // Get format for the specified country. |
| 708 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
| 708 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
| 709 | 709 | |
| 710 | 710 | /** |
| 711 | 711 | * Filters the address format to use on Invoices. |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * @param string $format The address format to use. |
| 718 | 718 | * @param string $country The country who's address format is being retrieved. |
| 719 | 719 | */ |
| 720 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
| 720 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * @param array $billing_details customer's billing details |
| 729 | 729 | * @return array |
| 730 | 730 | */ |
| 731 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
| 731 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
| 732 | 732 | |
| 733 | 733 | $default_args = array( |
| 734 | 734 | 'address' => '', |
@@ -741,22 +741,22 @@ discard block |
||
| 741 | 741 | 'company' => '', |
| 742 | 742 | ); |
| 743 | 743 | |
| 744 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
| 744 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
| 745 | 745 | $state = $args['state']; |
| 746 | 746 | $country = $args['country']; |
| 747 | 747 | |
| 748 | 748 | // Handle full country name. |
| 749 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
| 749 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
| 750 | 750 | |
| 751 | 751 | // Handle full state name. |
| 752 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
| 752 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
| 753 | 753 | |
| 754 | 754 | $args['postcode'] = $args['zip']; |
| 755 | 755 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
| 756 | 756 | $args['state'] = $full_state; |
| 757 | 757 | $args['state_code'] = $state; |
| 758 | 758 | $args['country'] = $full_country; |
| 759 | - $args['country_code']= $country; |
|
| 759 | + $args['country_code'] = $country; |
|
| 760 | 760 | |
| 761 | 761 | /** |
| 762 | 762 | * Filters the address format replacements to use on Invoices. |
@@ -767,14 +767,14 @@ discard block |
||
| 767 | 767 | * @param array $replacements The address replacements to use. |
| 768 | 768 | * @param array $billing_details The billing details to use. |
| 769 | 769 | */ |
| 770 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
| 770 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
| 771 | 771 | |
| 772 | 772 | $return = array(); |
| 773 | 773 | |
| 774 | - foreach( $replacements as $key => $value ) { |
|
| 775 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
| 774 | + foreach ($replacements as $key => $value) { |
|
| 775 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
| 776 | 776 | $return['{{' . $key . '}}'] = $value; |
| 777 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
| 777 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | return $return; |
@@ -788,6 +788,6 @@ discard block |
||
| 788 | 788 | * @since 1.0.14 |
| 789 | 789 | * @return string |
| 790 | 790 | */ |
| 791 | -function wpinv_trim_formatted_address_line( $line ) { |
|
| 792 | - return trim( $line, ', ' ); |
|
| 791 | +function wpinv_trim_formatted_address_line($line) { |
|
| 792 | + return trim($line, ', '); |
|
| 793 | 793 | } |
| 794 | 794 | \ No newline at end of file |
@@ -5,110 +5,110 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | - exit; // Exit if accessed directly |
|
| 8 | + exit; // Exit if accessed directly |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * GetPaid_Admin_Profile Class. |
|
| 15 | - */ |
|
| 16 | - class GetPaid_Admin_Profile { |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Hook in tabs. |
|
| 20 | - */ |
|
| 21 | - public function __construct() { |
|
| 22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 24 | - |
|
| 25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Get Address Fields for the edit user pages. |
|
| 31 | - * |
|
| 32 | - * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
| 33 | - */ |
|
| 34 | - public function get_customer_meta_fields() { |
|
| 35 | - |
|
| 36 | - $show_fields = apply_filters( |
|
| 37 | - 'getpaid_customer_meta_fields', |
|
| 38 | - array( |
|
| 39 | - 'billing' => array( |
|
| 40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
| 41 | - 'fields' => array( |
|
| 42 | - '_wpinv_first_name' => array( |
|
| 43 | - 'label' => __( 'First name', 'invoicing' ), |
|
| 44 | - 'description' => '', |
|
| 45 | - ), |
|
| 46 | - '_wpinv_last_name' => array( |
|
| 47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
| 48 | - 'description' => '', |
|
| 49 | - ), |
|
| 50 | - '_wpinv_company' => array( |
|
| 51 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 52 | - 'description' => '', |
|
| 53 | - ), |
|
| 54 | - '_wpinv_company_id' => array( |
|
| 55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 56 | - 'description' => '', |
|
| 57 | - ), |
|
| 58 | - '_wpinv_address' => array( |
|
| 59 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 60 | - 'description' => '', |
|
| 61 | - ), |
|
| 62 | - '_wpinv_city' => array( |
|
| 63 | - 'label' => __( 'City', 'invoicing' ), |
|
| 64 | - 'description' => '', |
|
| 65 | - ), |
|
| 66 | - '_wpinv_zip' => array( |
|
| 67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
| 68 | - 'description' => '', |
|
| 69 | - ), |
|
| 70 | - '_wpinv_country' => array( |
|
| 71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
| 72 | - 'description' => '', |
|
| 73 | - 'class' => 'getpaid_js_field-country', |
|
| 74 | - 'type' => 'select', |
|
| 75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
| 76 | - ), |
|
| 77 | - '_wpinv_state' => array( |
|
| 78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
| 79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
| 80 | - 'class' => 'getpaid_js_field-state regular-text', |
|
| 81 | - ), |
|
| 82 | - '_wpinv_phone' => array( |
|
| 83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 84 | - 'description' => '', |
|
| 85 | - ), |
|
| 86 | - '_wpinv_vat_number' => array( |
|
| 87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 88 | - 'description' => '', |
|
| 89 | - ), |
|
| 90 | - ), |
|
| 91 | - ), |
|
| 92 | - ) |
|
| 93 | - ); |
|
| 94 | - return $show_fields; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Show Address Fields on edit user pages. |
|
| 99 | - * |
|
| 100 | - * @param WP_User $user |
|
| 101 | - */ |
|
| 102 | - public function add_customer_meta_fields( $user ) { |
|
| 103 | - |
|
| 104 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $show_fields = $this->get_customer_meta_fields(); |
|
| 109 | - |
|
| 110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
| 111 | - ?> |
|
| 13 | + /** |
|
| 14 | + * GetPaid_Admin_Profile Class. |
|
| 15 | + */ |
|
| 16 | + class GetPaid_Admin_Profile { |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Hook in tabs. |
|
| 20 | + */ |
|
| 21 | + public function __construct() { |
|
| 22 | + add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 23 | + add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 24 | + |
|
| 25 | + add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 26 | + add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Get Address Fields for the edit user pages. |
|
| 31 | + * |
|
| 32 | + * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
| 33 | + */ |
|
| 34 | + public function get_customer_meta_fields() { |
|
| 35 | + |
|
| 36 | + $show_fields = apply_filters( |
|
| 37 | + 'getpaid_customer_meta_fields', |
|
| 38 | + array( |
|
| 39 | + 'billing' => array( |
|
| 40 | + 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
| 41 | + 'fields' => array( |
|
| 42 | + '_wpinv_first_name' => array( |
|
| 43 | + 'label' => __( 'First name', 'invoicing' ), |
|
| 44 | + 'description' => '', |
|
| 45 | + ), |
|
| 46 | + '_wpinv_last_name' => array( |
|
| 47 | + 'label' => __( 'Last name', 'invoicing' ), |
|
| 48 | + 'description' => '', |
|
| 49 | + ), |
|
| 50 | + '_wpinv_company' => array( |
|
| 51 | + 'label' => __( 'Company', 'invoicing' ), |
|
| 52 | + 'description' => '', |
|
| 53 | + ), |
|
| 54 | + '_wpinv_company_id' => array( |
|
| 55 | + 'label' => __( 'Company ID', 'invoicing' ), |
|
| 56 | + 'description' => '', |
|
| 57 | + ), |
|
| 58 | + '_wpinv_address' => array( |
|
| 59 | + 'label' => __( 'Address', 'invoicing' ), |
|
| 60 | + 'description' => '', |
|
| 61 | + ), |
|
| 62 | + '_wpinv_city' => array( |
|
| 63 | + 'label' => __( 'City', 'invoicing' ), |
|
| 64 | + 'description' => '', |
|
| 65 | + ), |
|
| 66 | + '_wpinv_zip' => array( |
|
| 67 | + 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
| 68 | + 'description' => '', |
|
| 69 | + ), |
|
| 70 | + '_wpinv_country' => array( |
|
| 71 | + 'label' => __( 'Country / Region', 'invoicing' ), |
|
| 72 | + 'description' => '', |
|
| 73 | + 'class' => 'getpaid_js_field-country', |
|
| 74 | + 'type' => 'select', |
|
| 75 | + 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
| 76 | + ), |
|
| 77 | + '_wpinv_state' => array( |
|
| 78 | + 'label' => __( 'State / County', 'invoicing' ), |
|
| 79 | + 'description' => __( 'State / County or state code', 'invoicing' ), |
|
| 80 | + 'class' => 'getpaid_js_field-state regular-text', |
|
| 81 | + ), |
|
| 82 | + '_wpinv_phone' => array( |
|
| 83 | + 'label' => __( 'Phone', 'invoicing' ), |
|
| 84 | + 'description' => '', |
|
| 85 | + ), |
|
| 86 | + '_wpinv_vat_number' => array( |
|
| 87 | + 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 88 | + 'description' => '', |
|
| 89 | + ), |
|
| 90 | + ), |
|
| 91 | + ), |
|
| 92 | + ) |
|
| 93 | + ); |
|
| 94 | + return $show_fields; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Show Address Fields on edit user pages. |
|
| 99 | + * |
|
| 100 | + * @param WP_User $user |
|
| 101 | + */ |
|
| 102 | + public function add_customer_meta_fields( $user ) { |
|
| 103 | + |
|
| 104 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $show_fields = $this->get_customer_meta_fields(); |
|
| 109 | + |
|
| 110 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
| 111 | + ?> |
|
| 112 | 112 | <h2><?php echo $fieldset['title']; ?></h2> |
| 113 | 113 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
| 114 | 114 | <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
| 121 | 121 | <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
| 122 | 122 | <?php |
| 123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
| 124 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
| 125 | - ?> |
|
| 123 | + $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
| 124 | + foreach ( $field['options'] as $option_key => $option_value ) : |
|
| 125 | + ?> |
|
| 126 | 126 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
| 127 | 127 | <?php endforeach; ?> |
| 128 | 128 | </select> |
@@ -137,52 +137,52 @@ discard block |
||
| 137 | 137 | <?php endforeach; ?> |
| 138 | 138 | </table> |
| 139 | 139 | <?php |
| 140 | - endforeach; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Save Address Fields on edit user pages. |
|
| 145 | - * |
|
| 146 | - * @param int $user_id User ID of the user being saved |
|
| 147 | - */ |
|
| 148 | - public function save_customer_meta_fields( $user_id ) { |
|
| 149 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - $save_fields = $this->get_customer_meta_fields(); |
|
| 154 | - |
|
| 155 | - foreach ( $save_fields as $fieldset ) { |
|
| 156 | - |
|
| 157 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
| 158 | - |
|
| 159 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
| 160 | - update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
| 161 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
| 162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
| 170 | - * |
|
| 171 | - * @since 3.1.0 |
|
| 172 | - * @param int $user_id User ID of the user being edited |
|
| 173 | - * @param string $key Key for user meta field |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - protected function get_user_meta( $user_id, $key ) { |
|
| 177 | - $value = get_user_meta( $user_id, $key, true ); |
|
| 178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
| 179 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
| 180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - return $value; |
|
| 184 | - } |
|
| 185 | - } |
|
| 140 | + endforeach; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Save Address Fields on edit user pages. |
|
| 145 | + * |
|
| 146 | + * @param int $user_id User ID of the user being saved |
|
| 147 | + */ |
|
| 148 | + public function save_customer_meta_fields( $user_id ) { |
|
| 149 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + $save_fields = $this->get_customer_meta_fields(); |
|
| 154 | + |
|
| 155 | + foreach ( $save_fields as $fieldset ) { |
|
| 156 | + |
|
| 157 | + foreach ( $fieldset['fields'] as $key => $field ) { |
|
| 158 | + |
|
| 159 | + if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
| 160 | + update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
| 161 | + } elseif ( isset( $_POST[ $key ] ) ) { |
|
| 162 | + update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
| 170 | + * |
|
| 171 | + * @since 3.1.0 |
|
| 172 | + * @param int $user_id User ID of the user being edited |
|
| 173 | + * @param string $key Key for user meta field |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + protected function get_user_meta( $user_id, $key ) { |
|
| 177 | + $value = get_user_meta( $user_id, $key, true ); |
|
| 178 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
| 179 | + if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
| 180 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + return $value; |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | 187 | endif; |
| 188 | 188 | |
@@ -4,11 +4,11 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 7 | +if (!defined('ABSPATH')) { |
|
| 8 | 8 | exit; // Exit if accessed directly |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
|
| 11 | +if (!class_exists('GetPaid_Admin_Profile', false)) : |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * GetPaid_Admin_Profile Class. |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | * Hook in tabs. |
| 20 | 20 | */ |
| 21 | 21 | public function __construct() { |
| 22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
| 22 | + add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
| 23 | + add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
| 24 | 24 | |
| 25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
| 25 | + add_action('personal_options_update', array($this, 'save_customer_meta_fields')); |
|
| 26 | + add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields')); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -37,54 +37,54 @@ discard block |
||
| 37 | 37 | 'getpaid_customer_meta_fields', |
| 38 | 38 | array( |
| 39 | 39 | 'billing' => array( |
| 40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
| 40 | + 'title' => __('Billing Details (GetPaid)', 'invoicing'), |
|
| 41 | 41 | 'fields' => array( |
| 42 | 42 | '_wpinv_first_name' => array( |
| 43 | - 'label' => __( 'First name', 'invoicing' ), |
|
| 43 | + 'label' => __('First name', 'invoicing'), |
|
| 44 | 44 | 'description' => '', |
| 45 | 45 | ), |
| 46 | 46 | '_wpinv_last_name' => array( |
| 47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
| 47 | + 'label' => __('Last name', 'invoicing'), |
|
| 48 | 48 | 'description' => '', |
| 49 | 49 | ), |
| 50 | 50 | '_wpinv_company' => array( |
| 51 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 51 | + 'label' => __('Company', 'invoicing'), |
|
| 52 | 52 | 'description' => '', |
| 53 | 53 | ), |
| 54 | 54 | '_wpinv_company_id' => array( |
| 55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 55 | + 'label' => __('Company ID', 'invoicing'), |
|
| 56 | 56 | 'description' => '', |
| 57 | 57 | ), |
| 58 | 58 | '_wpinv_address' => array( |
| 59 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 59 | + 'label' => __('Address', 'invoicing'), |
|
| 60 | 60 | 'description' => '', |
| 61 | 61 | ), |
| 62 | 62 | '_wpinv_city' => array( |
| 63 | - 'label' => __( 'City', 'invoicing' ), |
|
| 63 | + 'label' => __('City', 'invoicing'), |
|
| 64 | 64 | 'description' => '', |
| 65 | 65 | ), |
| 66 | 66 | '_wpinv_zip' => array( |
| 67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
| 67 | + 'label' => __('Postcode / ZIP', 'invoicing'), |
|
| 68 | 68 | 'description' => '', |
| 69 | 69 | ), |
| 70 | 70 | '_wpinv_country' => array( |
| 71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
| 71 | + 'label' => __('Country / Region', 'invoicing'), |
|
| 72 | 72 | 'description' => '', |
| 73 | 73 | 'class' => 'getpaid_js_field-country', |
| 74 | 74 | 'type' => 'select', |
| 75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
| 75 | + 'options' => array('' => __('Select a country / region…', 'invoicing')) + wpinv_get_country_list(), |
|
| 76 | 76 | ), |
| 77 | 77 | '_wpinv_state' => array( |
| 78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
| 79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
| 78 | + 'label' => __('State / County', 'invoicing'), |
|
| 79 | + 'description' => __('State / County or state code', 'invoicing'), |
|
| 80 | 80 | 'class' => 'getpaid_js_field-state regular-text', |
| 81 | 81 | ), |
| 82 | 82 | '_wpinv_phone' => array( |
| 83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 83 | + 'label' => __('Phone', 'invoicing'), |
|
| 84 | 84 | 'description' => '', |
| 85 | 85 | ), |
| 86 | 86 | '_wpinv_vat_number' => array( |
| 87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 87 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 88 | 88 | 'description' => '', |
| 89 | 89 | ), |
| 90 | 90 | ), |
@@ -99,39 +99,39 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param WP_User $user |
| 101 | 101 | */ |
| 102 | - public function add_customer_meta_fields( $user ) { |
|
| 102 | + public function add_customer_meta_fields($user) { |
|
| 103 | 103 | |
| 104 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
| 104 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) { |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $show_fields = $this->get_customer_meta_fields(); |
| 109 | 109 | |
| 110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
| 110 | + foreach ($show_fields as $fieldset_key => $fieldset) : |
|
| 111 | 111 | ?> |
| 112 | 112 | <h2><?php echo $fieldset['title']; ?></h2> |
| 113 | - <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
|
| 114 | - <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
|
| 113 | + <table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>"> |
|
| 114 | + <?php foreach ($fieldset['fields'] as $key => $field) : ?> |
|
| 115 | 115 | <tr> |
| 116 | 116 | <th> |
| 117 | - <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
|
| 117 | + <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label> |
|
| 118 | 118 | </th> |
| 119 | 119 | <td> |
| 120 | - <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
|
| 121 | - <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
|
| 120 | + <?php if (!empty($field['type']) && 'select' === $field['type']) : ?> |
|
| 121 | + <select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;"> |
|
| 122 | 122 | <?php |
| 123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
| 124 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
| 123 | + $selected = esc_attr(get_user_meta($user->ID, $key, true)); |
|
| 124 | + foreach ($field['options'] as $option_key => $option_value) : |
|
| 125 | 125 | ?> |
| 126 | - <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
|
| 126 | + <option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option> |
|
| 127 | 127 | <?php endforeach; ?> |
| 128 | 128 | </select> |
| 129 | - <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> |
|
| 130 | - <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> /> |
|
| 129 | + <?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?> |
|
| 130 | + <input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> /> |
|
| 131 | 131 | <?php else : ?> |
| 132 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
| 132 | + <input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" /> |
|
| 133 | 133 | <?php endif; ?> |
| 134 | - <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> |
|
| 134 | + <p class="description"><?php echo wp_kses_post($field['description']); ?></p> |
|
| 135 | 135 | </td> |
| 136 | 136 | </tr> |
| 137 | 137 | <?php endforeach; ?> |
@@ -145,21 +145,21 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @param int $user_id User ID of the user being saved |
| 147 | 147 | */ |
| 148 | - public function save_customer_meta_fields( $user_id ) { |
|
| 149 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
| 148 | + public function save_customer_meta_fields($user_id) { |
|
| 149 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) { |
|
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $save_fields = $this->get_customer_meta_fields(); |
| 154 | 154 | |
| 155 | - foreach ( $save_fields as $fieldset ) { |
|
| 155 | + foreach ($save_fields as $fieldset) { |
|
| 156 | 156 | |
| 157 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
| 157 | + foreach ($fieldset['fields'] as $key => $field) { |
|
| 158 | 158 | |
| 159 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
| 160 | - update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
| 161 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
| 162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
| 159 | + if (isset($field['type']) && 'checkbox' === $field['type']) { |
|
| 160 | + update_user_meta($user_id, $key, isset($_POST[$key])); |
|
| 161 | + } elseif (isset($_POST[$key])) { |
|
| 162 | + update_user_meta($user_id, $key, wpinv_clean($_POST[$key])); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | * @param string $key Key for user meta field |
| 174 | 174 | * @return string |
| 175 | 175 | */ |
| 176 | - protected function get_user_meta( $user_id, $key ) { |
|
| 177 | - $value = get_user_meta( $user_id, $key, true ); |
|
| 178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
| 179 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
| 180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
| 176 | + protected function get_user_meta($user_id, $key) { |
|
| 177 | + $value = get_user_meta($user_id, $key, true); |
|
| 178 | + $existing_fields = array('_wpinv_first_name', '_wpinv_last_name'); |
|
| 179 | + if (!$value && in_array($key, $existing_fields)) { |
|
| 180 | + $value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $value; |
@@ -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,19 +277,19 @@ 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 if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?> |
|
| 292 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
| 291 | + <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?> |
|
| 292 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
| 293 | 293 | |
| 294 | 294 | <div class="row"> |
| 295 | 295 | <div class="col-12 col-sm-6"> |
@@ -298,14 +298,14 @@ discard block |
||
| 298 | 298 | array( |
| 299 | 299 | 'id' => 'wpinv_template', |
| 300 | 300 | 'name' => 'wpinv_template', |
| 301 | - 'label' => __( 'Template', 'invoicing' ), |
|
| 301 | + 'label' => __('Template', 'invoicing'), |
|
| 302 | 302 | 'label_type' => 'vertical', |
| 303 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
| 303 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
| 304 | 304 | 'class' => 'form-control-sm', |
| 305 | - 'value' => $invoice->get_template( 'edit' ), |
|
| 305 | + 'value' => $invoice->get_template('edit'), |
|
| 306 | 306 | 'options' => array( |
| 307 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 308 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
| 307 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 308 | + 'hours' => __('Hours', 'invoicing'), |
|
| 309 | 309 | //'amount' => __( 'Amount Only', 'invoicing' ), |
| 310 | 310 | ), |
| 311 | 311 | 'data-allow-clear' => 'false', |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | array( |
| 323 | 323 | 'id' => 'wpinv_currency', |
| 324 | 324 | 'name' => 'wpinv_currency', |
| 325 | - 'label' => __( 'Currency', 'invoicing' ), |
|
| 325 | + 'label' => __('Currency', 'invoicing'), |
|
| 326 | 326 | 'label_type' => 'vertical', |
| 327 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
| 327 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
| 328 | 328 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
| 329 | - 'value' => $invoice->get_currency( 'edit' ), |
|
| 329 | + 'value' => $invoice->get_currency('edit'), |
|
| 330 | 330 | 'required' => false, |
| 331 | 331 | 'data-allow-clear' => 'false', |
| 332 | 332 | 'select2' => true, |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | </div> |
| 339 | 339 | </div> |
| 340 | 340 | |
| 341 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
| 341 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
| 342 | 342 | <?php endif; ?> |
| 343 | 343 | |
| 344 | 344 | <div class="row"> |
@@ -349,18 +349,18 @@ discard block |
||
| 349 | 349 | 'type' => 'text', |
| 350 | 350 | 'id' => 'wpinv_company_id', |
| 351 | 351 | 'name' => 'wpinv_company_id', |
| 352 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 352 | + 'label' => __('Company ID', 'invoicing'), |
|
| 353 | 353 | 'label_type' => 'vertical', |
| 354 | 354 | 'placeholder' => '', |
| 355 | 355 | 'class' => 'form-control-sm', |
| 356 | - 'value' => $invoice->get_company_id( 'edit' ), |
|
| 356 | + 'value' => $invoice->get_company_id('edit'), |
|
| 357 | 357 | ) |
| 358 | 358 | ); |
| 359 | 359 | ?> |
| 360 | 360 | </div> |
| 361 | 361 | </div> |
| 362 | 362 | |
| 363 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
| 363 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
| 364 | 364 | </div> |
| 365 | 365 | <?php |
| 366 | 366 | } |
@@ -370,51 +370,51 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @param int $post_id |
| 372 | 372 | */ |
| 373 | - public static function save( $post_id ) { |
|
| 373 | + public static function save($post_id) { |
|
| 374 | 374 | |
| 375 | 375 | // Prepare the invoice. |
| 376 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 376 | + $invoice = new WPInv_Invoice($post_id); |
|
| 377 | 377 | |
| 378 | 378 | // Load new data. |
| 379 | 379 | $invoice->set_props( |
| 380 | 380 | array( |
| 381 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
| 382 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
| 383 | - 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
|
| 384 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
| 385 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
| 386 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
| 387 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
| 388 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
| 389 | - 'company_id' => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null, |
|
| 390 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
| 391 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
| 392 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
| 393 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
| 394 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
| 395 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
| 396 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
| 397 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
| 398 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
| 399 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
| 400 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
| 401 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
| 402 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
| 381 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
| 382 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
| 383 | + 'disable_taxes' => isset($_POST['disable_taxes']), |
|
| 384 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
| 385 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
| 386 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
| 387 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
| 388 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
| 389 | + 'company_id' => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null, |
|
| 390 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
| 391 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
| 392 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
| 393 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
| 394 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
| 395 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
| 396 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
| 397 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
| 398 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
| 399 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
| 400 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
| 401 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
| 402 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
| 403 | 403 | ) |
| 404 | 404 | ); |
| 405 | 405 | |
| 406 | 406 | // Discount code. |
| 407 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 407 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 408 | 408 | |
| 409 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
| 410 | - $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) ); |
|
| 409 | + if (isset($_POST['wpinv_discount_code'])) { |
|
| 410 | + $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code'])); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 414 | - if ( $discount->exists() ) { |
|
| 415 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 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 | // Recalculate totals. |
@@ -423,17 +423,17 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // If we're creating a new user... |
| 426 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) { |
|
| 426 | + if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) { |
|
| 427 | 427 | |
| 428 | 428 | // Attempt to create the user. |
| 429 | - $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) ); |
|
| 429 | + $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email']))); |
|
| 430 | 430 | |
| 431 | 431 | |
| 432 | 432 | // If successful, update the invoice author. |
| 433 | - if ( is_numeric( $user ) ) { |
|
| 434 | - $invoice->set_author( $user ); |
|
| 433 | + if (is_numeric($user)) { |
|
| 434 | + $invoice->set_author($user); |
|
| 435 | 435 | } else { |
| 436 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 436 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
@@ -447,24 +447,24 @@ discard block |
||
| 447 | 447 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
| 448 | 448 | |
| 449 | 449 | // (Maybe) send new user notification. |
| 450 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
| 451 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
| 452 | - wp_send_new_user_notifications( $user, 'user' ); |
|
| 450 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
| 451 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
| 452 | + wp_send_new_user_notifications($user, 'user'); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
| 455 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
| 456 | 456 | |
| 457 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
| 457 | + $sent = getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
| 458 | 458 | |
| 459 | - if ( $sent ) { |
|
| 460 | - getpaid_admin()->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 459 | + if ($sent) { |
|
| 460 | + getpaid_admin()->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
| 461 | 461 | } else { |
| 462 | - getpaid_admin()->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
| 462 | + getpaid_admin()->show_error(__('Could not send the invoice to the customer', 'invoicing')); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | // Fires after an invoice is saved. |
| 468 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
| 468 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
| 469 | 469 | } |
| 470 | 470 | } |
@@ -14,89 +14,89 @@ discard block |
||
| 14 | 14 | class GetPaid_Admin { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Local path to this plugins admin directory |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $admin_path; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Web path to this plugins admin directory |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - public $admin_url; |
|
| 17 | + * Local path to this plugins admin directory |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $admin_path; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Web path to this plugins admin directory |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + public $admin_url; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Reports components. |
|
| 32 | - * |
|
| 33 | - * @var GetPaid_Reports |
|
| 34 | - */ |
|
| 30 | + /** |
|
| 31 | + * Reports components. |
|
| 32 | + * |
|
| 33 | + * @var GetPaid_Reports |
|
| 34 | + */ |
|
| 35 | 35 | public $reports; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Class constructor. |
|
| 39 | - */ |
|
| 40 | - public function __construct(){ |
|
| 38 | + * Class constructor. |
|
| 39 | + */ |
|
| 40 | + public function __construct(){ |
|
| 41 | 41 | |
| 42 | 42 | $this->admin_path = plugin_dir_path( __FILE__ ); |
| 43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 44 | - $this->reports = new GetPaid_Reports(); |
|
| 43 | + $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 44 | + $this->reports = new GetPaid_Reports(); |
|
| 45 | 45 | |
| 46 | 46 | if ( is_admin() ) { |
| 47 | - $this->init_admin_hooks(); |
|
| 47 | + $this->init_admin_hooks(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Init action and filter hooks |
|
| 54 | - * |
|
| 55 | - */ |
|
| 56 | - private function init_admin_hooks() { |
|
| 53 | + * Init action and filter hooks |
|
| 54 | + * |
|
| 55 | + */ |
|
| 56 | + private function init_admin_hooks() { |
|
| 57 | 57 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
| 58 | 58 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
| 59 | 59 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
| 60 | 60 | add_action( 'admin_init', array( $this, 'activation_redirect') ); |
| 61 | 61 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
| 62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
| 64 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 65 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 63 | + add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
| 64 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 65 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 66 | 66 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
| 67 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
| 68 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
| 69 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
| 70 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
| 71 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
| 72 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
| 73 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
| 74 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
| 75 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 76 | - |
|
| 77 | - // Setup/welcome |
|
| 78 | - if ( ! empty( $_GET['page'] ) ) { |
|
| 79 | - switch ( $_GET['page'] ) { |
|
| 80 | - case 'gp-setup' : |
|
| 81 | - include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' ); |
|
| 82 | - break; |
|
| 83 | - } |
|
| 84 | - } |
|
| 67 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
| 68 | + add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
| 69 | + add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
| 70 | + add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
| 71 | + add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
| 72 | + add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
| 73 | + add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
| 74 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
| 75 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 76 | + |
|
| 77 | + // Setup/welcome |
|
| 78 | + if ( ! empty( $_GET['page'] ) ) { |
|
| 79 | + switch ( $_GET['page'] ) { |
|
| 80 | + case 'gp-setup' : |
|
| 81 | + include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' ); |
|
| 82 | + break; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Register admin scripts |
|
| 90 | - * |
|
| 91 | - */ |
|
| 92 | - public function enqeue_scripts() { |
|
| 89 | + * Register admin scripts |
|
| 90 | + * |
|
| 91 | + */ |
|
| 92 | + public function enqeue_scripts() { |
|
| 93 | 93 | global $current_screen, $pagenow; |
| 94 | 94 | |
| 95 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 96 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
| 95 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 96 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
| 97 | 97 | |
| 98 | 98 | if ( ! empty( $current_screen->post_type ) ) { |
| 99 | - $page = $current_screen->post_type; |
|
| 99 | + $page = $current_screen->post_type; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // General styles. |
@@ -117,54 +117,54 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Payment form scripts. |
| 120 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 120 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 121 | 121 | $this->load_payment_form_scripts(); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 125 | - wp_enqueue_script( 'postbox' ); |
|
| 126 | - } |
|
| 124 | + if ( $page == 'wpinv-subscriptions' ) { |
|
| 125 | + wp_enqueue_script( 'postbox' ); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * Returns admin js translations. |
|
| 132 | - * |
|
| 133 | - */ |
|
| 134 | - protected function get_admin_i18() { |
|
| 131 | + * Returns admin js translations. |
|
| 132 | + * |
|
| 133 | + */ |
|
| 134 | + protected function get_admin_i18() { |
|
| 135 | 135 | global $post; |
| 136 | 136 | |
| 137 | - $date_range = array( |
|
| 138 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
| 139 | - ); |
|
| 137 | + $date_range = array( |
|
| 138 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
| 139 | + ); |
|
| 140 | 140 | |
| 141 | - if ( $date_range['period'] == 'custom' ) { |
|
| 141 | + if ( $date_range['period'] == 'custom' ) { |
|
| 142 | 142 | |
| 143 | - if ( isset( $_GET['from'] ) ) { |
|
| 144 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
| 145 | - } |
|
| 143 | + if ( isset( $_GET['from'] ) ) { |
|
| 144 | + $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - if ( isset( $_GET['to'] ) ) { |
|
| 148 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
| 149 | - } |
|
| 147 | + if ( isset( $_GET['to'] ) ) { |
|
| 148 | + $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | $i18n = array( |
| 154 | 154 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 155 | 155 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
| 156 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
| 157 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
| 158 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
| 159 | - 'date_range' => $date_range, |
|
| 156 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
| 157 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
| 158 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
| 159 | + 'date_range' => $date_range, |
|
| 160 | 160 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
| 161 | 161 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
| 162 | 162 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
| 163 | 163 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
| 164 | 164 | 'tax' => wpinv_tax_amount(), |
| 165 | 165 | 'discount' => 0, |
| 166 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
| 167 | - 'currency' => wpinv_get_currency(), |
|
| 166 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
| 167 | + 'currency' => wpinv_get_currency(), |
|
| 168 | 168 | 'currency_pos' => wpinv_currency_position(), |
| 169 | 169 | 'thousand_sep' => wpinv_thousands_separator(), |
| 170 | 170 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -184,118 +184,118 @@ discard block |
||
| 184 | 184 | 'item_description' => __( 'Item Description', 'invoicing' ), |
| 185 | 185 | 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
| 186 | 186 | 'discount_description' => __( 'Discount Description', 'invoicing' ), |
| 187 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
| 188 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
| 189 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
| 190 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
| 187 | + 'searching' => __( 'Searching', 'invoicing' ), |
|
| 188 | + 'loading' => __( 'Loading...', 'invoicing' ), |
|
| 189 | + 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
| 190 | + 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 193 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 194 | 194 | |
| 195 | - $invoice = new WPInv_Invoice( $post ); |
|
| 196 | - $i18n['save_invoice'] = sprintf( |
|
| 197 | - __( 'Save %s', 'invoicing' ), |
|
| 198 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 199 | - ); |
|
| 195 | + $invoice = new WPInv_Invoice( $post ); |
|
| 196 | + $i18n['save_invoice'] = sprintf( |
|
| 197 | + __( 'Save %s', 'invoicing' ), |
|
| 198 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 199 | + ); |
|
| 200 | 200 | |
| 201 | - $i18n['invoice_description'] = sprintf( |
|
| 202 | - __( '%s Description', 'invoicing' ), |
|
| 203 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 204 | - ); |
|
| 201 | + $i18n['invoice_description'] = sprintf( |
|
| 202 | + __( '%s Description', 'invoicing' ), |
|
| 203 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 204 | + ); |
|
| 205 | 205 | |
| 206 | - } |
|
| 207 | - return $i18n; |
|
| 208 | - } |
|
| 206 | + } |
|
| 207 | + return $i18n; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Change the admin footer text on GetPaid admin pages. |
|
| 212 | - * |
|
| 213 | - * @since 2.0.0 |
|
| 214 | - * @param string $footer_text |
|
| 215 | - * @return string |
|
| 216 | - */ |
|
| 217 | - public function admin_footer_text( $footer_text ) { |
|
| 218 | - global $current_screen; |
|
| 210 | + /** |
|
| 211 | + * Change the admin footer text on GetPaid admin pages. |
|
| 212 | + * |
|
| 213 | + * @since 2.0.0 |
|
| 214 | + * @param string $footer_text |
|
| 215 | + * @return string |
|
| 216 | + */ |
|
| 217 | + public function admin_footer_text( $footer_text ) { |
|
| 218 | + global $current_screen; |
|
| 219 | 219 | |
| 220 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 220 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 221 | 221 | |
| 222 | 222 | if ( ! empty( $current_screen->post_type ) ) { |
| 223 | - $page = $current_screen->post_type; |
|
| 223 | + $page = $current_screen->post_type; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // General styles. |
| 227 | 227 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
| 228 | 228 | |
| 229 | - // Change the footer text |
|
| 230 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
| 231 | - |
|
| 232 | - $rating_url = esc_url( |
|
| 233 | - wp_nonce_url( |
|
| 234 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
| 235 | - 'getpaid-nonce', |
|
| 236 | - 'getpaid-nonce' |
|
| 237 | - ) |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - $footer_text = sprintf( |
|
| 241 | - /* translators: %s: five stars */ |
|
| 242 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
| 243 | - "<a href='$rating_url'>★★★★★</a>" |
|
| 244 | - ); |
|
| 245 | - |
|
| 246 | - } else { |
|
| 247 | - |
|
| 248 | - $footer_text = sprintf( |
|
| 249 | - /* translators: %s: GetPaid */ |
|
| 250 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
| 251 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
| 252 | - ); |
|
| 253 | - |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - return $footer_text; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Redirects to wp.org to rate the plugin. |
|
| 263 | - * |
|
| 264 | - * @since 2.0.0 |
|
| 265 | - */ |
|
| 266 | - public function redirect_to_wordpress_rating_page() { |
|
| 267 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
| 268 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
| 269 | - exit; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * Loads payment form js. |
|
| 274 | - * |
|
| 275 | - */ |
|
| 276 | - protected function load_payment_form_scripts() { |
|
| 229 | + // Change the footer text |
|
| 230 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
| 231 | + |
|
| 232 | + $rating_url = esc_url( |
|
| 233 | + wp_nonce_url( |
|
| 234 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
| 235 | + 'getpaid-nonce', |
|
| 236 | + 'getpaid-nonce' |
|
| 237 | + ) |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + $footer_text = sprintf( |
|
| 241 | + /* translators: %s: five stars */ |
|
| 242 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
| 243 | + "<a href='$rating_url'>★★★★★</a>" |
|
| 244 | + ); |
|
| 245 | + |
|
| 246 | + } else { |
|
| 247 | + |
|
| 248 | + $footer_text = sprintf( |
|
| 249 | + /* translators: %s: GetPaid */ |
|
| 250 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
| 251 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
| 252 | + ); |
|
| 253 | + |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + return $footer_text; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Redirects to wp.org to rate the plugin. |
|
| 263 | + * |
|
| 264 | + * @since 2.0.0 |
|
| 265 | + */ |
|
| 266 | + public function redirect_to_wordpress_rating_page() { |
|
| 267 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
| 268 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
| 269 | + exit; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * Loads payment form js. |
|
| 274 | + * |
|
| 275 | + */ |
|
| 276 | + protected function load_payment_form_scripts() { |
|
| 277 | 277 | global $post; |
| 278 | 278 | |
| 279 | 279 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
| 280 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 281 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 280 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 281 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 282 | 282 | |
| 283 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 284 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 283 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 284 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 285 | 285 | |
| 286 | - wp_localize_script( |
|
| 286 | + wp_localize_script( |
|
| 287 | 287 | 'wpinv-admin-payment-form-script', |
| 288 | 288 | 'wpinvPaymentFormAdmin', |
| 289 | 289 | array( |
| 290 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 291 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 292 | - 'currency' => wpinv_currency_symbol(), |
|
| 293 | - 'position' => wpinv_currency_position(), |
|
| 294 | - 'decimals' => (int) wpinv_decimals(), |
|
| 295 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
| 296 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
| 297 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 298 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
| 290 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 291 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 292 | + 'currency' => wpinv_currency_symbol(), |
|
| 293 | + 'position' => wpinv_currency_position(), |
|
| 294 | + 'decimals' => (int) wpinv_decimals(), |
|
| 295 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
| 296 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
| 297 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 298 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
| 299 | 299 | ) |
| 300 | 300 | ); |
| 301 | 301 | |
@@ -304,20 +304,20 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * Add our classes to admin pages. |
|
| 307 | + * Add our classes to admin pages. |
|
| 308 | 308 | * |
| 309 | 309 | * @param string $classes |
| 310 | 310 | * @return string |
| 311 | - * |
|
| 312 | - */ |
|
| 311 | + * |
|
| 312 | + */ |
|
| 313 | 313 | public function admin_body_class( $classes ) { |
| 314 | - global $pagenow, $post, $current_screen; |
|
| 314 | + global $pagenow, $post, $current_screen; |
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | 317 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
| 318 | 318 | |
| 319 | 319 | if ( ! empty( $current_screen->post_type ) ) { |
| 320 | - $page = $current_screen->post_type; |
|
| 320 | + $page = $current_screen->post_type; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -326,68 +326,68 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
| 328 | 328 | $classes .= ' wpinv-cpt wpinv'; |
| 329 | - } |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 331 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 332 | 332 | $classes .= ' getpaid-is-invoice-cpt'; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - return $classes; |
|
| 335 | + return $classes; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Maybe show the AyeCode Connect Notice. |
|
| 340 | - */ |
|
| 341 | - public function init_ayecode_connect_helper(){ |
|
| 339 | + * Maybe show the AyeCode Connect Notice. |
|
| 340 | + */ |
|
| 341 | + public function init_ayecode_connect_helper(){ |
|
| 342 | 342 | |
| 343 | - // Register with the deactivation survey class. |
|
| 344 | - AyeCode_Deactivation_Survey::instance(array( |
|
| 345 | - 'slug' => 'invoicing', |
|
| 346 | - 'version' => WPINV_VERSION, |
|
| 347 | - 'support_url' => 'https://wpgetpaid.com/support/', |
|
| 348 | - 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
| 349 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
| 350 | - )); |
|
| 343 | + // Register with the deactivation survey class. |
|
| 344 | + AyeCode_Deactivation_Survey::instance(array( |
|
| 345 | + 'slug' => 'invoicing', |
|
| 346 | + 'version' => WPINV_VERSION, |
|
| 347 | + 'support_url' => 'https://wpgetpaid.com/support/', |
|
| 348 | + 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
| 349 | + 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
| 350 | + )); |
|
| 351 | 351 | |
| 352 | 352 | new AyeCode_Connect_Helper( |
| 353 | 353 | array( |
| 354 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 355 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 356 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 357 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 358 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 359 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 360 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 354 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 355 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 356 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 357 | + 'connect_button' => __("Connect Site","invoicing"), |
|
| 358 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
| 359 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 360 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 361 | 361 | ), |
| 362 | 362 | array( 'wpi-addons' ) |
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * Redirect users to settings on activation. |
|
| 369 | - * |
|
| 370 | - * @return void |
|
| 371 | - */ |
|
| 372 | - public function activation_redirect() { |
|
| 367 | + /** |
|
| 368 | + * Redirect users to settings on activation. |
|
| 369 | + * |
|
| 370 | + * @return void |
|
| 371 | + */ |
|
| 372 | + public function activation_redirect() { |
|
| 373 | 373 | |
| 374 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
| 374 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
| 375 | 375 | |
| 376 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
| 377 | - return; |
|
| 378 | - } |
|
| 376 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
| 377 | + return; |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - // Bail if activating from network, or bulk |
|
| 381 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 382 | - return; |
|
| 383 | - } |
|
| 380 | + // Bail if activating from network, or bulk |
|
| 381 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 382 | + return; |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
| 385 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
| 386 | 386 | |
| 387 | 387 | wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
| 388 | 388 | exit; |
| 389 | 389 | |
| 390 | - } |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | 393 | * Fires an admin action after verifying that a user can fire them. |
@@ -401,459 +401,459 @@ discard block |
||
| 401 | 401 | |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - /** |
|
| 404 | + /** |
|
| 405 | 405 | * Sends a payment reminder to a customer. |
| 406 | - * |
|
| 407 | - * @param array $args |
|
| 406 | + * |
|
| 407 | + * @param array $args |
|
| 408 | 408 | */ |
| 409 | 409 | public function send_customer_invoice( $args ) { |
| 410 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
| 410 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
| 411 | 411 | |
| 412 | - if ( $sent ) { |
|
| 413 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 414 | - } else { |
|
| 415 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
| 416 | - } |
|
| 412 | + if ( $sent ) { |
|
| 413 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 414 | + } else { |
|
| 415 | + $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 419 | - exit; |
|
| 420 | - } |
|
| 418 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 419 | + exit; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - /** |
|
| 422 | + /** |
|
| 423 | 423 | * Sends a payment reminder to a customer. |
| 424 | - * |
|
| 425 | - * @param array $args |
|
| 424 | + * |
|
| 425 | + * @param array $args |
|
| 426 | 426 | */ |
| 427 | 427 | public function send_customer_payment_reminder( $args ) { |
| 428 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 428 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 429 | 429 | |
| 430 | - if ( $sent ) { |
|
| 431 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 432 | - } else { |
|
| 433 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 434 | - } |
|
| 430 | + if ( $sent ) { |
|
| 431 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 432 | + } else { |
|
| 433 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 437 | - exit; |
|
| 438 | - } |
|
| 436 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 437 | + exit; |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - /** |
|
| 440 | + /** |
|
| 441 | 441 | * Resets tax rates. |
| 442 | - * |
|
| 442 | + * |
|
| 443 | 443 | */ |
| 444 | 444 | public function admin_reset_tax_rates() { |
| 445 | 445 | |
| 446 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 447 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 448 | - exit; |
|
| 446 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 447 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 448 | + exit; |
|
| 449 | 449 | |
| 450 | - } |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - /** |
|
| 452 | + /** |
|
| 453 | 453 | * Resets admin pages. |
| 454 | - * |
|
| 454 | + * |
|
| 455 | 455 | */ |
| 456 | 456 | public function admin_create_missing_pages() { |
| 457 | - $installer = new GetPaid_Installer(); |
|
| 458 | - $installer->create_pages(); |
|
| 459 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
| 460 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 461 | - exit; |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - /** |
|
| 457 | + $installer = new GetPaid_Installer(); |
|
| 458 | + $installer->create_pages(); |
|
| 459 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
| 460 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 461 | + exit; |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | 465 | * Creates an missing admin tables. |
| 466 | - * |
|
| 466 | + * |
|
| 467 | 467 | */ |
| 468 | 468 | public function admin_create_missing_tables() { |
| 469 | - global $wpdb; |
|
| 470 | - $installer = new GetPaid_Installer(); |
|
| 469 | + global $wpdb; |
|
| 470 | + $installer = new GetPaid_Installer(); |
|
| 471 | 471 | |
| 472 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
| 473 | - $installer->create_subscriptions_table(); |
|
| 472 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
| 473 | + $installer->create_subscriptions_table(); |
|
| 474 | 474 | |
| 475 | - if ( $wpdb->last_error !== '' ) { |
|
| 476 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 477 | - } |
|
| 478 | - } |
|
| 475 | + if ( $wpdb->last_error !== '' ) { |
|
| 476 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 477 | + } |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
| 481 | - $installer->create_invoices_table(); |
|
| 480 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
| 481 | + $installer->create_invoices_table(); |
|
| 482 | 482 | |
| 483 | - if ( $wpdb->last_error !== '' ) { |
|
| 484 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 485 | - } |
|
| 486 | - } |
|
| 483 | + if ( $wpdb->last_error !== '' ) { |
|
| 484 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
| 489 | - $installer->create_invoice_items_table(); |
|
| 488 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
| 489 | + $installer->create_invoice_items_table(); |
|
| 490 | 490 | |
| 491 | - if ( $wpdb->last_error !== '' ) { |
|
| 492 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 493 | - } |
|
| 494 | - } |
|
| 491 | + if ( $wpdb->last_error !== '' ) { |
|
| 492 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - if ( ! $this->has_notices() ) { |
|
| 497 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
| 498 | - } |
|
| 496 | + if ( ! $this->has_notices() ) { |
|
| 497 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 501 | - exit; |
|
| 502 | - } |
|
| 500 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 501 | + exit; |
|
| 502 | + } |
|
| 503 | 503 | |
| 504 | - /** |
|
| 504 | + /** |
|
| 505 | 505 | * Migrates old invoices to the new database tables. |
| 506 | - * |
|
| 506 | + * |
|
| 507 | 507 | */ |
| 508 | 508 | public function admin_migrate_old_invoices() { |
| 509 | 509 | |
| 510 | - // Migrate the invoices. |
|
| 511 | - $installer = new GetPaid_Installer(); |
|
| 512 | - $installer->migrate_old_invoices(); |
|
| 510 | + // Migrate the invoices. |
|
| 511 | + $installer = new GetPaid_Installer(); |
|
| 512 | + $installer->migrate_old_invoices(); |
|
| 513 | 513 | |
| 514 | - // Show an admin message. |
|
| 515 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
| 514 | + // Show an admin message. |
|
| 515 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
| 516 | 516 | |
| 517 | - // Redirect the admin. |
|
| 518 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 519 | - exit; |
|
| 517 | + // Redirect the admin. |
|
| 518 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 519 | + exit; |
|
| 520 | 520 | |
| 521 | - } |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - /** |
|
| 523 | + /** |
|
| 524 | 524 | * Download customers. |
| 525 | - * |
|
| 525 | + * |
|
| 526 | 526 | */ |
| 527 | 527 | public function admin_download_customers() { |
| 528 | - global $wpdb; |
|
| 528 | + global $wpdb; |
|
| 529 | 529 | |
| 530 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
| 530 | + $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
| 531 | 531 | |
| 532 | - header( "Content-Type:text/csv" ); |
|
| 533 | - header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
| 532 | + header( "Content-Type:text/csv" ); |
|
| 533 | + header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
| 534 | 534 | |
| 535 | - $post_types = ''; |
|
| 535 | + $post_types = ''; |
|
| 536 | 536 | |
| 537 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 538 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 539 | - } |
|
| 537 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 538 | + $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 541 | + $post_types = rtrim( $post_types, ' OR' ); |
|
| 542 | 542 | |
| 543 | - $customers = $wpdb->get_col( |
|
| 544 | - $wpdb->prepare( |
|
| 545 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" |
|
| 546 | - ) |
|
| 547 | - ); |
|
| 543 | + $customers = $wpdb->get_col( |
|
| 544 | + $wpdb->prepare( |
|
| 545 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" |
|
| 546 | + ) |
|
| 547 | + ); |
|
| 548 | 548 | |
| 549 | - $columns = array( |
|
| 550 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 551 | - 'email' => __( 'Email', 'invoicing' ), |
|
| 552 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 553 | - 'state' => __( 'State', 'invoicing' ), |
|
| 554 | - 'city' => __( 'City', 'invoicing' ), |
|
| 555 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 556 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 557 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 558 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 559 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
| 560 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 561 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
| 562 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
| 563 | - ); |
|
| 549 | + $columns = array( |
|
| 550 | + 'name' => __( 'Name', 'invoicing' ), |
|
| 551 | + 'email' => __( 'Email', 'invoicing' ), |
|
| 552 | + 'country' => __( 'Country', 'invoicing' ), |
|
| 553 | + 'state' => __( 'State', 'invoicing' ), |
|
| 554 | + 'city' => __( 'City', 'invoicing' ), |
|
| 555 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 556 | + 'address' => __( 'Address', 'invoicing' ), |
|
| 557 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
| 558 | + 'company' => __( 'Company', 'invoicing' ), |
|
| 559 | + 'company_id' => __( 'Company ID', 'invoicing' ), |
|
| 560 | + 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 561 | + 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
| 562 | + 'signup' => __( 'Date created', 'invoicing' ), |
|
| 563 | + ); |
|
| 564 | 564 | |
| 565 | - // Output the csv column headers. |
|
| 566 | - fputcsv( $output, array_values( $columns ) ); |
|
| 565 | + // Output the csv column headers. |
|
| 566 | + fputcsv( $output, array_values( $columns ) ); |
|
| 567 | 567 | |
| 568 | - // Loop through |
|
| 569 | - $table = new WPInv_Customers_Table(); |
|
| 570 | - foreach ( $customers as $customer_id ) { |
|
| 568 | + // Loop through |
|
| 569 | + $table = new WPInv_Customers_Table(); |
|
| 570 | + foreach ( $customers as $customer_id ) { |
|
| 571 | 571 | |
| 572 | - $user = get_user_by( 'id', $customer_id ); |
|
| 573 | - $row = array(); |
|
| 574 | - if ( empty( $user ) ) { |
|
| 575 | - continue; |
|
| 576 | - } |
|
| 572 | + $user = get_user_by( 'id', $customer_id ); |
|
| 573 | + $row = array(); |
|
| 574 | + if ( empty( $user ) ) { |
|
| 575 | + continue; |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - foreach ( array_keys( $columns ) as $column ) { |
|
| 578 | + foreach ( array_keys( $columns ) as $column ) { |
|
| 579 | 579 | |
| 580 | - $method = 'column_' . $column; |
|
| 580 | + $method = 'column_' . $column; |
|
| 581 | 581 | |
| 582 | - if ( 'name' == $column ) { |
|
| 583 | - $value = sanitize_text_field( $user->display_name ); |
|
| 584 | - } else if( 'email' == $column ) { |
|
| 585 | - $value = sanitize_email( $user->user_email ); |
|
| 586 | - } else if ( is_callable( array( $table, $method ) ) ) { |
|
| 587 | - $value = strip_tags( $table->$method( $user ) ); |
|
| 588 | - } |
|
| 582 | + if ( 'name' == $column ) { |
|
| 583 | + $value = sanitize_text_field( $user->display_name ); |
|
| 584 | + } else if( 'email' == $column ) { |
|
| 585 | + $value = sanitize_email( $user->user_email ); |
|
| 586 | + } else if ( is_callable( array( $table, $method ) ) ) { |
|
| 587 | + $value = strip_tags( $table->$method( $user ) ); |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - if ( empty( $value ) ) { |
|
| 591 | - $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
| 592 | - } |
|
| 590 | + if ( empty( $value ) ) { |
|
| 591 | + $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | - $row[] = $value; |
|
| 594 | + $row[] = $value; |
|
| 595 | 595 | |
| 596 | - } |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | - fputcsv( $output, $row ); |
|
| 599 | - } |
|
| 598 | + fputcsv( $output, $row ); |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | - fclose( $output ); |
|
| 602 | - exit; |
|
| 601 | + fclose( $output ); |
|
| 602 | + exit; |
|
| 603 | 603 | |
| 604 | - } |
|
| 604 | + } |
|
| 605 | 605 | |
| 606 | - /** |
|
| 606 | + /** |
|
| 607 | 607 | * Installs a plugin. |
| 608 | - * |
|
| 609 | - * @param array $data |
|
| 608 | + * |
|
| 609 | + * @param array $data |
|
| 610 | 610 | */ |
| 611 | 611 | public function admin_install_plugin( $data ) { |
| 612 | 612 | |
| 613 | - if ( ! empty( $data['plugins'] ) ) { |
|
| 614 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
| 615 | - wp_cache_flush(); |
|
| 613 | + if ( ! empty( $data['plugins'] ) ) { |
|
| 614 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
| 615 | + wp_cache_flush(); |
|
| 616 | 616 | |
| 617 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
| 618 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
| 619 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
| 620 | - $installed = $upgrader->install( $plugin_zip ); |
|
| 617 | + foreach ( $data['plugins'] as $slug => $file ) { |
|
| 618 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
| 619 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
| 620 | + $installed = $upgrader->install( $plugin_zip ); |
|
| 621 | 621 | |
| 622 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
| 623 | - activate_plugin( $file, '', false, true ); |
|
| 624 | - } else { |
|
| 625 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
| 626 | - } |
|
| 622 | + if ( ! is_wp_error( $installed ) && $installed ) { |
|
| 623 | + activate_plugin( $file, '', false, true ); |
|
| 624 | + } else { |
|
| 625 | + wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - } |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - } |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
| 633 | - wp_safe_redirect( $redirect ); |
|
| 634 | - exit; |
|
| 632 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
| 633 | + wp_safe_redirect( $redirect ); |
|
| 634 | + exit; |
|
| 635 | 635 | |
| 636 | - } |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - /** |
|
| 638 | + /** |
|
| 639 | 639 | * Connects a gateway. |
| 640 | - * |
|
| 641 | - * @param array $data |
|
| 640 | + * |
|
| 641 | + * @param array $data |
|
| 642 | 642 | */ |
| 643 | 643 | public function admin_connect_gateway( $data ) { |
| 644 | 644 | |
| 645 | - if ( ! empty( $data['plugin'] ) ) { |
|
| 645 | + if ( ! empty( $data['plugin'] ) ) { |
|
| 646 | 646 | |
| 647 | - $gateway = sanitize_key( $data['plugin'] ); |
|
| 648 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
| 647 | + $gateway = sanitize_key( $data['plugin'] ); |
|
| 648 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
| 649 | 649 | |
| 650 | - if ( ! empty( $connect_url ) ) { |
|
| 651 | - wp_redirect( $connect_url ); |
|
| 652 | - exit; |
|
| 653 | - } |
|
| 650 | + if ( ! empty( $connect_url ) ) { |
|
| 651 | + wp_redirect( $connect_url ); |
|
| 652 | + exit; |
|
| 653 | + } |
|
| 654 | 654 | |
| 655 | - if ( 'stripe' == $data['plugin'] ) { |
|
| 656 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 655 | + if ( 'stripe' == $data['plugin'] ) { |
|
| 656 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 657 | 657 | |
| 658 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
| 659 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
| 660 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
| 661 | - $upgrader->install( $plugin_zip ); |
|
| 662 | - } |
|
| 658 | + if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
| 659 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
| 660 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
| 661 | + $upgrader->install( $plugin_zip ); |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
| 665 | - } |
|
| 664 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
| 665 | + } |
|
| 666 | 666 | |
| 667 | - if ( ! empty( $connect_url ) ) { |
|
| 668 | - wp_redirect( $connect_url ); |
|
| 669 | - exit; |
|
| 670 | - } |
|
| 667 | + if ( ! empty( $connect_url ) ) { |
|
| 668 | + wp_redirect( $connect_url ); |
|
| 669 | + exit; |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | - } |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
| 675 | - wp_safe_redirect( $redirect ); |
|
| 676 | - exit; |
|
| 674 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
| 675 | + wp_safe_redirect( $redirect ); |
|
| 676 | + exit; |
|
| 677 | 677 | |
| 678 | - } |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - /** |
|
| 680 | + /** |
|
| 681 | 681 | * Recalculates discounts. |
| 682 | - * |
|
| 682 | + * |
|
| 683 | 683 | */ |
| 684 | 684 | public function admin_recalculate_discounts() { |
| 685 | - global $wpdb; |
|
| 685 | + global $wpdb; |
|
| 686 | 686 | |
| 687 | - // Fetch all invoices that have discount codes. |
|
| 688 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 689 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
| 687 | + // Fetch all invoices that have discount codes. |
|
| 688 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 689 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
| 690 | 690 | |
| 691 | - foreach ( $invoices as $invoice ) { |
|
| 691 | + foreach ( $invoices as $invoice ) { |
|
| 692 | 692 | |
| 693 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 693 | + $invoice = new WPInv_Invoice( $invoice ); |
|
| 694 | 694 | |
| 695 | - if ( ! $invoice->exists() ) { |
|
| 696 | - continue; |
|
| 697 | - } |
|
| 695 | + if ( ! $invoice->exists() ) { |
|
| 696 | + continue; |
|
| 697 | + } |
|
| 698 | 698 | |
| 699 | - // Abort if the discount does not exist or does not apply here. |
|
| 700 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 701 | - if ( ! $discount->exists() ) { |
|
| 702 | - continue; |
|
| 703 | - } |
|
| 699 | + // Abort if the discount does not exist or does not apply here. |
|
| 700 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 701 | + if ( ! $discount->exists() ) { |
|
| 702 | + continue; |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 706 | - $invoice->recalculate_total(); |
|
| 705 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 706 | + $invoice->recalculate_total(); |
|
| 707 | 707 | |
| 708 | - if ( $invoice->get_total_discount() > 0 ) { |
|
| 709 | - $invoice->save(); |
|
| 710 | - } |
|
| 708 | + if ( $invoice->get_total_discount() > 0 ) { |
|
| 709 | + $invoice->save(); |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - // Show an admin message. |
|
| 715 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
| 714 | + // Show an admin message. |
|
| 715 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
| 716 | 716 | |
| 717 | - // Redirect the admin. |
|
| 718 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 719 | - exit; |
|
| 717 | + // Redirect the admin. |
|
| 718 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 719 | + exit; |
|
| 720 | 720 | |
| 721 | - } |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | 723 | /** |
| 724 | - * Returns an array of admin notices. |
|
| 725 | - * |
|
| 726 | - * @since 1.0.19 |
|
| 724 | + * Returns an array of admin notices. |
|
| 725 | + * |
|
| 726 | + * @since 1.0.19 |
|
| 727 | 727 | * @return array |
| 728 | - */ |
|
| 729 | - public function get_notices() { |
|
| 730 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
| 728 | + */ |
|
| 729 | + public function get_notices() { |
|
| 730 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
| 731 | 731 | return is_array( $notices ) ? $notices : array(); |
| 732 | - } |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | - /** |
|
| 735 | - * Checks if we have any admin notices. |
|
| 736 | - * |
|
| 737 | - * @since 2.0.4 |
|
| 734 | + /** |
|
| 735 | + * Checks if we have any admin notices. |
|
| 736 | + * |
|
| 737 | + * @since 2.0.4 |
|
| 738 | 738 | * @return array |
| 739 | - */ |
|
| 740 | - public function has_notices() { |
|
| 741 | - return count( $this->get_notices() ) > 0; |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - /** |
|
| 745 | - * Clears all admin notices |
|
| 746 | - * |
|
| 747 | - * @access public |
|
| 748 | - * @since 1.0.19 |
|
| 749 | - */ |
|
| 750 | - public function clear_notices() { |
|
| 751 | - delete_option( 'wpinv_admin_notices' ); |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * Saves a new admin notice |
|
| 756 | - * |
|
| 757 | - * @access public |
|
| 758 | - * @since 1.0.19 |
|
| 759 | - */ |
|
| 760 | - public function save_notice( $type, $message ) { |
|
| 761 | - $notices = $this->get_notices(); |
|
| 762 | - |
|
| 763 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 764 | - $notices[ $type ] = array(); |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - $notices[ $type ][] = $message; |
|
| 768 | - |
|
| 769 | - update_option( 'wpinv_admin_notices', $notices ); |
|
| 770 | - } |
|
| 771 | - |
|
| 772 | - /** |
|
| 773 | - * Displays a success notice |
|
| 774 | - * |
|
| 775 | - * @param string $msg The message to qeue. |
|
| 776 | - * @access public |
|
| 777 | - * @since 1.0.19 |
|
| 778 | - */ |
|
| 779 | - public function show_success( $msg ) { |
|
| 780 | - $this->save_notice( 'success', $msg ); |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - /** |
|
| 784 | - * Displays a error notice |
|
| 785 | - * |
|
| 786 | - * @access public |
|
| 787 | - * @param string $msg The message to qeue. |
|
| 788 | - * @since 1.0.19 |
|
| 789 | - */ |
|
| 790 | - public function show_error( $msg ) { |
|
| 791 | - $this->save_notice( 'error', $msg ); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - /** |
|
| 795 | - * Displays a warning notice |
|
| 796 | - * |
|
| 797 | - * @access public |
|
| 798 | - * @param string $msg The message to qeue. |
|
| 799 | - * @since 1.0.19 |
|
| 800 | - */ |
|
| 801 | - public function show_warning( $msg ) { |
|
| 802 | - $this->save_notice( 'warning', $msg ); |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * Displays a info notice |
|
| 807 | - * |
|
| 808 | - * @access public |
|
| 809 | - * @param string $msg The message to qeue. |
|
| 810 | - * @since 1.0.19 |
|
| 811 | - */ |
|
| 812 | - public function show_info( $msg ) { |
|
| 813 | - $this->save_notice( 'info', $msg ); |
|
| 814 | - } |
|
| 815 | - |
|
| 816 | - /** |
|
| 817 | - * Show notices |
|
| 818 | - * |
|
| 819 | - * @access public |
|
| 820 | - * @since 1.0.19 |
|
| 821 | - */ |
|
| 822 | - public function show_notices() { |
|
| 739 | + */ |
|
| 740 | + public function has_notices() { |
|
| 741 | + return count( $this->get_notices() ) > 0; |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Clears all admin notices |
|
| 746 | + * |
|
| 747 | + * @access public |
|
| 748 | + * @since 1.0.19 |
|
| 749 | + */ |
|
| 750 | + public function clear_notices() { |
|
| 751 | + delete_option( 'wpinv_admin_notices' ); |
|
| 752 | + } |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * Saves a new admin notice |
|
| 756 | + * |
|
| 757 | + * @access public |
|
| 758 | + * @since 1.0.19 |
|
| 759 | + */ |
|
| 760 | + public function save_notice( $type, $message ) { |
|
| 761 | + $notices = $this->get_notices(); |
|
| 762 | + |
|
| 763 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 764 | + $notices[ $type ] = array(); |
|
| 765 | + } |
|
| 766 | + |
|
| 767 | + $notices[ $type ][] = $message; |
|
| 768 | + |
|
| 769 | + update_option( 'wpinv_admin_notices', $notices ); |
|
| 770 | + } |
|
| 771 | + |
|
| 772 | + /** |
|
| 773 | + * Displays a success notice |
|
| 774 | + * |
|
| 775 | + * @param string $msg The message to qeue. |
|
| 776 | + * @access public |
|
| 777 | + * @since 1.0.19 |
|
| 778 | + */ |
|
| 779 | + public function show_success( $msg ) { |
|
| 780 | + $this->save_notice( 'success', $msg ); |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + /** |
|
| 784 | + * Displays a error notice |
|
| 785 | + * |
|
| 786 | + * @access public |
|
| 787 | + * @param string $msg The message to qeue. |
|
| 788 | + * @since 1.0.19 |
|
| 789 | + */ |
|
| 790 | + public function show_error( $msg ) { |
|
| 791 | + $this->save_notice( 'error', $msg ); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + /** |
|
| 795 | + * Displays a warning notice |
|
| 796 | + * |
|
| 797 | + * @access public |
|
| 798 | + * @param string $msg The message to qeue. |
|
| 799 | + * @since 1.0.19 |
|
| 800 | + */ |
|
| 801 | + public function show_warning( $msg ) { |
|
| 802 | + $this->save_notice( 'warning', $msg ); |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * Displays a info notice |
|
| 807 | + * |
|
| 808 | + * @access public |
|
| 809 | + * @param string $msg The message to qeue. |
|
| 810 | + * @since 1.0.19 |
|
| 811 | + */ |
|
| 812 | + public function show_info( $msg ) { |
|
| 813 | + $this->save_notice( 'info', $msg ); |
|
| 814 | + } |
|
| 815 | + |
|
| 816 | + /** |
|
| 817 | + * Show notices |
|
| 818 | + * |
|
| 819 | + * @access public |
|
| 820 | + * @since 1.0.19 |
|
| 821 | + */ |
|
| 822 | + public function show_notices() { |
|
| 823 | 823 | |
| 824 | 824 | $notices = $this->get_notices(); |
| 825 | 825 | $this->clear_notices(); |
| 826 | 826 | |
| 827 | - foreach ( $notices as $type => $messages ) { |
|
| 827 | + foreach ( $notices as $type => $messages ) { |
|
| 828 | 828 | |
| 829 | - if ( ! is_array( $messages ) ) { |
|
| 830 | - continue; |
|
| 831 | - } |
|
| 829 | + if ( ! is_array( $messages ) ) { |
|
| 830 | + continue; |
|
| 831 | + } |
|
| 832 | 832 | |
| 833 | 833 | $type = sanitize_key( $type ); |
| 834 | - foreach ( $messages as $message ) { |
|
| 834 | + foreach ( $messages as $message ) { |
|
| 835 | 835 | $message = wp_kses_post( $message ); |
| 836 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
| 836 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
| 842 | - |
|
| 843 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
| 844 | - $url = wp_nonce_url( |
|
| 845 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 846 | - 'getpaid-nonce', |
|
| 847 | - 'getpaid-nonce' |
|
| 848 | - ); |
|
| 849 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
| 850 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
| 851 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
| 852 | - break; |
|
| 853 | - } |
|
| 841 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
| 842 | + |
|
| 843 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
| 844 | + $url = wp_nonce_url( |
|
| 845 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 846 | + 'getpaid-nonce', |
|
| 847 | + 'getpaid-nonce' |
|
| 848 | + ); |
|
| 849 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
| 850 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
| 851 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
| 852 | + break; |
|
| 853 | + } |
|
| 854 | 854 | |
| 855 | - } |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | - } |
|
| 857 | + } |
|
| 858 | 858 | |
| 859 | 859 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * The main admin class. |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Class constructor. |
| 39 | 39 | */ |
| 40 | - public function __construct(){ |
|
| 40 | + public function __construct() { |
|
| 41 | 41 | |
| 42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
| 43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
| 43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
| 44 | 44 | $this->reports = new GetPaid_Reports(); |
| 45 | 45 | |
| 46 | - if ( is_admin() ) { |
|
| 46 | + if (is_admin()) { |
|
| 47 | 47 | $this->init_admin_hooks(); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -54,31 +54,31 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | */ |
| 56 | 56 | private function init_admin_hooks() { |
| 57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
|
| 58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
| 59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
| 60 | - add_action( 'admin_init', array( $this, 'activation_redirect') ); |
|
| 61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
|
| 62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
| 64 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 65 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 66 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
| 67 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
| 68 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
| 69 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
| 70 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
| 71 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
| 72 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
| 73 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
| 74 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
| 75 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts')); |
|
| 58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
| 59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
| 60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
| 61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
| 62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
| 63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
| 64 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
| 65 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
| 66 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
| 67 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
| 68 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
| 69 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
| 70 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
| 71 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
| 72 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
| 73 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
| 74 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
| 75 | + do_action('getpaid_init_admin_hooks', $this); |
|
| 76 | 76 | |
| 77 | 77 | // Setup/welcome |
| 78 | - if ( ! empty( $_GET['page'] ) ) { |
|
| 79 | - switch ( $_GET['page'] ) { |
|
| 78 | + if (!empty($_GET['page'])) { |
|
| 79 | + switch ($_GET['page']) { |
|
| 80 | 80 | case 'gp-setup' : |
| 81 | - include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' ); |
|
| 81 | + include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'); |
|
| 82 | 82 | break; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -92,37 +92,37 @@ discard block |
||
| 92 | 92 | public function enqeue_scripts() { |
| 93 | 93 | global $current_screen, $pagenow; |
| 94 | 94 | |
| 95 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 95 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 96 | 96 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
| 97 | 97 | |
| 98 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 98 | + if (!empty($current_screen->post_type)) { |
|
| 99 | 99 | $page = $current_screen->post_type; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // General styles. |
| 103 | - if ( false !== stripos( $page, 'wpi' ) || 'gp-setup' == $page ) { |
|
| 103 | + if (false !== stripos($page, 'wpi') || 'gp-setup' == $page) { |
|
| 104 | 104 | |
| 105 | 105 | // Styles. |
| 106 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
| 107 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
| 108 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
| 106 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
| 107 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
| 108 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
| 109 | 109 | |
| 110 | 110 | // Scripts. |
| 111 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 111 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
| 112 | 112 | |
| 113 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
| 114 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
| 115 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
| 113 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
| 114 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
| 115 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Payment form scripts. |
| 120 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 120 | + if ('wpi_payment_form' == $page && $editing) { |
|
| 121 | 121 | $this->load_payment_form_scripts(); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 125 | - wp_enqueue_script( 'postbox' ); |
|
| 124 | + if ($page == 'wpinv-subscriptions') { |
|
| 125 | + wp_enqueue_script('postbox'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | } |
@@ -135,32 +135,32 @@ discard block |
||
| 135 | 135 | global $post; |
| 136 | 136 | |
| 137 | 137 | $date_range = array( |
| 138 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
| 138 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days' |
|
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | - if ( $date_range['period'] == 'custom' ) { |
|
| 141 | + if ($date_range['period'] == 'custom') { |
|
| 142 | 142 | |
| 143 | - if ( isset( $_GET['from'] ) ) { |
|
| 144 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
| 143 | + if (isset($_GET['from'])) { |
|
| 144 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ( isset( $_GET['to'] ) ) { |
|
| 148 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
| 147 | + if (isset($_GET['to'])) { |
|
| 148 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $i18n = array( |
| 154 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 155 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
| 156 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
| 157 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
| 158 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
| 154 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 155 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
| 156 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
| 157 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
| 158 | + 'rest_root' => esc_url_raw(rest_url()), |
|
| 159 | 159 | 'date_range' => $date_range, |
| 160 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
| 161 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
| 162 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
| 163 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
| 160 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
| 161 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
| 162 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
| 163 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
| 164 | 164 | 'tax' => wpinv_tax_amount(), |
| 165 | 165 | 'discount' => 0, |
| 166 | 166 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -169,38 +169,38 @@ discard block |
||
| 169 | 169 | 'thousand_sep' => wpinv_thousands_separator(), |
| 170 | 170 | 'decimal_sep' => wpinv_decimal_separator(), |
| 171 | 171 | 'decimals' => wpinv_decimals(), |
| 172 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
| 173 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
| 174 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
| 175 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
| 176 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
| 177 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
| 178 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
| 179 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
| 180 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
| 181 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
| 182 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
| 183 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
| 184 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
| 185 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
| 186 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
| 187 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
| 188 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
| 189 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
| 190 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
| 172 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
| 173 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
| 174 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
| 175 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
| 176 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
| 177 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
| 178 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
| 179 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
| 180 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
| 181 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
| 182 | + 'action_edit' => __('Edit', 'invoicing'), |
|
| 183 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
| 184 | + 'item_description' => __('Item Description', 'invoicing'), |
|
| 185 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
| 186 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
| 187 | + 'searching' => __('Searching', 'invoicing'), |
|
| 188 | + 'loading' => __('Loading...', 'invoicing'), |
|
| 189 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
| 190 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 193 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
| 194 | 194 | |
| 195 | - $invoice = new WPInv_Invoice( $post ); |
|
| 195 | + $invoice = new WPInv_Invoice($post); |
|
| 196 | 196 | $i18n['save_invoice'] = sprintf( |
| 197 | - __( 'Save %s', 'invoicing' ), |
|
| 198 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 197 | + __('Save %s', 'invoicing'), |
|
| 198 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | 201 | $i18n['invoice_description'] = sprintf( |
| 202 | - __( '%s Description', 'invoicing' ), |
|
| 203 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 202 | + __('%s Description', 'invoicing'), |
|
| 203 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | } |
@@ -214,24 +214,24 @@ discard block |
||
| 214 | 214 | * @param string $footer_text |
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | - public function admin_footer_text( $footer_text ) { |
|
| 217 | + public function admin_footer_text($footer_text) { |
|
| 218 | 218 | global $current_screen; |
| 219 | 219 | |
| 220 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 220 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 221 | 221 | |
| 222 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 222 | + if (!empty($current_screen->post_type)) { |
|
| 223 | 223 | $page = $current_screen->post_type; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // General styles. |
| 227 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
| 227 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
| 228 | 228 | |
| 229 | 229 | // Change the footer text |
| 230 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
| 230 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
| 231 | 231 | |
| 232 | - $rating_url = esc_url( |
|
| 232 | + $rating_url = esc_url( |
|
| 233 | 233 | wp_nonce_url( |
| 234 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
| 234 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
| 235 | 235 | 'getpaid-nonce', |
| 236 | 236 | 'getpaid-nonce' |
| 237 | 237 | ) |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $footer_text = sprintf( |
| 241 | 241 | /* translators: %s: five stars */ |
| 242 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
| 242 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
| 243 | 243 | "<a href='$rating_url'>★★★★★</a>" |
| 244 | 244 | ); |
| 245 | 245 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | $footer_text = sprintf( |
| 249 | 249 | /* translators: %s: GetPaid */ |
| 250 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
| 250 | + __('Thank you for using %s!', 'invoicing'), |
|
| 251 | 251 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
| 252 | 252 | ); |
| 253 | 253 | |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | * @since 2.0.0 |
| 265 | 265 | */ |
| 266 | 266 | public function redirect_to_wordpress_rating_page() { |
| 267 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
| 268 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
| 267 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
| 268 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
| 269 | 269 | exit; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -276,30 +276,30 @@ discard block |
||
| 276 | 276 | protected function load_payment_form_scripts() { |
| 277 | 277 | global $post; |
| 278 | 278 | |
| 279 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
| 280 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 281 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 279 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
| 280 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
| 281 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
| 282 | 282 | |
| 283 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 284 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 283 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
| 284 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
| 285 | 285 | |
| 286 | 286 | wp_localize_script( |
| 287 | 287 | 'wpinv-admin-payment-form-script', |
| 288 | 288 | 'wpinvPaymentFormAdmin', |
| 289 | 289 | array( |
| 290 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 291 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 290 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
| 291 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
| 292 | 292 | 'currency' => wpinv_currency_symbol(), |
| 293 | 293 | 'position' => wpinv_currency_position(), |
| 294 | 294 | 'decimals' => (int) wpinv_decimals(), |
| 295 | 295 | 'thousands_sep' => wpinv_thousands_separator(), |
| 296 | 296 | 'decimals_sep' => wpinv_decimal_separator(), |
| 297 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 297 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
| 298 | 298 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
| 299 | 299 | ) |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
| 302 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
| 303 | 303 | |
| 304 | 304 | } |
| 305 | 305 | |
@@ -310,25 +310,25 @@ discard block |
||
| 310 | 310 | * @return string |
| 311 | 311 | * |
| 312 | 312 | */ |
| 313 | - public function admin_body_class( $classes ) { |
|
| 313 | + public function admin_body_class($classes) { |
|
| 314 | 314 | global $pagenow, $post, $current_screen; |
| 315 | 315 | |
| 316 | 316 | |
| 317 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 317 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 318 | 318 | |
| 319 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 319 | + if (!empty($current_screen->post_type)) { |
|
| 320 | 320 | $page = $current_screen->post_type; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
| 324 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
| 323 | + if (false !== stripos($page, 'wpi')) { |
|
| 324 | + $classes .= ' wpi-' . sanitize_key($page); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
| 327 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
| 328 | 328 | $classes .= ' wpinv-cpt wpinv'; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 331 | + if (getpaid_is_invoice_post_type($page)) { |
|
| 332 | 332 | $classes .= ' getpaid-is-invoice-cpt'; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | /** |
| 339 | 339 | * Maybe show the AyeCode Connect Notice. |
| 340 | 340 | */ |
| 341 | - public function init_ayecode_connect_helper(){ |
|
| 341 | + public function init_ayecode_connect_helper() { |
|
| 342 | 342 | |
| 343 | 343 | // Register with the deactivation survey class. |
| 344 | 344 | AyeCode_Deactivation_Survey::instance(array( |
@@ -346,20 +346,20 @@ discard block |
||
| 346 | 346 | 'version' => WPINV_VERSION, |
| 347 | 347 | 'support_url' => 'https://wpgetpaid.com/support/', |
| 348 | 348 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
| 349 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
| 349 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
| 350 | 350 | )); |
| 351 | 351 | |
| 352 | 352 | new AyeCode_Connect_Helper( |
| 353 | 353 | array( |
| 354 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 355 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 356 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 357 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 358 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 359 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 360 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 354 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
| 355 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
| 356 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 357 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
| 358 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
| 359 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
| 360 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
| 361 | 361 | ), |
| 362 | - array( 'wpi-addons' ) |
|
| 362 | + array('wpi-addons') |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | } |
@@ -371,20 +371,20 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | public function activation_redirect() { |
| 373 | 373 | |
| 374 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
| 374 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
| 375 | 375 | |
| 376 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
| 376 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
| 377 | 377 | return; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Bail if activating from network, or bulk |
| 381 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 381 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 382 | 382 | return; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
| 385 | + update_option('wpinv_redirected_to_settings', 1); |
|
| 386 | 386 | |
| 387 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 387 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
| 388 | 388 | exit; |
| 389 | 389 | |
| 390 | 390 | } |
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | */ |
| 395 | 395 | public function maybe_do_admin_action() { |
| 396 | 396 | |
| 397 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 398 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
| 399 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
| 397 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
| 398 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
| 399 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | } |
@@ -406,16 +406,16 @@ discard block |
||
| 406 | 406 | * |
| 407 | 407 | * @param array $args |
| 408 | 408 | */ |
| 409 | - public function send_customer_invoice( $args ) { |
|
| 410 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
| 409 | + public function send_customer_invoice($args) { |
|
| 410 | + $sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
| 411 | 411 | |
| 412 | - if ( $sent ) { |
|
| 413 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 412 | + if ($sent) { |
|
| 413 | + $this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
| 414 | 414 | } else { |
| 415 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
| 415 | + $this->show_error(__('Could not send the invoice to the customer', 'invoicing')); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 418 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
| 419 | 419 | exit; |
| 420 | 420 | } |
| 421 | 421 | |
@@ -424,16 +424,16 @@ discard block |
||
| 424 | 424 | * |
| 425 | 425 | * @param array $args |
| 426 | 426 | */ |
| 427 | - public function send_customer_payment_reminder( $args ) { |
|
| 428 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 427 | + public function send_customer_payment_reminder($args) { |
|
| 428 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
| 429 | 429 | |
| 430 | - if ( $sent ) { |
|
| 431 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 430 | + if ($sent) { |
|
| 431 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
| 432 | 432 | } else { |
| 433 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 433 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 436 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
| 437 | 437 | exit; |
| 438 | 438 | } |
| 439 | 439 | |
@@ -443,8 +443,8 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function admin_reset_tax_rates() { |
| 445 | 445 | |
| 446 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 447 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 446 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
| 447 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
| 448 | 448 | exit; |
| 449 | 449 | |
| 450 | 450 | } |
@@ -456,8 +456,8 @@ discard block |
||
| 456 | 456 | public function admin_create_missing_pages() { |
| 457 | 457 | $installer = new GetPaid_Installer(); |
| 458 | 458 | $installer->create_pages(); |
| 459 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
| 460 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 459 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
| 460 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
| 461 | 461 | exit; |
| 462 | 462 | } |
| 463 | 463 | |
@@ -469,35 +469,35 @@ discard block |
||
| 469 | 469 | global $wpdb; |
| 470 | 470 | $installer = new GetPaid_Installer(); |
| 471 | 471 | |
| 472 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
| 472 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { |
|
| 473 | 473 | $installer->create_subscriptions_table(); |
| 474 | 474 | |
| 475 | - if ( $wpdb->last_error !== '' ) { |
|
| 476 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 475 | + if ($wpdb->last_error !== '') { |
|
| 476 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
| 480 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { |
|
| 481 | 481 | $installer->create_invoices_table(); |
| 482 | 482 | |
| 483 | - if ( $wpdb->last_error !== '' ) { |
|
| 484 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 483 | + if ($wpdb->last_error !== '') { |
|
| 484 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
| 488 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { |
|
| 489 | 489 | $installer->create_invoice_items_table(); |
| 490 | 490 | |
| 491 | - if ( $wpdb->last_error !== '' ) { |
|
| 492 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
| 491 | + if ($wpdb->last_error !== '') { |
|
| 492 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if ( ! $this->has_notices() ) { |
|
| 497 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
| 496 | + if (!$this->has_notices()) { |
|
| 497 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 500 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
| 501 | 501 | exit; |
| 502 | 502 | } |
| 503 | 503 | |
@@ -512,10 +512,10 @@ discard block |
||
| 512 | 512 | $installer->migrate_old_invoices(); |
| 513 | 513 | |
| 514 | 514 | // Show an admin message. |
| 515 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
| 515 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
| 516 | 516 | |
| 517 | 517 | // Redirect the admin. |
| 518 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 518 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
| 519 | 519 | exit; |
| 520 | 520 | |
| 521 | 521 | } |
@@ -527,18 +527,18 @@ discard block |
||
| 527 | 527 | public function admin_download_customers() { |
| 528 | 528 | global $wpdb; |
| 529 | 529 | |
| 530 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
| 530 | + $output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing')); |
|
| 531 | 531 | |
| 532 | - header( "Content-Type:text/csv" ); |
|
| 533 | - header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
| 532 | + header("Content-Type:text/csv"); |
|
| 533 | + header("Content-Disposition:attachment;filename=customers.csv"); |
|
| 534 | 534 | |
| 535 | 535 | $post_types = ''; |
| 536 | 536 | |
| 537 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 538 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 537 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
| 538 | + $post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 541 | + $post_types = rtrim($post_types, ' OR'); |
|
| 542 | 542 | |
| 543 | 543 | $customers = $wpdb->get_col( |
| 544 | 544 | $wpdb->prepare( |
@@ -547,58 +547,58 @@ discard block |
||
| 547 | 547 | ); |
| 548 | 548 | |
| 549 | 549 | $columns = array( |
| 550 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 551 | - 'email' => __( 'Email', 'invoicing' ), |
|
| 552 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 553 | - 'state' => __( 'State', 'invoicing' ), |
|
| 554 | - 'city' => __( 'City', 'invoicing' ), |
|
| 555 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 556 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 557 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 558 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 559 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
| 560 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 561 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
| 562 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
| 550 | + 'name' => __('Name', 'invoicing'), |
|
| 551 | + 'email' => __('Email', 'invoicing'), |
|
| 552 | + 'country' => __('Country', 'invoicing'), |
|
| 553 | + 'state' => __('State', 'invoicing'), |
|
| 554 | + 'city' => __('City', 'invoicing'), |
|
| 555 | + 'zip' => __('ZIP', 'invoicing'), |
|
| 556 | + 'address' => __('Address', 'invoicing'), |
|
| 557 | + 'phone' => __('Phone', 'invoicing'), |
|
| 558 | + 'company' => __('Company', 'invoicing'), |
|
| 559 | + 'company_id' => __('Company ID', 'invoicing'), |
|
| 560 | + 'invoices' => __('Invoices', 'invoicing'), |
|
| 561 | + 'total_raw' => __('Total Spend', 'invoicing'), |
|
| 562 | + 'signup' => __('Date created', 'invoicing'), |
|
| 563 | 563 | ); |
| 564 | 564 | |
| 565 | 565 | // Output the csv column headers. |
| 566 | - fputcsv( $output, array_values( $columns ) ); |
|
| 566 | + fputcsv($output, array_values($columns)); |
|
| 567 | 567 | |
| 568 | 568 | // Loop through |
| 569 | 569 | $table = new WPInv_Customers_Table(); |
| 570 | - foreach ( $customers as $customer_id ) { |
|
| 570 | + foreach ($customers as $customer_id) { |
|
| 571 | 571 | |
| 572 | - $user = get_user_by( 'id', $customer_id ); |
|
| 572 | + $user = get_user_by('id', $customer_id); |
|
| 573 | 573 | $row = array(); |
| 574 | - if ( empty( $user ) ) { |
|
| 574 | + if (empty($user)) { |
|
| 575 | 575 | continue; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - foreach ( array_keys( $columns ) as $column ) { |
|
| 578 | + foreach (array_keys($columns) as $column) { |
|
| 579 | 579 | |
| 580 | 580 | $method = 'column_' . $column; |
| 581 | 581 | |
| 582 | - if ( 'name' == $column ) { |
|
| 583 | - $value = sanitize_text_field( $user->display_name ); |
|
| 584 | - } else if( 'email' == $column ) { |
|
| 585 | - $value = sanitize_email( $user->user_email ); |
|
| 586 | - } else if ( is_callable( array( $table, $method ) ) ) { |
|
| 587 | - $value = strip_tags( $table->$method( $user ) ); |
|
| 582 | + if ('name' == $column) { |
|
| 583 | + $value = sanitize_text_field($user->display_name); |
|
| 584 | + } else if ('email' == $column) { |
|
| 585 | + $value = sanitize_email($user->user_email); |
|
| 586 | + } else if (is_callable(array($table, $method))) { |
|
| 587 | + $value = strip_tags($table->$method($user)); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - if ( empty( $value ) ) { |
|
| 591 | - $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
| 590 | + if (empty($value)) { |
|
| 591 | + $value = sanitize_text_field(get_user_meta($user->ID, '_wpinv_' . $column, true)); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | $row[] = $value; |
| 595 | 595 | |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - fputcsv( $output, $row ); |
|
| 598 | + fputcsv($output, $row); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - fclose( $output ); |
|
| 601 | + fclose($output); |
|
| 602 | 602 | exit; |
| 603 | 603 | |
| 604 | 604 | } |
@@ -608,29 +608,29 @@ discard block |
||
| 608 | 608 | * |
| 609 | 609 | * @param array $data |
| 610 | 610 | */ |
| 611 | - public function admin_install_plugin( $data ) { |
|
| 611 | + public function admin_install_plugin($data) { |
|
| 612 | 612 | |
| 613 | - if ( ! empty( $data['plugins'] ) ) { |
|
| 613 | + if (!empty($data['plugins'])) { |
|
| 614 | 614 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 615 | 615 | wp_cache_flush(); |
| 616 | 616 | |
| 617 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
| 618 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
| 619 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
| 620 | - $installed = $upgrader->install( $plugin_zip ); |
|
| 617 | + foreach ($data['plugins'] as $slug => $file) { |
|
| 618 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
| 619 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
| 620 | + $installed = $upgrader->install($plugin_zip); |
|
| 621 | 621 | |
| 622 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
| 623 | - activate_plugin( $file, '', false, true ); |
|
| 622 | + if (!is_wp_error($installed) && $installed) { |
|
| 623 | + activate_plugin($file, '', false, true); |
|
| 624 | 624 | } else { |
| 625 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
| 625 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
| 633 | - wp_safe_redirect( $redirect ); |
|
| 632 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
| 633 | + wp_safe_redirect($redirect); |
|
| 634 | 634 | exit; |
| 635 | 635 | |
| 636 | 636 | } |
@@ -640,39 +640,39 @@ discard block |
||
| 640 | 640 | * |
| 641 | 641 | * @param array $data |
| 642 | 642 | */ |
| 643 | - public function admin_connect_gateway( $data ) { |
|
| 643 | + public function admin_connect_gateway($data) { |
|
| 644 | 644 | |
| 645 | - if ( ! empty( $data['plugin'] ) ) { |
|
| 645 | + if (!empty($data['plugin'])) { |
|
| 646 | 646 | |
| 647 | - $gateway = sanitize_key( $data['plugin'] ); |
|
| 648 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
| 647 | + $gateway = sanitize_key($data['plugin']); |
|
| 648 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
| 649 | 649 | |
| 650 | - if ( ! empty( $connect_url ) ) { |
|
| 651 | - wp_redirect( $connect_url ); |
|
| 650 | + if (!empty($connect_url)) { |
|
| 651 | + wp_redirect($connect_url); |
|
| 652 | 652 | exit; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - if ( 'stripe' == $data['plugin'] ) { |
|
| 655 | + if ('stripe' == $data['plugin']) { |
|
| 656 | 656 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 657 | 657 | |
| 658 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
| 659 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
| 660 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
| 661 | - $upgrader->install( $plugin_zip ); |
|
| 658 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
| 659 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
| 660 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
| 661 | + $upgrader->install($plugin_zip); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
| 664 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - if ( ! empty( $connect_url ) ) { |
|
| 668 | - wp_redirect( $connect_url ); |
|
| 667 | + if (!empty($connect_url)) { |
|
| 668 | + wp_redirect($connect_url); |
|
| 669 | 669 | exit; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
| 675 | - wp_safe_redirect( $redirect ); |
|
| 674 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
| 675 | + wp_safe_redirect($redirect); |
|
| 676 | 676 | exit; |
| 677 | 677 | |
| 678 | 678 | } |
@@ -686,36 +686,36 @@ discard block |
||
| 686 | 686 | |
| 687 | 687 | // Fetch all invoices that have discount codes. |
| 688 | 688 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 689 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
| 689 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
| 690 | 690 | |
| 691 | - foreach ( $invoices as $invoice ) { |
|
| 691 | + foreach ($invoices as $invoice) { |
|
| 692 | 692 | |
| 693 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 693 | + $invoice = new WPInv_Invoice($invoice); |
|
| 694 | 694 | |
| 695 | - if ( ! $invoice->exists() ) { |
|
| 695 | + if (!$invoice->exists()) { |
|
| 696 | 696 | continue; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | // Abort if the discount does not exist or does not apply here. |
| 700 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 701 | - if ( ! $discount->exists() ) { |
|
| 700 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 701 | + if (!$discount->exists()) { |
|
| 702 | 702 | continue; |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 705 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 706 | 706 | $invoice->recalculate_total(); |
| 707 | 707 | |
| 708 | - if ( $invoice->get_total_discount() > 0 ) { |
|
| 708 | + if ($invoice->get_total_discount() > 0) { |
|
| 709 | 709 | $invoice->save(); |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | // Show an admin message. |
| 715 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
| 715 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
| 716 | 716 | |
| 717 | 717 | // Redirect the admin. |
| 718 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
| 718 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
| 719 | 719 | exit; |
| 720 | 720 | |
| 721 | 721 | } |
@@ -727,8 +727,8 @@ discard block |
||
| 727 | 727 | * @return array |
| 728 | 728 | */ |
| 729 | 729 | public function get_notices() { |
| 730 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
| 731 | - return is_array( $notices ) ? $notices : array(); |
|
| 730 | + $notices = get_option('wpinv_admin_notices'); |
|
| 731 | + return is_array($notices) ? $notices : array(); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | /** |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | * @return array |
| 739 | 739 | */ |
| 740 | 740 | public function has_notices() { |
| 741 | - return count( $this->get_notices() ) > 0; |
|
| 741 | + return count($this->get_notices()) > 0; |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | * @since 1.0.19 |
| 749 | 749 | */ |
| 750 | 750 | public function clear_notices() { |
| 751 | - delete_option( 'wpinv_admin_notices' ); |
|
| 751 | + delete_option('wpinv_admin_notices'); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
@@ -757,16 +757,16 @@ discard block |
||
| 757 | 757 | * @access public |
| 758 | 758 | * @since 1.0.19 |
| 759 | 759 | */ |
| 760 | - public function save_notice( $type, $message ) { |
|
| 760 | + public function save_notice($type, $message) { |
|
| 761 | 761 | $notices = $this->get_notices(); |
| 762 | 762 | |
| 763 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 764 | - $notices[ $type ] = array(); |
|
| 763 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
| 764 | + $notices[$type] = array(); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - $notices[ $type ][] = $message; |
|
| 767 | + $notices[$type][] = $message; |
|
| 768 | 768 | |
| 769 | - update_option( 'wpinv_admin_notices', $notices ); |
|
| 769 | + update_option('wpinv_admin_notices', $notices); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | /** |
@@ -776,8 +776,8 @@ discard block |
||
| 776 | 776 | * @access public |
| 777 | 777 | * @since 1.0.19 |
| 778 | 778 | */ |
| 779 | - public function show_success( $msg ) { |
|
| 780 | - $this->save_notice( 'success', $msg ); |
|
| 779 | + public function show_success($msg) { |
|
| 780 | + $this->save_notice('success', $msg); |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | /** |
@@ -787,8 +787,8 @@ discard block |
||
| 787 | 787 | * @param string $msg The message to qeue. |
| 788 | 788 | * @since 1.0.19 |
| 789 | 789 | */ |
| 790 | - public function show_error( $msg ) { |
|
| 791 | - $this->save_notice( 'error', $msg ); |
|
| 790 | + public function show_error($msg) { |
|
| 791 | + $this->save_notice('error', $msg); |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | /** |
@@ -798,8 +798,8 @@ discard block |
||
| 798 | 798 | * @param string $msg The message to qeue. |
| 799 | 799 | * @since 1.0.19 |
| 800 | 800 | */ |
| 801 | - public function show_warning( $msg ) { |
|
| 802 | - $this->save_notice( 'warning', $msg ); |
|
| 801 | + public function show_warning($msg) { |
|
| 802 | + $this->save_notice('warning', $msg); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | /** |
@@ -809,8 +809,8 @@ discard block |
||
| 809 | 809 | * @param string $msg The message to qeue. |
| 810 | 810 | * @since 1.0.19 |
| 811 | 811 | */ |
| 812 | - public function show_info( $msg ) { |
|
| 813 | - $this->save_notice( 'info', $msg ); |
|
| 812 | + public function show_info($msg) { |
|
| 813 | + $this->save_notice('info', $msg); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | /** |
@@ -824,30 +824,30 @@ discard block |
||
| 824 | 824 | $notices = $this->get_notices(); |
| 825 | 825 | $this->clear_notices(); |
| 826 | 826 | |
| 827 | - foreach ( $notices as $type => $messages ) { |
|
| 827 | + foreach ($notices as $type => $messages) { |
|
| 828 | 828 | |
| 829 | - if ( ! is_array( $messages ) ) { |
|
| 829 | + if (!is_array($messages)) { |
|
| 830 | 830 | continue; |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - $type = sanitize_key( $type ); |
|
| 834 | - foreach ( $messages as $message ) { |
|
| 835 | - $message = wp_kses_post( $message ); |
|
| 833 | + $type = sanitize_key($type); |
|
| 834 | + foreach ($messages as $message) { |
|
| 835 | + $message = wp_kses_post($message); |
|
| 836 | 836 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
| 841 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
| 842 | 842 | |
| 843 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
| 844 | - $url = wp_nonce_url( |
|
| 845 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 843 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
| 844 | + $url = wp_nonce_url( |
|
| 845 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
| 846 | 846 | 'getpaid-nonce', |
| 847 | 847 | 'getpaid-nonce' |
| 848 | 848 | ); |
| 849 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
| 850 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
| 849 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
| 850 | + $message2 = __('Generate Pages', 'invoicing'); |
|
| 851 | 851 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
| 852 | 852 | break; |
| 853 | 853 | } |