@@ -11,30 +11,30 @@ discard block |
||
| 11 | 11 | class WPInv_Invoice extends GetPaid_Data { |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Which data store to load. |
|
| 15 | - * |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 14 | + * Which data store to load. |
|
| 15 | + * |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | 18 | protected $data_store_name = 'invoice'; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * This is the name of this object type. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 21 | + * This is the name of this object type. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | 25 | protected $object_type = 'invoice'; |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 29 | - * |
|
| 30 | - * @since 1.0.19 |
|
| 31 | - * @var array |
|
| 32 | - */ |
|
| 33 | - protected $data = array( |
|
| 34 | - 'parent_id' => 0, |
|
| 35 | - 'status' => 'wpi-pending', |
|
| 36 | - 'version' => '', |
|
| 37 | - 'date_created' => null, |
|
| 28 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 29 | + * |
|
| 30 | + * @since 1.0.19 |
|
| 31 | + * @var array |
|
| 32 | + */ |
|
| 33 | + protected $data = array( |
|
| 34 | + 'parent_id' => 0, |
|
| 35 | + 'status' => 'wpi-pending', |
|
| 36 | + 'version' => '', |
|
| 37 | + 'date_created' => null, |
|
| 38 | 38 | 'date_modified' => null, |
| 39 | 39 | 'due_date' => null, |
| 40 | 40 | 'completed_date' => null, |
@@ -76,20 +76,20 @@ discard block |
||
| 76 | 76 | 'transaction_id' => '', |
| 77 | 77 | 'currency' => '', |
| 78 | 78 | 'disable_taxes' => false, |
| 79 | - 'subscription_id' => null, |
|
| 80 | - 'is_viewed' => false, |
|
| 81 | - 'email_cc' => '', |
|
| 82 | - 'template' => 'quantity', // hours, amount only |
|
| 79 | + 'subscription_id' => null, |
|
| 80 | + 'is_viewed' => false, |
|
| 81 | + 'email_cc' => '', |
|
| 82 | + 'template' => 'quantity', // hours, amount only |
|
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * Stores meta in cache for future reads. |
|
| 87 | - * |
|
| 88 | - * A group must be set to to enable caching. |
|
| 89 | - * |
|
| 90 | - * @var string |
|
| 91 | - */ |
|
| 92 | - protected $cache_group = 'getpaid_invoices'; |
|
| 86 | + * Stores meta in cache for future reads. |
|
| 87 | + * |
|
| 88 | + * A group must be set to to enable caching. |
|
| 89 | + * |
|
| 90 | + * @var string |
|
| 91 | + */ |
|
| 92 | + protected $cache_group = 'getpaid_invoices'; |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * Stores a reference to the original WP_Post object |
@@ -103,97 +103,97 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @var int |
| 105 | 105 | */ |
| 106 | - protected $recurring_item = null; |
|
| 106 | + protected $recurring_item = null; |
|
| 107 | 107 | |
| 108 | - /** |
|
| 108 | + /** |
|
| 109 | 109 | * Stores an array of item totals. |
| 110 | - * |
|
| 111 | - * e.g $totals['discount'] = array( |
|
| 112 | - * 'initial' => 10, |
|
| 113 | - * 'recurring' => 10, |
|
| 114 | - * ) |
|
| 110 | + * |
|
| 111 | + * e.g $totals['discount'] = array( |
|
| 112 | + * 'initial' => 10, |
|
| 113 | + * 'recurring' => 10, |
|
| 114 | + * ) |
|
| 115 | 115 | * |
| 116 | 116 | * @var array |
| 117 | 117 | */ |
| 118 | - protected $totals = array(); |
|
| 118 | + protected $totals = array(); |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Stores the status transition information. |
|
| 122 | - * |
|
| 123 | - * @since 1.0.19 |
|
| 124 | - * @var bool |
|
| 125 | - */ |
|
| 126 | - protected $status_transition = false; |
|
| 120 | + /** |
|
| 121 | + * Stores the status transition information. |
|
| 122 | + * |
|
| 123 | + * @since 1.0.19 |
|
| 124 | + * @var bool |
|
| 125 | + */ |
|
| 126 | + protected $status_transition = false; |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 130 | - * |
|
| 131 | - * @param int/string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, number or object to read. |
|
| 132 | - */ |
|
| 129 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 130 | + * |
|
| 131 | + * @param int/string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, number or object to read. |
|
| 132 | + */ |
|
| 133 | 133 | public function __construct( $invoice = false ) { |
| 134 | 134 | |
| 135 | 135 | parent::__construct( $invoice ); |
| 136 | 136 | |
| 137 | - if ( is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 138 | - $this->set_id( $invoice ); |
|
| 139 | - } elseif ( $invoice instanceof self ) { |
|
| 140 | - $this->set_id( $invoice->get_id() ); |
|
| 141 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 142 | - $this->set_id( $invoice->ID ); |
|
| 143 | - } elseif ( is_array( $invoice ) ) { |
|
| 144 | - $this->set_props( $invoice ); |
|
| 145 | - |
|
| 146 | - if ( isset( $invoice['ID'] ) ) { |
|
| 147 | - $this->set_id( $invoice['ID'] ); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_discount_id_by_code( $invoice, 'key' ) ) { |
|
| 151 | - $this->set_id( $invoice_id ); |
|
| 152 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_discount_id_by_code( $invoice, 'number' ) ) { |
|
| 153 | - $this->set_id( $invoice_id ); |
|
| 154 | - } else { |
|
| 155 | - $this->set_object_read( true ); |
|
| 156 | - } |
|
| 137 | + if ( is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 138 | + $this->set_id( $invoice ); |
|
| 139 | + } elseif ( $invoice instanceof self ) { |
|
| 140 | + $this->set_id( $invoice->get_id() ); |
|
| 141 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 142 | + $this->set_id( $invoice->ID ); |
|
| 143 | + } elseif ( is_array( $invoice ) ) { |
|
| 144 | + $this->set_props( $invoice ); |
|
| 145 | + |
|
| 146 | + if ( isset( $invoice['ID'] ) ) { |
|
| 147 | + $this->set_id( $invoice['ID'] ); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_discount_id_by_code( $invoice, 'key' ) ) { |
|
| 151 | + $this->set_id( $invoice_id ); |
|
| 152 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_discount_id_by_code( $invoice, 'number' ) ) { |
|
| 153 | + $this->set_id( $invoice_id ); |
|
| 154 | + } else { |
|
| 155 | + $this->set_object_read( true ); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | // Load the datastore. |
| 159 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 159 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 160 | 160 | |
| 161 | - if ( $this->get_id() > 0 ) { |
|
| 161 | + if ( $this->get_id() > 0 ) { |
|
| 162 | 162 | $this->post = get_post( $this->get_id() ); |
| 163 | 163 | $this->ID = $this->get_id(); |
| 164 | - $this->data_store->read( $this ); |
|
| 164 | + $this->data_store->read( $this ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | - * Given a discount code, it returns a discount id. |
|
| 171 | - * |
|
| 172 | - * |
|
| 173 | - * @static |
|
| 174 | - * @param string $discount_code |
|
| 175 | - * @since 1.0.15 |
|
| 176 | - * @return int |
|
| 177 | - */ |
|
| 178 | - public static function get_discount_id_by_code( $invoice_key_or_number, $field = 'key' ) { |
|
| 170 | + * Given a discount code, it returns a discount id. |
|
| 171 | + * |
|
| 172 | + * |
|
| 173 | + * @static |
|
| 174 | + * @param string $discount_code |
|
| 175 | + * @since 1.0.15 |
|
| 176 | + * @return int |
|
| 177 | + */ |
|
| 178 | + public static function get_discount_id_by_code( $invoice_key_or_number, $field = 'key' ) { |
|
| 179 | 179 | global $wpdb; |
| 180 | 180 | |
| 181 | - // Trim the code. |
|
| 181 | + // Trim the code. |
|
| 182 | 182 | $key = trim( $invoice_key_or_number ); |
| 183 | 183 | |
| 184 | 184 | // Valid fields. |
| 185 | 185 | $fields = array( 'key', 'number' ); |
| 186 | 186 | |
| 187 | - // Ensure a value has been passed. |
|
| 188 | - if ( empty( $key ) || ! in_array( $field, $fields ) ) { |
|
| 189 | - return 0; |
|
| 190 | - } |
|
| 187 | + // Ensure a value has been passed. |
|
| 188 | + if ( empty( $key ) || ! in_array( $field, $fields ) ) { |
|
| 189 | + return 0; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - // Maybe retrieve from the cache. |
|
| 193 | - $invoice_id = wp_cache_get( $key, 'getpaid_invoice_keys_' . $field ); |
|
| 194 | - if ( ! empty( $invoice_id ) ) { |
|
| 195 | - return $invoice_id; |
|
| 196 | - } |
|
| 192 | + // Maybe retrieve from the cache. |
|
| 193 | + $invoice_id = wp_cache_get( $key, 'getpaid_invoice_keys_' . $field ); |
|
| 194 | + if ( ! empty( $invoice_id ) ) { |
|
| 195 | + return $invoice_id; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | // Fetch from the db. |
| 199 | 199 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE $field=%s LIMIT 1", $key ) |
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | - if ( empty( $invoice_id ) ) { |
|
| 205 | - return 0; |
|
| 206 | - } |
|
| 204 | + if ( empty( $invoice_id ) ) { |
|
| 205 | + return 0; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - // Update the cache with our data |
|
| 209 | - wp_cache_set( $key, $invoice_id, 'getpaid_invoice_keys_' . $field ); |
|
| 208 | + // Update the cache with our data |
|
| 209 | + wp_cache_set( $key, $invoice_id, 'getpaid_invoice_keys_' . $field ); |
|
| 210 | 210 | |
| 211 | - return $invoice_id; |
|
| 211 | + return $invoice_id; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -234,53 +234,53 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | - * Get parent invoice ID. |
|
| 238 | - * |
|
| 239 | - * @since 1.0.19 |
|
| 240 | - * @param string $context View or edit context. |
|
| 241 | - * @return int |
|
| 242 | - */ |
|
| 243 | - public function get_parent_id( $context = 'view' ) { |
|
| 244 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 237 | + * Get parent invoice ID. |
|
| 238 | + * |
|
| 239 | + * @since 1.0.19 |
|
| 240 | + * @param string $context View or edit context. |
|
| 241 | + * @return int |
|
| 242 | + */ |
|
| 243 | + public function get_parent_id( $context = 'view' ) { |
|
| 244 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | - * Get parent invoice. |
|
| 249 | - * |
|
| 250 | - * @since 1.0.19 |
|
| 251 | - * @return WPInv_Invoice |
|
| 252 | - */ |
|
| 248 | + * Get parent invoice. |
|
| 249 | + * |
|
| 250 | + * @since 1.0.19 |
|
| 251 | + * @return WPInv_Invoice |
|
| 252 | + */ |
|
| 253 | 253 | public function get_parent_payment() { |
| 254 | 254 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Alias for self::get_parent_payment(). |
|
| 259 | - * |
|
| 260 | - * @since 1.0.19 |
|
| 261 | - * @return WPInv_Invoice |
|
| 262 | - */ |
|
| 258 | + * Alias for self::get_parent_payment(). |
|
| 259 | + * |
|
| 260 | + * @since 1.0.19 |
|
| 261 | + * @return WPInv_Invoice |
|
| 262 | + */ |
|
| 263 | 263 | public function get_parent() { |
| 264 | 264 | return $this->get_parent_payment(); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | - * Get invoice status. |
|
| 269 | - * |
|
| 270 | - * @since 1.0.19 |
|
| 271 | - * @param string $context View or edit context. |
|
| 272 | - * @return string |
|
| 273 | - */ |
|
| 274 | - public function get_status( $context = 'view' ) { |
|
| 275 | - return $this->get_prop( 'status', $context ); |
|
| 268 | + * Get invoice status. |
|
| 269 | + * |
|
| 270 | + * @since 1.0.19 |
|
| 271 | + * @param string $context View or edit context. |
|
| 272 | + * @return string |
|
| 273 | + */ |
|
| 274 | + public function get_status( $context = 'view' ) { |
|
| 275 | + return $this->get_prop( 'status', $context ); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | - * Get invoice status nice name. |
|
| 280 | - * |
|
| 281 | - * @since 1.0.19 |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 279 | + * Get invoice status nice name. |
|
| 280 | + * |
|
| 281 | + * @since 1.0.19 |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | 284 | public function get_status_nicename() { |
| 285 | 285 | $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
| 286 | 286 | |
@@ -294,20 +294,20 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | - * Get plugin version when the invoice was created. |
|
| 298 | - * |
|
| 299 | - * @since 1.0.19 |
|
| 300 | - * @param string $context View or edit context. |
|
| 301 | - * @return string |
|
| 302 | - */ |
|
| 303 | - public function get_version( $context = 'view' ) { |
|
| 304 | - return $this->get_prop( 'version', $context ); |
|
| 305 | - } |
|
| 297 | + * Get plugin version when the invoice was created. |
|
| 298 | + * |
|
| 299 | + * @since 1.0.19 |
|
| 300 | + * @param string $context View or edit context. |
|
| 301 | + * @return string |
|
| 302 | + */ |
|
| 303 | + public function get_version( $context = 'view' ) { |
|
| 304 | + return $this->get_prop( 'version', $context ); |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - /** |
|
| 308 | - * @deprecated |
|
| 309 | - */ |
|
| 310 | - public function get_invoice_date( $formatted = true ) { |
|
| 307 | + /** |
|
| 308 | + * @deprecated |
|
| 309 | + */ |
|
| 310 | + public function get_invoice_date( $formatted = true ) { |
|
| 311 | 311 | $date_completed = $this->get_date_completed(); |
| 312 | 312 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 313 | 313 | |
@@ -324,187 +324,187 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | - * Get date when the invoice was created. |
|
| 328 | - * |
|
| 329 | - * @since 1.0.19 |
|
| 330 | - * @param string $context View or edit context. |
|
| 331 | - * @return string |
|
| 332 | - */ |
|
| 333 | - public function get_date_created( $context = 'view' ) { |
|
| 334 | - return $this->get_prop( 'date_created', $context ); |
|
| 335 | - } |
|
| 327 | + * Get date when the invoice was created. |
|
| 328 | + * |
|
| 329 | + * @since 1.0.19 |
|
| 330 | + * @param string $context View or edit context. |
|
| 331 | + * @return string |
|
| 332 | + */ |
|
| 333 | + public function get_date_created( $context = 'view' ) { |
|
| 334 | + return $this->get_prop( 'date_created', $context ); |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * Alias for self::get_date_created(). |
|
| 339 | - * |
|
| 340 | - * @since 1.0.19 |
|
| 341 | - * @param string $context View or edit context. |
|
| 342 | - * @return string |
|
| 343 | - */ |
|
| 344 | - public function get_created_date( $context = 'view' ) { |
|
| 345 | - return $this->get_date_created( $context ); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * Get GMT date when the invoice was created. |
|
| 350 | - * |
|
| 351 | - * @since 1.0.19 |
|
| 352 | - * @param string $context View or edit context. |
|
| 353 | - * @return string |
|
| 354 | - */ |
|
| 355 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 337 | + /** |
|
| 338 | + * Alias for self::get_date_created(). |
|
| 339 | + * |
|
| 340 | + * @since 1.0.19 |
|
| 341 | + * @param string $context View or edit context. |
|
| 342 | + * @return string |
|
| 343 | + */ |
|
| 344 | + public function get_created_date( $context = 'view' ) { |
|
| 345 | + return $this->get_date_created( $context ); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * Get GMT date when the invoice was created. |
|
| 350 | + * |
|
| 351 | + * @since 1.0.19 |
|
| 352 | + * @param string $context View or edit context. |
|
| 353 | + * @return string |
|
| 354 | + */ |
|
| 355 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 356 | 356 | $date = $this->get_date_created( $context ); |
| 357 | 357 | |
| 358 | 358 | if ( $date ) { |
| 359 | 359 | $date = get_gmt_from_date( $date ); |
| 360 | 360 | } |
| 361 | - return $date; |
|
| 361 | + return $date; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | - * Get date when the invoice was last modified. |
|
| 366 | - * |
|
| 367 | - * @since 1.0.19 |
|
| 368 | - * @param string $context View or edit context. |
|
| 369 | - * @return string |
|
| 370 | - */ |
|
| 371 | - public function get_date_modified( $context = 'view' ) { |
|
| 372 | - return $this->get_prop( 'date_modified', $context ); |
|
| 373 | - } |
|
| 365 | + * Get date when the invoice was last modified. |
|
| 366 | + * |
|
| 367 | + * @since 1.0.19 |
|
| 368 | + * @param string $context View or edit context. |
|
| 369 | + * @return string |
|
| 370 | + */ |
|
| 371 | + public function get_date_modified( $context = 'view' ) { |
|
| 372 | + return $this->get_prop( 'date_modified', $context ); |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - /** |
|
| 376 | - * Alias for self::get_date_modified(). |
|
| 377 | - * |
|
| 378 | - * @since 1.0.19 |
|
| 379 | - * @param string $context View or edit context. |
|
| 380 | - * @return string |
|
| 381 | - */ |
|
| 382 | - public function get_modified_date( $context = 'view' ) { |
|
| 383 | - return $this->get_date_modified( $context ); |
|
| 375 | + /** |
|
| 376 | + * Alias for self::get_date_modified(). |
|
| 377 | + * |
|
| 378 | + * @since 1.0.19 |
|
| 379 | + * @param string $context View or edit context. |
|
| 380 | + * @return string |
|
| 381 | + */ |
|
| 382 | + public function get_modified_date( $context = 'view' ) { |
|
| 383 | + return $this->get_date_modified( $context ); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
| 387 | - * Get GMT date when the invoice was last modified. |
|
| 388 | - * |
|
| 389 | - * @since 1.0.19 |
|
| 390 | - * @param string $context View or edit context. |
|
| 391 | - * @return string |
|
| 392 | - */ |
|
| 393 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 387 | + * Get GMT date when the invoice was last modified. |
|
| 388 | + * |
|
| 389 | + * @since 1.0.19 |
|
| 390 | + * @param string $context View or edit context. |
|
| 391 | + * @return string |
|
| 392 | + */ |
|
| 393 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 394 | 394 | $date = $this->get_date_modified( $context ); |
| 395 | 395 | |
| 396 | 396 | if ( $date ) { |
| 397 | 397 | $date = get_gmt_from_date( $date ); |
| 398 | 398 | } |
| 399 | - return $date; |
|
| 399 | + return $date; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | - * Get the invoice due date. |
|
| 404 | - * |
|
| 405 | - * @since 1.0.19 |
|
| 406 | - * @param string $context View or edit context. |
|
| 407 | - * @return string |
|
| 408 | - */ |
|
| 409 | - public function get_due_date( $context = 'view' ) { |
|
| 410 | - return $this->get_prop( 'due_date', $context ); |
|
| 403 | + * Get the invoice due date. |
|
| 404 | + * |
|
| 405 | + * @since 1.0.19 |
|
| 406 | + * @param string $context View or edit context. |
|
| 407 | + * @return string |
|
| 408 | + */ |
|
| 409 | + public function get_due_date( $context = 'view' ) { |
|
| 410 | + return $this->get_prop( 'due_date', $context ); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
| 414 | - * Alias for self::get_due_date(). |
|
| 415 | - * |
|
| 416 | - * @since 1.0.19 |
|
| 417 | - * @param string $context View or edit context. |
|
| 418 | - * @return string |
|
| 419 | - */ |
|
| 420 | - public function get_date_due( $context = 'view' ) { |
|
| 421 | - return $this->get_due_date( $context ); |
|
| 414 | + * Alias for self::get_due_date(). |
|
| 415 | + * |
|
| 416 | + * @since 1.0.19 |
|
| 417 | + * @param string $context View or edit context. |
|
| 418 | + * @return string |
|
| 419 | + */ |
|
| 420 | + public function get_date_due( $context = 'view' ) { |
|
| 421 | + return $this->get_due_date( $context ); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
| 425 | - * Get the invoice GMT due date. |
|
| 426 | - * |
|
| 427 | - * @since 1.0.19 |
|
| 428 | - * @param string $context View or edit context. |
|
| 429 | - * @return string |
|
| 430 | - */ |
|
| 431 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 425 | + * Get the invoice GMT due date. |
|
| 426 | + * |
|
| 427 | + * @since 1.0.19 |
|
| 428 | + * @param string $context View or edit context. |
|
| 429 | + * @return string |
|
| 430 | + */ |
|
| 431 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 432 | 432 | $date = $this->get_due_date( $context ); |
| 433 | 433 | |
| 434 | 434 | if ( $date ) { |
| 435 | 435 | $date = get_gmt_from_date( $date ); |
| 436 | 436 | } |
| 437 | - return $date; |
|
| 437 | + return $date; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
| 441 | - * Alias for self::get_due_date_gmt(). |
|
| 442 | - * |
|
| 443 | - * @since 1.0.19 |
|
| 444 | - * @param string $context View or edit context. |
|
| 445 | - * @return string |
|
| 446 | - */ |
|
| 447 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 448 | - return $this->get_due_date_gmt( $context ); |
|
| 441 | + * Alias for self::get_due_date_gmt(). |
|
| 442 | + * |
|
| 443 | + * @since 1.0.19 |
|
| 444 | + * @param string $context View or edit context. |
|
| 445 | + * @return string |
|
| 446 | + */ |
|
| 447 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 448 | + return $this->get_due_date_gmt( $context ); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
| 452 | - * Get date when the invoice was completed. |
|
| 453 | - * |
|
| 454 | - * @since 1.0.19 |
|
| 455 | - * @param string $context View or edit context. |
|
| 456 | - * @return string |
|
| 457 | - */ |
|
| 458 | - public function get_completed_date( $context = 'view' ) { |
|
| 459 | - return $this->get_prop( 'completed_date', $context ); |
|
| 452 | + * Get date when the invoice was completed. |
|
| 453 | + * |
|
| 454 | + * @since 1.0.19 |
|
| 455 | + * @param string $context View or edit context. |
|
| 456 | + * @return string |
|
| 457 | + */ |
|
| 458 | + public function get_completed_date( $context = 'view' ) { |
|
| 459 | + return $this->get_prop( 'completed_date', $context ); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
| 463 | - * Alias for self::get_completed_date(). |
|
| 464 | - * |
|
| 465 | - * @since 1.0.19 |
|
| 466 | - * @param string $context View or edit context. |
|
| 467 | - * @return string |
|
| 468 | - */ |
|
| 469 | - public function get_date_completed( $context = 'view' ) { |
|
| 470 | - return $this->get_completed_date( $context ); |
|
| 463 | + * Alias for self::get_completed_date(). |
|
| 464 | + * |
|
| 465 | + * @since 1.0.19 |
|
| 466 | + * @param string $context View or edit context. |
|
| 467 | + * @return string |
|
| 468 | + */ |
|
| 469 | + public function get_date_completed( $context = 'view' ) { |
|
| 470 | + return $this->get_completed_date( $context ); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
| 474 | - * Get GMT date when the invoice was was completed. |
|
| 475 | - * |
|
| 476 | - * @since 1.0.19 |
|
| 477 | - * @param string $context View or edit context. |
|
| 478 | - * @return string |
|
| 479 | - */ |
|
| 480 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 474 | + * Get GMT date when the invoice was was completed. |
|
| 475 | + * |
|
| 476 | + * @since 1.0.19 |
|
| 477 | + * @param string $context View or edit context. |
|
| 478 | + * @return string |
|
| 479 | + */ |
|
| 480 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 481 | 481 | $date = $this->get_completed_date( $context ); |
| 482 | 482 | |
| 483 | 483 | if ( $date ) { |
| 484 | 484 | $date = get_gmt_from_date( $date ); |
| 485 | 485 | } |
| 486 | - return $date; |
|
| 486 | + return $date; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | - * Alias for self::get_completed_date_gmt(). |
|
| 491 | - * |
|
| 492 | - * @since 1.0.19 |
|
| 493 | - * @param string $context View or edit context. |
|
| 494 | - * @return string |
|
| 495 | - */ |
|
| 496 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 497 | - return $this->get_completed_date_gmt( $context ); |
|
| 490 | + * Alias for self::get_completed_date_gmt(). |
|
| 491 | + * |
|
| 492 | + * @since 1.0.19 |
|
| 493 | + * @param string $context View or edit context. |
|
| 494 | + * @return string |
|
| 495 | + */ |
|
| 496 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 497 | + return $this->get_completed_date_gmt( $context ); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
| 501 | - * Get the invoice number. |
|
| 502 | - * |
|
| 503 | - * @since 1.0.19 |
|
| 504 | - * @param string $context View or edit context. |
|
| 505 | - * @return string |
|
| 506 | - */ |
|
| 507 | - public function get_number( $context = 'view' ) { |
|
| 501 | + * Get the invoice number. |
|
| 502 | + * |
|
| 503 | + * @since 1.0.19 |
|
| 504 | + * @param string $context View or edit context. |
|
| 505 | + * @return string |
|
| 506 | + */ |
|
| 507 | + public function get_number( $context = 'view' ) { |
|
| 508 | 508 | $number = $this->get_prop( 'number', $context ); |
| 509 | 509 | |
| 510 | 510 | if ( empty( $number ) ) { |
@@ -512,17 +512,17 @@ discard block |
||
| 512 | 512 | $this->set_number( $number ); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - return $number; |
|
| 515 | + return $number; |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | - * Get the invoice key. |
|
| 520 | - * |
|
| 521 | - * @since 1.0.19 |
|
| 522 | - * @param string $context View or edit context. |
|
| 523 | - * @return string |
|
| 524 | - */ |
|
| 525 | - public function get_key( $context = 'view' ) { |
|
| 519 | + * Get the invoice key. |
|
| 520 | + * |
|
| 521 | + * @since 1.0.19 |
|
| 522 | + * @param string $context View or edit context. |
|
| 523 | + * @return string |
|
| 524 | + */ |
|
| 525 | + public function get_key( $context = 'view' ) { |
|
| 526 | 526 | $key = $this->get_prop( 'key', $context ); |
| 527 | 527 | |
| 528 | 528 | if ( empty( $key ) ) { |
@@ -530,24 +530,24 @@ discard block |
||
| 530 | 530 | $this->set_key( $key ); |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - return $key; |
|
| 533 | + return $key; |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
| 537 | - * Get the invoice type. |
|
| 538 | - * |
|
| 539 | - * @since 1.0.19 |
|
| 540 | - * @param string $context View or edit context. |
|
| 541 | - * @return string |
|
| 542 | - */ |
|
| 543 | - public function get_type( $context = 'view' ) { |
|
| 537 | + * Get the invoice type. |
|
| 538 | + * |
|
| 539 | + * @since 1.0.19 |
|
| 540 | + * @param string $context View or edit context. |
|
| 541 | + * @return string |
|
| 542 | + */ |
|
| 543 | + public function get_type( $context = 'view' ) { |
|
| 544 | 544 | return $this->get_prop( 'type', $context ); |
| 545 | - } |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * @deprecated |
|
| 549 | - */ |
|
| 550 | - public function get_invoice_quote_type( $post_id ) { |
|
| 547 | + /** |
|
| 548 | + * @deprecated |
|
| 549 | + */ |
|
| 550 | + public function get_invoice_quote_type( $post_id ) { |
|
| 551 | 551 | if ( empty( $post_id ) ) { |
| 552 | 552 | return ''; |
| 553 | 553 | } |
@@ -564,35 +564,35 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | - * Get the invoice post type. |
|
| 568 | - * |
|
| 569 | - * @since 1.0.19 |
|
| 570 | - * @param string $context View or edit context. |
|
| 571 | - * @return string |
|
| 572 | - */ |
|
| 573 | - public function get_post_type( $context = 'view' ) { |
|
| 567 | + * Get the invoice post type. |
|
| 568 | + * |
|
| 569 | + * @since 1.0.19 |
|
| 570 | + * @param string $context View or edit context. |
|
| 571 | + * @return string |
|
| 572 | + */ |
|
| 573 | + public function get_post_type( $context = 'view' ) { |
|
| 574 | 574 | return $this->get_prop( 'post_type', $context ); |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | - * Get the invoice mode. |
|
| 579 | - * |
|
| 580 | - * @since 1.0.19 |
|
| 581 | - * @param string $context View or edit context. |
|
| 582 | - * @return string |
|
| 583 | - */ |
|
| 584 | - public function get_mode( $context = 'view' ) { |
|
| 578 | + * Get the invoice mode. |
|
| 579 | + * |
|
| 580 | + * @since 1.0.19 |
|
| 581 | + * @param string $context View or edit context. |
|
| 582 | + * @return string |
|
| 583 | + */ |
|
| 584 | + public function get_mode( $context = 'view' ) { |
|
| 585 | 585 | return $this->get_prop( 'mode', $context ); |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
| 589 | - * Get the invoice path. |
|
| 590 | - * |
|
| 591 | - * @since 1.0.19 |
|
| 592 | - * @param string $context View or edit context. |
|
| 593 | - * @return string |
|
| 594 | - */ |
|
| 595 | - public function get_path( $context = 'view' ) { |
|
| 589 | + * Get the invoice path. |
|
| 590 | + * |
|
| 591 | + * @since 1.0.19 |
|
| 592 | + * @param string $context View or edit context. |
|
| 593 | + * @return string |
|
| 594 | + */ |
|
| 595 | + public function get_path( $context = 'view' ) { |
|
| 596 | 596 | $path = $this->get_prop( 'path', $context ); |
| 597 | 597 | |
| 598 | 598 | if ( empty( $path ) ) { |
@@ -600,73 +600,73 @@ discard block |
||
| 600 | 600 | $path = sanitize_title( $prefix . $this->get_id() ); |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - return $path; |
|
| 603 | + return $path; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
| 607 | - * Get the invoice name/title. |
|
| 608 | - * |
|
| 609 | - * @since 1.0.19 |
|
| 610 | - * @param string $context View or edit context. |
|
| 611 | - * @return string |
|
| 612 | - */ |
|
| 613 | - public function get_name( $context = 'view' ) { |
|
| 607 | + * Get the invoice name/title. |
|
| 608 | + * |
|
| 609 | + * @since 1.0.19 |
|
| 610 | + * @param string $context View or edit context. |
|
| 611 | + * @return string |
|
| 612 | + */ |
|
| 613 | + public function get_name( $context = 'view' ) { |
|
| 614 | 614 | $name = $this->get_prop( 'title', $context ); |
| 615 | 615 | |
| 616 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 616 | + return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** |
| 620 | - * Alias of self::get_name(). |
|
| 621 | - * |
|
| 622 | - * @since 1.0.19 |
|
| 623 | - * @param string $context View or edit context. |
|
| 624 | - * @return string |
|
| 625 | - */ |
|
| 626 | - public function get_title( $context = 'view' ) { |
|
| 627 | - return $this->get_name( $context ); |
|
| 620 | + * Alias of self::get_name(). |
|
| 621 | + * |
|
| 622 | + * @since 1.0.19 |
|
| 623 | + * @param string $context View or edit context. |
|
| 624 | + * @return string |
|
| 625 | + */ |
|
| 626 | + public function get_title( $context = 'view' ) { |
|
| 627 | + return $this->get_name( $context ); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
| 631 | - * Get the invoice description. |
|
| 632 | - * |
|
| 633 | - * @since 1.0.19 |
|
| 634 | - * @param string $context View or edit context. |
|
| 635 | - * @return string |
|
| 636 | - */ |
|
| 637 | - public function get_description( $context = 'view' ) { |
|
| 638 | - return $this->get_prop( 'description', $context ); |
|
| 631 | + * Get the invoice description. |
|
| 632 | + * |
|
| 633 | + * @since 1.0.19 |
|
| 634 | + * @param string $context View or edit context. |
|
| 635 | + * @return string |
|
| 636 | + */ |
|
| 637 | + public function get_description( $context = 'view' ) { |
|
| 638 | + return $this->get_prop( 'description', $context ); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | - * Alias of self::get_description(). |
|
| 643 | - * |
|
| 644 | - * @since 1.0.19 |
|
| 645 | - * @param string $context View or edit context. |
|
| 646 | - * @return string |
|
| 647 | - */ |
|
| 648 | - public function get_excerpt( $context = 'view' ) { |
|
| 649 | - return $this->get_description( $context ); |
|
| 642 | + * Alias of self::get_description(). |
|
| 643 | + * |
|
| 644 | + * @since 1.0.19 |
|
| 645 | + * @param string $context View or edit context. |
|
| 646 | + * @return string |
|
| 647 | + */ |
|
| 648 | + public function get_excerpt( $context = 'view' ) { |
|
| 649 | + return $this->get_description( $context ); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | - * Alias of self::get_description(). |
|
| 654 | - * |
|
| 655 | - * @since 1.0.19 |
|
| 656 | - * @param string $context View or edit context. |
|
| 657 | - * @return string |
|
| 658 | - */ |
|
| 659 | - public function get_summary( $context = 'view' ) { |
|
| 660 | - return $this->get_description( $context ); |
|
| 653 | + * Alias of self::get_description(). |
|
| 654 | + * |
|
| 655 | + * @since 1.0.19 |
|
| 656 | + * @param string $context View or edit context. |
|
| 657 | + * @return string |
|
| 658 | + */ |
|
| 659 | + public function get_summary( $context = 'view' ) { |
|
| 660 | + return $this->get_description( $context ); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /** |
| 664 | - * Returns the user info. |
|
| 665 | - * |
|
| 666 | - * @since 1.0.19 |
|
| 664 | + * Returns the user info. |
|
| 665 | + * |
|
| 666 | + * @since 1.0.19 |
|
| 667 | 667 | * @param string $context View or edit context. |
| 668 | - * @return array |
|
| 669 | - */ |
|
| 668 | + * @return array |
|
| 669 | + */ |
|
| 670 | 670 | public function get_user_info( $context = 'view' ) { |
| 671 | 671 | |
| 672 | 672 | $user_info = array( |
@@ -683,605 +683,605 @@ discard block |
||
| 683 | 683 | 'company' => $this->get_company( $context ), |
| 684 | 684 | 'vat_number' => $this->get_vat_number( $context ), |
| 685 | 685 | 'discount' => $this->get_discount_code( $context ), |
| 686 | - ); |
|
| 686 | + ); |
|
| 687 | 687 | |
| 688 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 688 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 689 | 689 | |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
| 693 | - * Get the customer id. |
|
| 694 | - * |
|
| 695 | - * @since 1.0.19 |
|
| 696 | - * @param string $context View or edit context. |
|
| 697 | - * @return int |
|
| 698 | - */ |
|
| 699 | - public function get_author( $context = 'view' ) { |
|
| 700 | - return (int) $this->get_prop( 'author', $context ); |
|
| 693 | + * Get the customer id. |
|
| 694 | + * |
|
| 695 | + * @since 1.0.19 |
|
| 696 | + * @param string $context View or edit context. |
|
| 697 | + * @return int |
|
| 698 | + */ |
|
| 699 | + public function get_author( $context = 'view' ) { |
|
| 700 | + return (int) $this->get_prop( 'author', $context ); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | - * Alias of self::get_author(). |
|
| 705 | - * |
|
| 706 | - * @since 1.0.19 |
|
| 707 | - * @param string $context View or edit context. |
|
| 708 | - * @return int |
|
| 709 | - */ |
|
| 710 | - public function get_user_id( $context = 'view' ) { |
|
| 711 | - return $this->get_author( $context ); |
|
| 704 | + * Alias of self::get_author(). |
|
| 705 | + * |
|
| 706 | + * @since 1.0.19 |
|
| 707 | + * @param string $context View or edit context. |
|
| 708 | + * @return int |
|
| 709 | + */ |
|
| 710 | + public function get_user_id( $context = 'view' ) { |
|
| 711 | + return $this->get_author( $context ); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - /** |
|
| 715 | - * Alias of self::get_author(). |
|
| 716 | - * |
|
| 717 | - * @since 1.0.19 |
|
| 718 | - * @param string $context View or edit context. |
|
| 719 | - * @return int |
|
| 720 | - */ |
|
| 721 | - public function get_customer_id( $context = 'view' ) { |
|
| 722 | - return $this->get_author( $context ); |
|
| 714 | + /** |
|
| 715 | + * Alias of self::get_author(). |
|
| 716 | + * |
|
| 717 | + * @since 1.0.19 |
|
| 718 | + * @param string $context View or edit context. |
|
| 719 | + * @return int |
|
| 720 | + */ |
|
| 721 | + public function get_customer_id( $context = 'view' ) { |
|
| 722 | + return $this->get_author( $context ); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | - * Get the customer's ip. |
|
| 727 | - * |
|
| 728 | - * @since 1.0.19 |
|
| 729 | - * @param string $context View or edit context. |
|
| 730 | - * @return string |
|
| 731 | - */ |
|
| 732 | - public function get_ip( $context = 'view' ) { |
|
| 733 | - return $this->get_prop( 'user_ip', $context ); |
|
| 726 | + * Get the customer's ip. |
|
| 727 | + * |
|
| 728 | + * @since 1.0.19 |
|
| 729 | + * @param string $context View or edit context. |
|
| 730 | + * @return string |
|
| 731 | + */ |
|
| 732 | + public function get_ip( $context = 'view' ) { |
|
| 733 | + return $this->get_prop( 'user_ip', $context ); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | /** |
| 737 | - * Alias of self::get_ip(). |
|
| 738 | - * |
|
| 739 | - * @since 1.0.19 |
|
| 740 | - * @param string $context View or edit context. |
|
| 741 | - * @return string |
|
| 742 | - */ |
|
| 743 | - public function get_user_ip( $context = 'view' ) { |
|
| 744 | - return $this->get_ip( $context ); |
|
| 737 | + * Alias of self::get_ip(). |
|
| 738 | + * |
|
| 739 | + * @since 1.0.19 |
|
| 740 | + * @param string $context View or edit context. |
|
| 741 | + * @return string |
|
| 742 | + */ |
|
| 743 | + public function get_user_ip( $context = 'view' ) { |
|
| 744 | + return $this->get_ip( $context ); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - /** |
|
| 748 | - * Alias of self::get_ip(). |
|
| 749 | - * |
|
| 750 | - * @since 1.0.19 |
|
| 751 | - * @param string $context View or edit context. |
|
| 752 | - * @return string |
|
| 753 | - */ |
|
| 754 | - public function get_customer_ip( $context = 'view' ) { |
|
| 755 | - return $this->get_ip( $context ); |
|
| 747 | + /** |
|
| 748 | + * Alias of self::get_ip(). |
|
| 749 | + * |
|
| 750 | + * @since 1.0.19 |
|
| 751 | + * @param string $context View or edit context. |
|
| 752 | + * @return string |
|
| 753 | + */ |
|
| 754 | + public function get_customer_ip( $context = 'view' ) { |
|
| 755 | + return $this->get_ip( $context ); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | - * Get the customer's first name. |
|
| 760 | - * |
|
| 761 | - * @since 1.0.19 |
|
| 762 | - * @param string $context View or edit context. |
|
| 763 | - * @return string |
|
| 764 | - */ |
|
| 765 | - public function get_first_name( $context = 'view' ) { |
|
| 766 | - return $this->get_prop( 'first_name', $context ); |
|
| 759 | + * Get the customer's first name. |
|
| 760 | + * |
|
| 761 | + * @since 1.0.19 |
|
| 762 | + * @param string $context View or edit context. |
|
| 763 | + * @return string |
|
| 764 | + */ |
|
| 765 | + public function get_first_name( $context = 'view' ) { |
|
| 766 | + return $this->get_prop( 'first_name', $context ); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /** |
| 770 | - * Alias of self::get_first_name(). |
|
| 771 | - * |
|
| 772 | - * @since 1.0.19 |
|
| 773 | - * @param string $context View or edit context. |
|
| 774 | - * @return int |
|
| 775 | - */ |
|
| 776 | - public function get_user_first_name( $context = 'view' ) { |
|
| 777 | - return $this->get_first_name( $context ); |
|
| 770 | + * Alias of self::get_first_name(). |
|
| 771 | + * |
|
| 772 | + * @since 1.0.19 |
|
| 773 | + * @param string $context View or edit context. |
|
| 774 | + * @return int |
|
| 775 | + */ |
|
| 776 | + public function get_user_first_name( $context = 'view' ) { |
|
| 777 | + return $this->get_first_name( $context ); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - /** |
|
| 781 | - * Alias of self::get_first_name(). |
|
| 782 | - * |
|
| 783 | - * @since 1.0.19 |
|
| 784 | - * @param string $context View or edit context. |
|
| 785 | - * @return int |
|
| 786 | - */ |
|
| 787 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 788 | - return $this->get_first_name( $context ); |
|
| 780 | + /** |
|
| 781 | + * Alias of self::get_first_name(). |
|
| 782 | + * |
|
| 783 | + * @since 1.0.19 |
|
| 784 | + * @param string $context View or edit context. |
|
| 785 | + * @return int |
|
| 786 | + */ |
|
| 787 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 788 | + return $this->get_first_name( $context ); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | /** |
| 792 | - * Get the customer's last name. |
|
| 793 | - * |
|
| 794 | - * @since 1.0.19 |
|
| 795 | - * @param string $context View or edit context. |
|
| 796 | - * @return string |
|
| 797 | - */ |
|
| 798 | - public function get_last_name( $context = 'view' ) { |
|
| 799 | - return $this->get_prop( 'last_name', $context ); |
|
| 792 | + * Get the customer's last name. |
|
| 793 | + * |
|
| 794 | + * @since 1.0.19 |
|
| 795 | + * @param string $context View or edit context. |
|
| 796 | + * @return string |
|
| 797 | + */ |
|
| 798 | + public function get_last_name( $context = 'view' ) { |
|
| 799 | + return $this->get_prop( 'last_name', $context ); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | /** |
| 803 | - * Alias of self::get_last_name(). |
|
| 804 | - * |
|
| 805 | - * @since 1.0.19 |
|
| 806 | - * @param string $context View or edit context. |
|
| 807 | - * @return int |
|
| 808 | - */ |
|
| 809 | - public function get_user_last_name( $context = 'view' ) { |
|
| 810 | - return $this->get_last_name( $context ); |
|
| 803 | + * Alias of self::get_last_name(). |
|
| 804 | + * |
|
| 805 | + * @since 1.0.19 |
|
| 806 | + * @param string $context View or edit context. |
|
| 807 | + * @return int |
|
| 808 | + */ |
|
| 809 | + public function get_user_last_name( $context = 'view' ) { |
|
| 810 | + return $this->get_last_name( $context ); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /** |
| 814 | - * Alias of self::get_last_name(). |
|
| 815 | - * |
|
| 816 | - * @since 1.0.19 |
|
| 817 | - * @param string $context View or edit context. |
|
| 818 | - * @return int |
|
| 819 | - */ |
|
| 820 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 821 | - return $this->get_last_name( $context ); |
|
| 814 | + * Alias of self::get_last_name(). |
|
| 815 | + * |
|
| 816 | + * @since 1.0.19 |
|
| 817 | + * @param string $context View or edit context. |
|
| 818 | + * @return int |
|
| 819 | + */ |
|
| 820 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 821 | + return $this->get_last_name( $context ); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | - * Get the customer's full name. |
|
| 826 | - * |
|
| 827 | - * @since 1.0.19 |
|
| 828 | - * @param string $context View or edit context. |
|
| 829 | - * @return string |
|
| 830 | - */ |
|
| 831 | - public function get_full_name( $context = 'view' ) { |
|
| 832 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 825 | + * Get the customer's full name. |
|
| 826 | + * |
|
| 827 | + * @since 1.0.19 |
|
| 828 | + * @param string $context View or edit context. |
|
| 829 | + * @return string |
|
| 830 | + */ |
|
| 831 | + public function get_full_name( $context = 'view' ) { |
|
| 832 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
| 836 | - * Alias of self::get_full_name(). |
|
| 837 | - * |
|
| 838 | - * @since 1.0.19 |
|
| 839 | - * @param string $context View or edit context. |
|
| 840 | - * @return int |
|
| 841 | - */ |
|
| 842 | - public function get_user_full_name( $context = 'view' ) { |
|
| 843 | - return $this->get_full_name( $context ); |
|
| 836 | + * Alias of self::get_full_name(). |
|
| 837 | + * |
|
| 838 | + * @since 1.0.19 |
|
| 839 | + * @param string $context View or edit context. |
|
| 840 | + * @return int |
|
| 841 | + */ |
|
| 842 | + public function get_user_full_name( $context = 'view' ) { |
|
| 843 | + return $this->get_full_name( $context ); |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | /** |
| 847 | - * Alias of self::get_full_name(). |
|
| 848 | - * |
|
| 849 | - * @since 1.0.19 |
|
| 850 | - * @param string $context View or edit context. |
|
| 851 | - * @return int |
|
| 852 | - */ |
|
| 853 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 854 | - return $this->get_full_name( $context ); |
|
| 847 | + * Alias of self::get_full_name(). |
|
| 848 | + * |
|
| 849 | + * @since 1.0.19 |
|
| 850 | + * @param string $context View or edit context. |
|
| 851 | + * @return int |
|
| 852 | + */ |
|
| 853 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 854 | + return $this->get_full_name( $context ); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
| 858 | - * Get the customer's phone number. |
|
| 859 | - * |
|
| 860 | - * @since 1.0.19 |
|
| 861 | - * @param string $context View or edit context. |
|
| 862 | - * @return string |
|
| 863 | - */ |
|
| 864 | - public function get_phone( $context = 'view' ) { |
|
| 865 | - return $this->get_prop( 'phone', $context ); |
|
| 858 | + * Get the customer's phone number. |
|
| 859 | + * |
|
| 860 | + * @since 1.0.19 |
|
| 861 | + * @param string $context View or edit context. |
|
| 862 | + * @return string |
|
| 863 | + */ |
|
| 864 | + public function get_phone( $context = 'view' ) { |
|
| 865 | + return $this->get_prop( 'phone', $context ); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | /** |
| 869 | - * Alias of self::get_phone(). |
|
| 870 | - * |
|
| 871 | - * @since 1.0.19 |
|
| 872 | - * @param string $context View or edit context. |
|
| 873 | - * @return int |
|
| 874 | - */ |
|
| 875 | - public function get_phone_number( $context = 'view' ) { |
|
| 876 | - return $this->get_phone( $context ); |
|
| 869 | + * Alias of self::get_phone(). |
|
| 870 | + * |
|
| 871 | + * @since 1.0.19 |
|
| 872 | + * @param string $context View or edit context. |
|
| 873 | + * @return int |
|
| 874 | + */ |
|
| 875 | + public function get_phone_number( $context = 'view' ) { |
|
| 876 | + return $this->get_phone( $context ); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | /** |
| 880 | - * Alias of self::get_phone(). |
|
| 881 | - * |
|
| 882 | - * @since 1.0.19 |
|
| 883 | - * @param string $context View or edit context. |
|
| 884 | - * @return int |
|
| 885 | - */ |
|
| 886 | - public function get_user_phone( $context = 'view' ) { |
|
| 887 | - return $this->get_phone( $context ); |
|
| 880 | + * Alias of self::get_phone(). |
|
| 881 | + * |
|
| 882 | + * @since 1.0.19 |
|
| 883 | + * @param string $context View or edit context. |
|
| 884 | + * @return int |
|
| 885 | + */ |
|
| 886 | + public function get_user_phone( $context = 'view' ) { |
|
| 887 | + return $this->get_phone( $context ); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
| 891 | - * Alias of self::get_phone(). |
|
| 892 | - * |
|
| 893 | - * @since 1.0.19 |
|
| 894 | - * @param string $context View or edit context. |
|
| 895 | - * @return int |
|
| 896 | - */ |
|
| 897 | - public function get_customer_phone( $context = 'view' ) { |
|
| 898 | - return $this->get_phone( $context ); |
|
| 891 | + * Alias of self::get_phone(). |
|
| 892 | + * |
|
| 893 | + * @since 1.0.19 |
|
| 894 | + * @param string $context View or edit context. |
|
| 895 | + * @return int |
|
| 896 | + */ |
|
| 897 | + public function get_customer_phone( $context = 'view' ) { |
|
| 898 | + return $this->get_phone( $context ); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | /** |
| 902 | - * Get the customer's email address. |
|
| 903 | - * |
|
| 904 | - * @since 1.0.19 |
|
| 905 | - * @param string $context View or edit context. |
|
| 906 | - * @return string |
|
| 907 | - */ |
|
| 908 | - public function get_email( $context = 'view' ) { |
|
| 909 | - return $this->get_prop( 'email', $context ); |
|
| 902 | + * Get the customer's email address. |
|
| 903 | + * |
|
| 904 | + * @since 1.0.19 |
|
| 905 | + * @param string $context View or edit context. |
|
| 906 | + * @return string |
|
| 907 | + */ |
|
| 908 | + public function get_email( $context = 'view' ) { |
|
| 909 | + return $this->get_prop( 'email', $context ); |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
| 913 | - * Alias of self::get_email(). |
|
| 914 | - * |
|
| 915 | - * @since 1.0.19 |
|
| 916 | - * @param string $context View or edit context. |
|
| 917 | - * @return string |
|
| 918 | - */ |
|
| 919 | - public function get_email_address( $context = 'view' ) { |
|
| 920 | - return $this->get_email( $context ); |
|
| 913 | + * Alias of self::get_email(). |
|
| 914 | + * |
|
| 915 | + * @since 1.0.19 |
|
| 916 | + * @param string $context View or edit context. |
|
| 917 | + * @return string |
|
| 918 | + */ |
|
| 919 | + public function get_email_address( $context = 'view' ) { |
|
| 920 | + return $this->get_email( $context ); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | - * Alias of self::get_email(). |
|
| 925 | - * |
|
| 926 | - * @since 1.0.19 |
|
| 927 | - * @param string $context View or edit context. |
|
| 928 | - * @return int |
|
| 929 | - */ |
|
| 930 | - public function get_user_email( $context = 'view' ) { |
|
| 931 | - return $this->get_email( $context ); |
|
| 924 | + * Alias of self::get_email(). |
|
| 925 | + * |
|
| 926 | + * @since 1.0.19 |
|
| 927 | + * @param string $context View or edit context. |
|
| 928 | + * @return int |
|
| 929 | + */ |
|
| 930 | + public function get_user_email( $context = 'view' ) { |
|
| 931 | + return $this->get_email( $context ); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
| 935 | - * Alias of self::get_email(). |
|
| 936 | - * |
|
| 937 | - * @since 1.0.19 |
|
| 938 | - * @param string $context View or edit context. |
|
| 939 | - * @return int |
|
| 940 | - */ |
|
| 941 | - public function get_customer_email( $context = 'view' ) { |
|
| 942 | - return $this->get_email( $context ); |
|
| 935 | + * Alias of self::get_email(). |
|
| 936 | + * |
|
| 937 | + * @since 1.0.19 |
|
| 938 | + * @param string $context View or edit context. |
|
| 939 | + * @return int |
|
| 940 | + */ |
|
| 941 | + public function get_customer_email( $context = 'view' ) { |
|
| 942 | + return $this->get_email( $context ); |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | /** |
| 946 | - * Get the customer's country. |
|
| 947 | - * |
|
| 948 | - * @since 1.0.19 |
|
| 949 | - * @param string $context View or edit context. |
|
| 950 | - * @return string |
|
| 951 | - */ |
|
| 952 | - public function get_country( $context = 'view' ) { |
|
| 953 | - $country = $this->get_prop( 'country', $context ); |
|
| 954 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 946 | + * Get the customer's country. |
|
| 947 | + * |
|
| 948 | + * @since 1.0.19 |
|
| 949 | + * @param string $context View or edit context. |
|
| 950 | + * @return string |
|
| 951 | + */ |
|
| 952 | + public function get_country( $context = 'view' ) { |
|
| 953 | + $country = $this->get_prop( 'country', $context ); |
|
| 954 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | /** |
| 958 | - * Alias of self::get_country(). |
|
| 959 | - * |
|
| 960 | - * @since 1.0.19 |
|
| 961 | - * @param string $context View or edit context. |
|
| 962 | - * @return int |
|
| 963 | - */ |
|
| 964 | - public function get_user_country( $context = 'view' ) { |
|
| 965 | - return $this->get_country( $context ); |
|
| 958 | + * Alias of self::get_country(). |
|
| 959 | + * |
|
| 960 | + * @since 1.0.19 |
|
| 961 | + * @param string $context View or edit context. |
|
| 962 | + * @return int |
|
| 963 | + */ |
|
| 964 | + public function get_user_country( $context = 'view' ) { |
|
| 965 | + return $this->get_country( $context ); |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | /** |
| 969 | - * Alias of self::get_country(). |
|
| 970 | - * |
|
| 971 | - * @since 1.0.19 |
|
| 972 | - * @param string $context View or edit context. |
|
| 973 | - * @return int |
|
| 974 | - */ |
|
| 975 | - public function get_customer_country( $context = 'view' ) { |
|
| 976 | - return $this->get_country( $context ); |
|
| 969 | + * Alias of self::get_country(). |
|
| 970 | + * |
|
| 971 | + * @since 1.0.19 |
|
| 972 | + * @param string $context View or edit context. |
|
| 973 | + * @return int |
|
| 974 | + */ |
|
| 975 | + public function get_customer_country( $context = 'view' ) { |
|
| 976 | + return $this->get_country( $context ); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
| 980 | - * Get the customer's state. |
|
| 981 | - * |
|
| 982 | - * @since 1.0.19 |
|
| 983 | - * @param string $context View or edit context. |
|
| 984 | - * @return string |
|
| 985 | - */ |
|
| 986 | - public function get_state( $context = 'view' ) { |
|
| 987 | - $state = $this->get_prop( 'state', $context ); |
|
| 988 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 980 | + * Get the customer's state. |
|
| 981 | + * |
|
| 982 | + * @since 1.0.19 |
|
| 983 | + * @param string $context View or edit context. |
|
| 984 | + * @return string |
|
| 985 | + */ |
|
| 986 | + public function get_state( $context = 'view' ) { |
|
| 987 | + $state = $this->get_prop( 'state', $context ); |
|
| 988 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /** |
| 992 | - * Alias of self::get_state(). |
|
| 993 | - * |
|
| 994 | - * @since 1.0.19 |
|
| 995 | - * @param string $context View or edit context. |
|
| 996 | - * @return int |
|
| 997 | - */ |
|
| 998 | - public function get_user_state( $context = 'view' ) { |
|
| 999 | - return $this->get_state( $context ); |
|
| 992 | + * Alias of self::get_state(). |
|
| 993 | + * |
|
| 994 | + * @since 1.0.19 |
|
| 995 | + * @param string $context View or edit context. |
|
| 996 | + * @return int |
|
| 997 | + */ |
|
| 998 | + public function get_user_state( $context = 'view' ) { |
|
| 999 | + return $this->get_state( $context ); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
| 1003 | - * Alias of self::get_state(). |
|
| 1004 | - * |
|
| 1005 | - * @since 1.0.19 |
|
| 1006 | - * @param string $context View or edit context. |
|
| 1007 | - * @return int |
|
| 1008 | - */ |
|
| 1009 | - public function get_customer_state( $context = 'view' ) { |
|
| 1010 | - return $this->get_state( $context ); |
|
| 1003 | + * Alias of self::get_state(). |
|
| 1004 | + * |
|
| 1005 | + * @since 1.0.19 |
|
| 1006 | + * @param string $context View or edit context. |
|
| 1007 | + * @return int |
|
| 1008 | + */ |
|
| 1009 | + public function get_customer_state( $context = 'view' ) { |
|
| 1010 | + return $this->get_state( $context ); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
| 1014 | - * Get the customer's city. |
|
| 1015 | - * |
|
| 1016 | - * @since 1.0.19 |
|
| 1017 | - * @param string $context View or edit context. |
|
| 1018 | - * @return string |
|
| 1019 | - */ |
|
| 1020 | - public function get_city( $context = 'view' ) { |
|
| 1021 | - return $this->get_prop( 'city', $context ); |
|
| 1014 | + * Get the customer's city. |
|
| 1015 | + * |
|
| 1016 | + * @since 1.0.19 |
|
| 1017 | + * @param string $context View or edit context. |
|
| 1018 | + * @return string |
|
| 1019 | + */ |
|
| 1020 | + public function get_city( $context = 'view' ) { |
|
| 1021 | + return $this->get_prop( 'city', $context ); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | /** |
| 1025 | - * Alias of self::get_city(). |
|
| 1026 | - * |
|
| 1027 | - * @since 1.0.19 |
|
| 1028 | - * @param string $context View or edit context. |
|
| 1029 | - * @return string |
|
| 1030 | - */ |
|
| 1031 | - public function get_user_city( $context = 'view' ) { |
|
| 1032 | - return $this->get_city( $context ); |
|
| 1025 | + * Alias of self::get_city(). |
|
| 1026 | + * |
|
| 1027 | + * @since 1.0.19 |
|
| 1028 | + * @param string $context View or edit context. |
|
| 1029 | + * @return string |
|
| 1030 | + */ |
|
| 1031 | + public function get_user_city( $context = 'view' ) { |
|
| 1032 | + return $this->get_city( $context ); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | /** |
| 1036 | - * Alias of self::get_city(). |
|
| 1037 | - * |
|
| 1038 | - * @since 1.0.19 |
|
| 1039 | - * @param string $context View or edit context. |
|
| 1040 | - * @return string |
|
| 1041 | - */ |
|
| 1042 | - public function get_customer_city( $context = 'view' ) { |
|
| 1043 | - return $this->get_city( $context ); |
|
| 1036 | + * Alias of self::get_city(). |
|
| 1037 | + * |
|
| 1038 | + * @since 1.0.19 |
|
| 1039 | + * @param string $context View or edit context. |
|
| 1040 | + * @return string |
|
| 1041 | + */ |
|
| 1042 | + public function get_customer_city( $context = 'view' ) { |
|
| 1043 | + return $this->get_city( $context ); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
| 1047 | - * Get the customer's zip. |
|
| 1048 | - * |
|
| 1049 | - * @since 1.0.19 |
|
| 1050 | - * @param string $context View or edit context. |
|
| 1051 | - * @return string |
|
| 1052 | - */ |
|
| 1053 | - public function get_zip( $context = 'view' ) { |
|
| 1054 | - return $this->get_prop( 'zip', $context ); |
|
| 1047 | + * Get the customer's zip. |
|
| 1048 | + * |
|
| 1049 | + * @since 1.0.19 |
|
| 1050 | + * @param string $context View or edit context. |
|
| 1051 | + * @return string |
|
| 1052 | + */ |
|
| 1053 | + public function get_zip( $context = 'view' ) { |
|
| 1054 | + return $this->get_prop( 'zip', $context ); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | /** |
| 1058 | - * Alias of self::get_zip(). |
|
| 1059 | - * |
|
| 1060 | - * @since 1.0.19 |
|
| 1061 | - * @param string $context View or edit context. |
|
| 1062 | - * @return string |
|
| 1063 | - */ |
|
| 1064 | - public function get_user_zip( $context = 'view' ) { |
|
| 1065 | - return $this->get_zip( $context ); |
|
| 1058 | + * Alias of self::get_zip(). |
|
| 1059 | + * |
|
| 1060 | + * @since 1.0.19 |
|
| 1061 | + * @param string $context View or edit context. |
|
| 1062 | + * @return string |
|
| 1063 | + */ |
|
| 1064 | + public function get_user_zip( $context = 'view' ) { |
|
| 1065 | + return $this->get_zip( $context ); |
|
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | /** |
| 1069 | - * Alias of self::get_zip(). |
|
| 1070 | - * |
|
| 1071 | - * @since 1.0.19 |
|
| 1072 | - * @param string $context View or edit context. |
|
| 1073 | - * @return string |
|
| 1074 | - */ |
|
| 1075 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1076 | - return $this->get_zip( $context ); |
|
| 1069 | + * Alias of self::get_zip(). |
|
| 1070 | + * |
|
| 1071 | + * @since 1.0.19 |
|
| 1072 | + * @param string $context View or edit context. |
|
| 1073 | + * @return string |
|
| 1074 | + */ |
|
| 1075 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1076 | + return $this->get_zip( $context ); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | /** |
| 1080 | - * Get the customer's company. |
|
| 1081 | - * |
|
| 1082 | - * @since 1.0.19 |
|
| 1083 | - * @param string $context View or edit context. |
|
| 1084 | - * @return string |
|
| 1085 | - */ |
|
| 1086 | - public function get_company( $context = 'view' ) { |
|
| 1087 | - return $this->get_prop( 'company', $context ); |
|
| 1080 | + * Get the customer's company. |
|
| 1081 | + * |
|
| 1082 | + * @since 1.0.19 |
|
| 1083 | + * @param string $context View or edit context. |
|
| 1084 | + * @return string |
|
| 1085 | + */ |
|
| 1086 | + public function get_company( $context = 'view' ) { |
|
| 1087 | + return $this->get_prop( 'company', $context ); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
| 1091 | - * Alias of self::get_company(). |
|
| 1092 | - * |
|
| 1093 | - * @since 1.0.19 |
|
| 1094 | - * @param string $context View or edit context. |
|
| 1095 | - * @return string |
|
| 1096 | - */ |
|
| 1097 | - public function get_user_company( $context = 'view' ) { |
|
| 1098 | - return $this->get_company( $context ); |
|
| 1091 | + * Alias of self::get_company(). |
|
| 1092 | + * |
|
| 1093 | + * @since 1.0.19 |
|
| 1094 | + * @param string $context View or edit context. |
|
| 1095 | + * @return string |
|
| 1096 | + */ |
|
| 1097 | + public function get_user_company( $context = 'view' ) { |
|
| 1098 | + return $this->get_company( $context ); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | /** |
| 1102 | - * Alias of self::get_company(). |
|
| 1103 | - * |
|
| 1104 | - * @since 1.0.19 |
|
| 1105 | - * @param string $context View or edit context. |
|
| 1106 | - * @return string |
|
| 1107 | - */ |
|
| 1108 | - public function get_customer_company( $context = 'view' ) { |
|
| 1109 | - return $this->get_company( $context ); |
|
| 1102 | + * Alias of self::get_company(). |
|
| 1103 | + * |
|
| 1104 | + * @since 1.0.19 |
|
| 1105 | + * @param string $context View or edit context. |
|
| 1106 | + * @return string |
|
| 1107 | + */ |
|
| 1108 | + public function get_customer_company( $context = 'view' ) { |
|
| 1109 | + return $this->get_company( $context ); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | /** |
| 1113 | - * Get the customer's vat number. |
|
| 1114 | - * |
|
| 1115 | - * @since 1.0.19 |
|
| 1116 | - * @param string $context View or edit context. |
|
| 1117 | - * @return string |
|
| 1118 | - */ |
|
| 1119 | - public function get_vat_number( $context = 'view' ) { |
|
| 1120 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1113 | + * Get the customer's vat number. |
|
| 1114 | + * |
|
| 1115 | + * @since 1.0.19 |
|
| 1116 | + * @param string $context View or edit context. |
|
| 1117 | + * @return string |
|
| 1118 | + */ |
|
| 1119 | + public function get_vat_number( $context = 'view' ) { |
|
| 1120 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
| 1124 | - * Alias of self::get_vat_number(). |
|
| 1125 | - * |
|
| 1126 | - * @since 1.0.19 |
|
| 1127 | - * @param string $context View or edit context. |
|
| 1128 | - * @return string |
|
| 1129 | - */ |
|
| 1130 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1131 | - return $this->get_vat_number( $context ); |
|
| 1124 | + * Alias of self::get_vat_number(). |
|
| 1125 | + * |
|
| 1126 | + * @since 1.0.19 |
|
| 1127 | + * @param string $context View or edit context. |
|
| 1128 | + * @return string |
|
| 1129 | + */ |
|
| 1130 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1131 | + return $this->get_vat_number( $context ); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | /** |
| 1135 | - * Alias of self::get_vat_number(). |
|
| 1136 | - * |
|
| 1137 | - * @since 1.0.19 |
|
| 1138 | - * @param string $context View or edit context. |
|
| 1139 | - * @return string |
|
| 1140 | - */ |
|
| 1141 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1142 | - return $this->get_vat_number( $context ); |
|
| 1135 | + * Alias of self::get_vat_number(). |
|
| 1136 | + * |
|
| 1137 | + * @since 1.0.19 |
|
| 1138 | + * @param string $context View or edit context. |
|
| 1139 | + * @return string |
|
| 1140 | + */ |
|
| 1141 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1142 | + return $this->get_vat_number( $context ); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
| 1146 | - * Get the customer's vat rate. |
|
| 1147 | - * |
|
| 1148 | - * @since 1.0.19 |
|
| 1149 | - * @param string $context View or edit context. |
|
| 1150 | - * @return string |
|
| 1151 | - */ |
|
| 1152 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1153 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1146 | + * Get the customer's vat rate. |
|
| 1147 | + * |
|
| 1148 | + * @since 1.0.19 |
|
| 1149 | + * @param string $context View or edit context. |
|
| 1150 | + * @return string |
|
| 1151 | + */ |
|
| 1152 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1153 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /** |
| 1157 | - * Alias of self::get_vat_rate(). |
|
| 1158 | - * |
|
| 1159 | - * @since 1.0.19 |
|
| 1160 | - * @param string $context View or edit context. |
|
| 1161 | - * @return string |
|
| 1162 | - */ |
|
| 1163 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1164 | - return $this->get_vat_rate( $context ); |
|
| 1157 | + * Alias of self::get_vat_rate(). |
|
| 1158 | + * |
|
| 1159 | + * @since 1.0.19 |
|
| 1160 | + * @param string $context View or edit context. |
|
| 1161 | + * @return string |
|
| 1162 | + */ |
|
| 1163 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1164 | + return $this->get_vat_rate( $context ); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | /** |
| 1168 | - * Alias of self::get_vat_rate(). |
|
| 1169 | - * |
|
| 1170 | - * @since 1.0.19 |
|
| 1171 | - * @param string $context View or edit context. |
|
| 1172 | - * @return string |
|
| 1173 | - */ |
|
| 1174 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1175 | - return $this->get_vat_rate( $context ); |
|
| 1168 | + * Alias of self::get_vat_rate(). |
|
| 1169 | + * |
|
| 1170 | + * @since 1.0.19 |
|
| 1171 | + * @param string $context View or edit context. |
|
| 1172 | + * @return string |
|
| 1173 | + */ |
|
| 1174 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1175 | + return $this->get_vat_rate( $context ); |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + /** |
|
| 1179 | + * Get the customer's address. |
|
| 1180 | + * |
|
| 1181 | + * @since 1.0.19 |
|
| 1182 | + * @param string $context View or edit context. |
|
| 1183 | + * @return string |
|
| 1184 | + */ |
|
| 1185 | + public function get_address( $context = 'view' ) { |
|
| 1186 | + return $this->get_prop( 'address', $context ); |
|
| 1187 | + } |
|
| 1188 | + |
|
| 1189 | + /** |
|
| 1190 | + * Alias of self::get_address(). |
|
| 1191 | + * |
|
| 1192 | + * @since 1.0.19 |
|
| 1193 | + * @param string $context View or edit context. |
|
| 1194 | + * @return string |
|
| 1195 | + */ |
|
| 1196 | + public function get_user_address( $context = 'view' ) { |
|
| 1197 | + return $this->get_address( $context ); |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + /** |
|
| 1201 | + * Alias of self::get_address(). |
|
| 1202 | + * |
|
| 1203 | + * @since 1.0.19 |
|
| 1204 | + * @param string $context View or edit context. |
|
| 1205 | + * @return string |
|
| 1206 | + */ |
|
| 1207 | + public function get_customer_address( $context = 'view' ) { |
|
| 1208 | + return $this->get_address( $context ); |
|
| 1209 | + } |
|
| 1210 | + |
|
| 1211 | + /** |
|
| 1212 | + * Get whether the customer has viewed the invoice or not. |
|
| 1213 | + * |
|
| 1214 | + * @since 1.0.19 |
|
| 1215 | + * @param string $context View or edit context. |
|
| 1216 | + * @return bool |
|
| 1217 | + */ |
|
| 1218 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1219 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + /** |
|
| 1223 | + * Get other recipients for invoice communications. |
|
| 1224 | + * |
|
| 1225 | + * @since 1.0.19 |
|
| 1226 | + * @param string $context View or edit context. |
|
| 1227 | + * @return bool |
|
| 1228 | + */ |
|
| 1229 | + public function get_email_cc( $context = 'view' ) { |
|
| 1230 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1176 | 1231 | } |
| 1177 | 1232 | |
| 1178 | 1233 | /** |
| 1179 | - * Get the customer's address. |
|
| 1180 | - * |
|
| 1181 | - * @since 1.0.19 |
|
| 1182 | - * @param string $context View or edit context. |
|
| 1183 | - * @return string |
|
| 1184 | - */ |
|
| 1185 | - public function get_address( $context = 'view' ) { |
|
| 1186 | - return $this->get_prop( 'address', $context ); |
|
| 1187 | - } |
|
| 1188 | - |
|
| 1189 | - /** |
|
| 1190 | - * Alias of self::get_address(). |
|
| 1191 | - * |
|
| 1192 | - * @since 1.0.19 |
|
| 1193 | - * @param string $context View or edit context. |
|
| 1194 | - * @return string |
|
| 1195 | - */ |
|
| 1196 | - public function get_user_address( $context = 'view' ) { |
|
| 1197 | - return $this->get_address( $context ); |
|
| 1198 | - } |
|
| 1199 | - |
|
| 1200 | - /** |
|
| 1201 | - * Alias of self::get_address(). |
|
| 1202 | - * |
|
| 1203 | - * @since 1.0.19 |
|
| 1204 | - * @param string $context View or edit context. |
|
| 1205 | - * @return string |
|
| 1206 | - */ |
|
| 1207 | - public function get_customer_address( $context = 'view' ) { |
|
| 1208 | - return $this->get_address( $context ); |
|
| 1209 | - } |
|
| 1210 | - |
|
| 1211 | - /** |
|
| 1212 | - * Get whether the customer has viewed the invoice or not. |
|
| 1213 | - * |
|
| 1214 | - * @since 1.0.19 |
|
| 1215 | - * @param string $context View or edit context. |
|
| 1216 | - * @return bool |
|
| 1217 | - */ |
|
| 1218 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1219 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - /** |
|
| 1223 | - * Get other recipients for invoice communications. |
|
| 1224 | - * |
|
| 1225 | - * @since 1.0.19 |
|
| 1226 | - * @param string $context View or edit context. |
|
| 1227 | - * @return bool |
|
| 1228 | - */ |
|
| 1229 | - public function get_email_cc( $context = 'view' ) { |
|
| 1230 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1231 | - } |
|
| 1232 | - |
|
| 1233 | - /** |
|
| 1234 | - * Get invoice template. |
|
| 1235 | - * |
|
| 1236 | - * @since 1.0.19 |
|
| 1237 | - * @param string $context View or edit context. |
|
| 1238 | - * @return bool |
|
| 1239 | - */ |
|
| 1240 | - public function get_template( $context = 'view' ) { |
|
| 1241 | - return $this->get_prop( 'template', $context ); |
|
| 1242 | - } |
|
| 1243 | - |
|
| 1244 | - /** |
|
| 1245 | - * Get whether the customer has confirmed their address. |
|
| 1246 | - * |
|
| 1247 | - * @since 1.0.19 |
|
| 1248 | - * @param string $context View or edit context. |
|
| 1249 | - * @return bool |
|
| 1250 | - */ |
|
| 1251 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1252 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1253 | - } |
|
| 1254 | - |
|
| 1255 | - /** |
|
| 1256 | - * Alias of self::get_address_confirmed(). |
|
| 1257 | - * |
|
| 1258 | - * @since 1.0.19 |
|
| 1259 | - * @param string $context View or edit context. |
|
| 1260 | - * @return bool |
|
| 1261 | - */ |
|
| 1262 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1263 | - return $this->get_address_confirmed( $context ); |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - /** |
|
| 1267 | - * Alias of self::get_address(). |
|
| 1268 | - * |
|
| 1269 | - * @since 1.0.19 |
|
| 1270 | - * @param string $context View or edit context. |
|
| 1271 | - * @return bool |
|
| 1272 | - */ |
|
| 1273 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1274 | - return $this->get_address_confirmed( $context ); |
|
| 1275 | - } |
|
| 1276 | - |
|
| 1277 | - /** |
|
| 1278 | - * Get the invoice subtotal. |
|
| 1279 | - * |
|
| 1280 | - * @since 1.0.19 |
|
| 1281 | - * @param string $context View or edit context. |
|
| 1282 | - * @return float |
|
| 1283 | - */ |
|
| 1284 | - public function get_subtotal( $context = 'view' ) { |
|
| 1234 | + * Get invoice template. |
|
| 1235 | + * |
|
| 1236 | + * @since 1.0.19 |
|
| 1237 | + * @param string $context View or edit context. |
|
| 1238 | + * @return bool |
|
| 1239 | + */ |
|
| 1240 | + public function get_template( $context = 'view' ) { |
|
| 1241 | + return $this->get_prop( 'template', $context ); |
|
| 1242 | + } |
|
| 1243 | + |
|
| 1244 | + /** |
|
| 1245 | + * Get whether the customer has confirmed their address. |
|
| 1246 | + * |
|
| 1247 | + * @since 1.0.19 |
|
| 1248 | + * @param string $context View or edit context. |
|
| 1249 | + * @return bool |
|
| 1250 | + */ |
|
| 1251 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1252 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1253 | + } |
|
| 1254 | + |
|
| 1255 | + /** |
|
| 1256 | + * Alias of self::get_address_confirmed(). |
|
| 1257 | + * |
|
| 1258 | + * @since 1.0.19 |
|
| 1259 | + * @param string $context View or edit context. |
|
| 1260 | + * @return bool |
|
| 1261 | + */ |
|
| 1262 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1263 | + return $this->get_address_confirmed( $context ); |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + /** |
|
| 1267 | + * Alias of self::get_address(). |
|
| 1268 | + * |
|
| 1269 | + * @since 1.0.19 |
|
| 1270 | + * @param string $context View or edit context. |
|
| 1271 | + * @return bool |
|
| 1272 | + */ |
|
| 1273 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1274 | + return $this->get_address_confirmed( $context ); |
|
| 1275 | + } |
|
| 1276 | + |
|
| 1277 | + /** |
|
| 1278 | + * Get the invoice subtotal. |
|
| 1279 | + * |
|
| 1280 | + * @since 1.0.19 |
|
| 1281 | + * @param string $context View or edit context. |
|
| 1282 | + * @return float |
|
| 1283 | + */ |
|
| 1284 | + public function get_subtotal( $context = 'view' ) { |
|
| 1285 | 1285 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1286 | 1286 | |
| 1287 | 1287 | // Backwards compatibility. |
@@ -1293,155 +1293,155 @@ discard block |
||
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | /** |
| 1296 | - * Get the invoice discount total. |
|
| 1297 | - * |
|
| 1298 | - * @since 1.0.19 |
|
| 1299 | - * @param string $context View or edit context. |
|
| 1300 | - * @return float |
|
| 1301 | - */ |
|
| 1302 | - public function get_total_discount( $context = 'view' ) { |
|
| 1303 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1296 | + * Get the invoice discount total. |
|
| 1297 | + * |
|
| 1298 | + * @since 1.0.19 |
|
| 1299 | + * @param string $context View or edit context. |
|
| 1300 | + * @return float |
|
| 1301 | + */ |
|
| 1302 | + public function get_total_discount( $context = 'view' ) { |
|
| 1303 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | /** |
| 1307 | - * Get the invoice tax total. |
|
| 1308 | - * |
|
| 1309 | - * @since 1.0.19 |
|
| 1310 | - * @param string $context View or edit context. |
|
| 1311 | - * @return float |
|
| 1312 | - */ |
|
| 1313 | - public function get_total_tax( $context = 'view' ) { |
|
| 1314 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1315 | - } |
|
| 1307 | + * Get the invoice tax total. |
|
| 1308 | + * |
|
| 1309 | + * @since 1.0.19 |
|
| 1310 | + * @param string $context View or edit context. |
|
| 1311 | + * @return float |
|
| 1312 | + */ |
|
| 1313 | + public function get_total_tax( $context = 'view' ) { |
|
| 1314 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | - /** |
|
| 1318 | - * @deprecated |
|
| 1319 | - */ |
|
| 1320 | - public function get_final_tax( $currency = false ) { |
|
| 1321 | - $tax = $this->get_total_tax(); |
|
| 1317 | + /** |
|
| 1318 | + * @deprecated |
|
| 1319 | + */ |
|
| 1320 | + public function get_final_tax( $currency = false ) { |
|
| 1321 | + $tax = $this->get_total_tax(); |
|
| 1322 | 1322 | |
| 1323 | 1323 | if ( $currency ) { |
| 1324 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1324 | + return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | return $tax; |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
| 1331 | - * Get the invoice fees total. |
|
| 1332 | - * |
|
| 1333 | - * @since 1.0.19 |
|
| 1334 | - * @param string $context View or edit context. |
|
| 1335 | - * @return float |
|
| 1336 | - */ |
|
| 1337 | - public function get_total_fees( $context = 'view' ) { |
|
| 1338 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1331 | + * Get the invoice fees total. |
|
| 1332 | + * |
|
| 1333 | + * @since 1.0.19 |
|
| 1334 | + * @param string $context View or edit context. |
|
| 1335 | + * @return float |
|
| 1336 | + */ |
|
| 1337 | + public function get_total_fees( $context = 'view' ) { |
|
| 1338 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
| 1342 | - * Alias for self::get_total_fees(). |
|
| 1343 | - * |
|
| 1344 | - * @since 1.0.19 |
|
| 1345 | - * @param string $context View or edit context. |
|
| 1346 | - * @return float |
|
| 1347 | - */ |
|
| 1348 | - public function get_fees_total( $context = 'view' ) { |
|
| 1349 | - return $this->get_total_fees( $context ); |
|
| 1342 | + * Alias for self::get_total_fees(). |
|
| 1343 | + * |
|
| 1344 | + * @since 1.0.19 |
|
| 1345 | + * @param string $context View or edit context. |
|
| 1346 | + * @return float |
|
| 1347 | + */ |
|
| 1348 | + public function get_fees_total( $context = 'view' ) { |
|
| 1349 | + return $this->get_total_fees( $context ); |
|
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | /** |
| 1353 | - * Get the invoice total. |
|
| 1354 | - * |
|
| 1355 | - * @since 1.0.19 |
|
| 1353 | + * Get the invoice total. |
|
| 1354 | + * |
|
| 1355 | + * @since 1.0.19 |
|
| 1356 | 1356 | * @return float |
| 1357 | - */ |
|
| 1358 | - public function get_total() { |
|
| 1359 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1360 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1357 | + */ |
|
| 1358 | + public function get_total() { |
|
| 1359 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1360 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | 1363 | /** |
| 1364 | - * Get the initial invoice total. |
|
| 1365 | - * |
|
| 1366 | - * @since 1.0.19 |
|
| 1364 | + * Get the initial invoice total. |
|
| 1365 | + * |
|
| 1366 | + * @since 1.0.19 |
|
| 1367 | 1367 | * @param string $context View or edit context. |
| 1368 | 1368 | * @return float |
| 1369 | - */ |
|
| 1369 | + */ |
|
| 1370 | 1370 | public function get_initial_total() { |
| 1371 | 1371 | |
| 1372 | - if ( empty( $this->totals ) ) { |
|
| 1373 | - $this->recalculate_total(); |
|
| 1374 | - } |
|
| 1372 | + if ( empty( $this->totals ) ) { |
|
| 1373 | + $this->recalculate_total(); |
|
| 1374 | + } |
|
| 1375 | 1375 | |
| 1376 | - $tax = $this->totals['tax']['initial']; |
|
| 1377 | - $fee = $this->totals['fee']['initial']; |
|
| 1378 | - $discount = $this->totals['discount']['initial']; |
|
| 1379 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1380 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1376 | + $tax = $this->totals['tax']['initial']; |
|
| 1377 | + $fee = $this->totals['fee']['initial']; |
|
| 1378 | + $discount = $this->totals['discount']['initial']; |
|
| 1379 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1380 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1381 | 1381 | |
| 1382 | - if ( 0 > $total ) { |
|
| 1383 | - $total = 0; |
|
| 1384 | - } |
|
| 1382 | + if ( 0 > $total ) { |
|
| 1383 | + $total = 0; |
|
| 1384 | + } |
|
| 1385 | 1385 | |
| 1386 | 1386 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1387 | - } |
|
| 1387 | + } |
|
| 1388 | 1388 | |
| 1389 | - /** |
|
| 1390 | - * Get the recurring invoice total. |
|
| 1391 | - * |
|
| 1392 | - * @since 1.0.19 |
|
| 1389 | + /** |
|
| 1390 | + * Get the recurring invoice total. |
|
| 1391 | + * |
|
| 1392 | + * @since 1.0.19 |
|
| 1393 | 1393 | * @param string $context View or edit context. |
| 1394 | 1394 | * @return float |
| 1395 | - */ |
|
| 1395 | + */ |
|
| 1396 | 1396 | public function get_recurring_total() { |
| 1397 | 1397 | |
| 1398 | - if ( empty( $this->totals ) ) { |
|
| 1399 | - $this->recalculate_total(); |
|
| 1400 | - } |
|
| 1398 | + if ( empty( $this->totals ) ) { |
|
| 1399 | + $this->recalculate_total(); |
|
| 1400 | + } |
|
| 1401 | 1401 | |
| 1402 | - $tax = $this->totals['tax']['recurring']; |
|
| 1403 | - $fee = $this->totals['fee']['recurring']; |
|
| 1404 | - $discount = $this->totals['discount']['recurring']; |
|
| 1405 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1406 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1402 | + $tax = $this->totals['tax']['recurring']; |
|
| 1403 | + $fee = $this->totals['fee']['recurring']; |
|
| 1404 | + $discount = $this->totals['discount']['recurring']; |
|
| 1405 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1406 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1407 | 1407 | |
| 1408 | - if ( 0 > $total ) { |
|
| 1409 | - $total = 0; |
|
| 1410 | - } |
|
| 1408 | + if ( 0 > $total ) { |
|
| 1409 | + $total = 0; |
|
| 1410 | + } |
|
| 1411 | 1411 | |
| 1412 | 1412 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1413 | - } |
|
| 1413 | + } |
|
| 1414 | 1414 | |
| 1415 | - /** |
|
| 1416 | - * Returns recurring payment details. |
|
| 1417 | - * |
|
| 1418 | - * @since 1.0.19 |
|
| 1415 | + /** |
|
| 1416 | + * Returns recurring payment details. |
|
| 1417 | + * |
|
| 1418 | + * @since 1.0.19 |
|
| 1419 | 1419 | * @param string $field Optionally provide a field to return. |
| 1420 | - * @param string $currency Whether to include the currency. |
|
| 1420 | + * @param string $currency Whether to include the currency. |
|
| 1421 | 1421 | * @return float |
| 1422 | - */ |
|
| 1422 | + */ |
|
| 1423 | 1423 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1424 | 1424 | |
| 1425 | - // Maybe recalculate totals. |
|
| 1426 | - if ( empty( $this->totals ) ) { |
|
| 1427 | - $this->recalculate_total(); |
|
| 1428 | - } |
|
| 1425 | + // Maybe recalculate totals. |
|
| 1426 | + if ( empty( $this->totals ) ) { |
|
| 1427 | + $this->recalculate_total(); |
|
| 1428 | + } |
|
| 1429 | 1429 | |
| 1430 | - // Prepare recurring totals. |
|
| 1430 | + // Prepare recurring totals. |
|
| 1431 | 1431 | $data = apply_filters( |
| 1432 | - 'wpinv_get_invoice_recurring_details', |
|
| 1433 | - array( |
|
| 1434 | - 'cart_details' => $this->get_cart_details(), |
|
| 1435 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1436 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1437 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1438 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1439 | - 'total' => $this->get_recurring_total(), |
|
| 1440 | - ), |
|
| 1441 | - $this, |
|
| 1442 | - $field, |
|
| 1443 | - $currency |
|
| 1444 | - ); |
|
| 1432 | + 'wpinv_get_invoice_recurring_details', |
|
| 1433 | + array( |
|
| 1434 | + 'cart_details' => $this->get_cart_details(), |
|
| 1435 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1436 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1437 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1438 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1439 | + 'total' => $this->get_recurring_total(), |
|
| 1440 | + ), |
|
| 1441 | + $this, |
|
| 1442 | + $field, |
|
| 1443 | + $currency |
|
| 1444 | + ); |
|
| 1445 | 1445 | |
| 1446 | 1446 | if ( isset( $data[$field] ) ) { |
| 1447 | 1447 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1451,145 +1451,145 @@ discard block |
||
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | /** |
| 1454 | - * Get the invoice fees. |
|
| 1455 | - * |
|
| 1456 | - * @since 1.0.19 |
|
| 1457 | - * @param string $context View or edit context. |
|
| 1458 | - * @return array |
|
| 1459 | - */ |
|
| 1460 | - public function get_fees( $context = 'view' ) { |
|
| 1461 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1454 | + * Get the invoice fees. |
|
| 1455 | + * |
|
| 1456 | + * @since 1.0.19 |
|
| 1457 | + * @param string $context View or edit context. |
|
| 1458 | + * @return array |
|
| 1459 | + */ |
|
| 1460 | + public function get_fees( $context = 'view' ) { |
|
| 1461 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | 1464 | /** |
| 1465 | - * Get the invoice discounts. |
|
| 1466 | - * |
|
| 1467 | - * @since 1.0.19 |
|
| 1468 | - * @param string $context View or edit context. |
|
| 1469 | - * @return array |
|
| 1470 | - */ |
|
| 1471 | - public function get_discounts( $context = 'view' ) { |
|
| 1472 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1465 | + * Get the invoice discounts. |
|
| 1466 | + * |
|
| 1467 | + * @since 1.0.19 |
|
| 1468 | + * @param string $context View or edit context. |
|
| 1469 | + * @return array |
|
| 1470 | + */ |
|
| 1471 | + public function get_discounts( $context = 'view' ) { |
|
| 1472 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | /** |
| 1476 | - * Get the invoice taxes. |
|
| 1477 | - * |
|
| 1478 | - * @since 1.0.19 |
|
| 1479 | - * @param string $context View or edit context. |
|
| 1480 | - * @return array |
|
| 1481 | - */ |
|
| 1482 | - public function get_taxes( $context = 'view' ) { |
|
| 1483 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1476 | + * Get the invoice taxes. |
|
| 1477 | + * |
|
| 1478 | + * @since 1.0.19 |
|
| 1479 | + * @param string $context View or edit context. |
|
| 1480 | + * @return array |
|
| 1481 | + */ |
|
| 1482 | + public function get_taxes( $context = 'view' ) { |
|
| 1483 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | 1486 | /** |
| 1487 | - * Get the invoice items. |
|
| 1488 | - * |
|
| 1489 | - * @since 1.0.19 |
|
| 1490 | - * @param string $context View or edit context. |
|
| 1491 | - * @return GetPaid_Form_Item[] |
|
| 1492 | - */ |
|
| 1493 | - public function get_items( $context = 'view' ) { |
|
| 1487 | + * Get the invoice items. |
|
| 1488 | + * |
|
| 1489 | + * @since 1.0.19 |
|
| 1490 | + * @param string $context View or edit context. |
|
| 1491 | + * @return GetPaid_Form_Item[] |
|
| 1492 | + */ |
|
| 1493 | + public function get_items( $context = 'view' ) { |
|
| 1494 | 1494 | return $this->get_prop( 'items', $context ); |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
| 1498 | - * Get the invoice's payment form. |
|
| 1499 | - * |
|
| 1500 | - * @since 1.0.19 |
|
| 1501 | - * @param string $context View or edit context. |
|
| 1502 | - * @return int |
|
| 1503 | - */ |
|
| 1504 | - public function get_payment_form( $context = 'view' ) { |
|
| 1505 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1498 | + * Get the invoice's payment form. |
|
| 1499 | + * |
|
| 1500 | + * @since 1.0.19 |
|
| 1501 | + * @param string $context View or edit context. |
|
| 1502 | + * @return int |
|
| 1503 | + */ |
|
| 1504 | + public function get_payment_form( $context = 'view' ) { |
|
| 1505 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | /** |
| 1509 | - * Get the invoice's submission id. |
|
| 1510 | - * |
|
| 1511 | - * @since 1.0.19 |
|
| 1512 | - * @param string $context View or edit context. |
|
| 1513 | - * @return string |
|
| 1514 | - */ |
|
| 1515 | - public function get_submission_id( $context = 'view' ) { |
|
| 1516 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1509 | + * Get the invoice's submission id. |
|
| 1510 | + * |
|
| 1511 | + * @since 1.0.19 |
|
| 1512 | + * @param string $context View or edit context. |
|
| 1513 | + * @return string |
|
| 1514 | + */ |
|
| 1515 | + public function get_submission_id( $context = 'view' ) { |
|
| 1516 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | /** |
| 1520 | - * Get the invoice's discount code. |
|
| 1521 | - * |
|
| 1522 | - * @since 1.0.19 |
|
| 1523 | - * @param string $context View or edit context. |
|
| 1524 | - * @return string |
|
| 1525 | - */ |
|
| 1526 | - public function get_discount_code( $context = 'view' ) { |
|
| 1527 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1520 | + * Get the invoice's discount code. |
|
| 1521 | + * |
|
| 1522 | + * @since 1.0.19 |
|
| 1523 | + * @param string $context View or edit context. |
|
| 1524 | + * @return string |
|
| 1525 | + */ |
|
| 1526 | + public function get_discount_code( $context = 'view' ) { |
|
| 1527 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | /** |
| 1531 | - * Get the invoice's gateway. |
|
| 1532 | - * |
|
| 1533 | - * @since 1.0.19 |
|
| 1534 | - * @param string $context View or edit context. |
|
| 1535 | - * @return string |
|
| 1536 | - */ |
|
| 1537 | - public function get_gateway( $context = 'view' ) { |
|
| 1538 | - return $this->get_prop( 'gateway', $context ); |
|
| 1531 | + * Get the invoice's gateway. |
|
| 1532 | + * |
|
| 1533 | + * @since 1.0.19 |
|
| 1534 | + * @param string $context View or edit context. |
|
| 1535 | + * @return string |
|
| 1536 | + */ |
|
| 1537 | + public function get_gateway( $context = 'view' ) { |
|
| 1538 | + return $this->get_prop( 'gateway', $context ); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | /** |
| 1542 | - * Get the invoice's gateway display title. |
|
| 1543 | - * |
|
| 1544 | - * @since 1.0.19 |
|
| 1545 | - * @return string |
|
| 1546 | - */ |
|
| 1542 | + * Get the invoice's gateway display title. |
|
| 1543 | + * |
|
| 1544 | + * @since 1.0.19 |
|
| 1545 | + * @return string |
|
| 1546 | + */ |
|
| 1547 | 1547 | public function get_gateway_title() { |
| 1548 | 1548 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1549 | 1549 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | /** |
| 1553 | - * Get the invoice's transaction id. |
|
| 1554 | - * |
|
| 1555 | - * @since 1.0.19 |
|
| 1556 | - * @param string $context View or edit context. |
|
| 1557 | - * @return string |
|
| 1558 | - */ |
|
| 1559 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1560 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1553 | + * Get the invoice's transaction id. |
|
| 1554 | + * |
|
| 1555 | + * @since 1.0.19 |
|
| 1556 | + * @param string $context View or edit context. |
|
| 1557 | + * @return string |
|
| 1558 | + */ |
|
| 1559 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1560 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | /** |
| 1564 | - * Get the invoice's currency. |
|
| 1565 | - * |
|
| 1566 | - * @since 1.0.19 |
|
| 1567 | - * @param string $context View or edit context. |
|
| 1568 | - * @return string |
|
| 1569 | - */ |
|
| 1570 | - public function get_currency( $context = 'view' ) { |
|
| 1564 | + * Get the invoice's currency. |
|
| 1565 | + * |
|
| 1566 | + * @since 1.0.19 |
|
| 1567 | + * @param string $context View or edit context. |
|
| 1568 | + * @return string |
|
| 1569 | + */ |
|
| 1570 | + public function get_currency( $context = 'view' ) { |
|
| 1571 | 1571 | $currency = $this->get_prop( 'currency', $context ); |
| 1572 | 1572 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | /** |
| 1576 | - * Checks if we are charging taxes for this invoice. |
|
| 1577 | - * |
|
| 1578 | - * @since 1.0.19 |
|
| 1579 | - * @param string $context View or edit context. |
|
| 1580 | - * @return bool |
|
| 1581 | - */ |
|
| 1582 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1576 | + * Checks if we are charging taxes for this invoice. |
|
| 1577 | + * |
|
| 1578 | + * @since 1.0.19 |
|
| 1579 | + * @param string $context View or edit context. |
|
| 1580 | + * @return bool |
|
| 1581 | + */ |
|
| 1582 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1583 | 1583 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | /** |
| 1587 | - * Retrieves the subscription id for an invoice. |
|
| 1588 | - * |
|
| 1589 | - * @since 1.0.19 |
|
| 1590 | - * @param string $context View or edit context. |
|
| 1591 | - * @return int |
|
| 1592 | - */ |
|
| 1587 | + * Retrieves the subscription id for an invoice. |
|
| 1588 | + * |
|
| 1589 | + * @since 1.0.19 |
|
| 1590 | + * @param string $context View or edit context. |
|
| 1591 | + * @return int |
|
| 1592 | + */ |
|
| 1593 | 1593 | public function get_subscription_id( $context = 'view' ) { |
| 1594 | 1594 | $subscription_id = $this->get_prop( 'subscription_id', $context ); |
| 1595 | 1595 | |
@@ -1602,12 +1602,12 @@ discard block |
||
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | /** |
| 1605 | - * Retrieves the payment meta for an invoice. |
|
| 1606 | - * |
|
| 1607 | - * @since 1.0.19 |
|
| 1608 | - * @param string $context View or edit context. |
|
| 1609 | - * @return array |
|
| 1610 | - */ |
|
| 1605 | + * Retrieves the payment meta for an invoice. |
|
| 1606 | + * |
|
| 1607 | + * @since 1.0.19 |
|
| 1608 | + * @param string $context View or edit context. |
|
| 1609 | + * @return array |
|
| 1610 | + */ |
|
| 1611 | 1611 | public function get_payment_meta( $context = 'view' ) { |
| 1612 | 1612 | |
| 1613 | 1613 | return array( |
@@ -1627,11 +1627,11 @@ discard block |
||
| 1627 | 1627 | } |
| 1628 | 1628 | |
| 1629 | 1629 | /** |
| 1630 | - * Retrieves the cart details for an invoice. |
|
| 1631 | - * |
|
| 1632 | - * @since 1.0.19 |
|
| 1633 | - * @return array |
|
| 1634 | - */ |
|
| 1630 | + * Retrieves the cart details for an invoice. |
|
| 1631 | + * |
|
| 1632 | + * @since 1.0.19 |
|
| 1633 | + * @return array |
|
| 1634 | + */ |
|
| 1635 | 1635 | public function get_cart_details() { |
| 1636 | 1636 | $items = $this->get_items(); |
| 1637 | 1637 | $cart_details = array(); |
@@ -1641,16 +1641,16 @@ discard block |
||
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | 1643 | return $cart_details; |
| 1644 | - } |
|
| 1644 | + } |
|
| 1645 | 1645 | |
| 1646 | - /** |
|
| 1647 | - * Retrieves the recurring item. |
|
| 1648 | - * |
|
| 1649 | - * @return null|GetPaid_Form_Item |
|
| 1650 | - */ |
|
| 1651 | - public function get_recurring( $object = false ) { |
|
| 1646 | + /** |
|
| 1647 | + * Retrieves the recurring item. |
|
| 1648 | + * |
|
| 1649 | + * @return null|GetPaid_Form_Item |
|
| 1650 | + */ |
|
| 1651 | + public function get_recurring( $object = false ) { |
|
| 1652 | 1652 | |
| 1653 | - // Are we returning an object? |
|
| 1653 | + // Are we returning an object? |
|
| 1654 | 1654 | if ( $object ) { |
| 1655 | 1655 | return $this->get_item( $this->recurring_item ); |
| 1656 | 1656 | } |
@@ -1658,58 +1658,58 @@ discard block |
||
| 1658 | 1658 | return $this->recurring_item; |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | - /** |
|
| 1662 | - * Retrieves the subscription name. |
|
| 1663 | - * |
|
| 1664 | - * @since 1.0.19 |
|
| 1665 | - * @return string |
|
| 1666 | - */ |
|
| 1667 | - public function get_subscription_name() { |
|
| 1661 | + /** |
|
| 1662 | + * Retrieves the subscription name. |
|
| 1663 | + * |
|
| 1664 | + * @since 1.0.19 |
|
| 1665 | + * @return string |
|
| 1666 | + */ |
|
| 1667 | + public function get_subscription_name() { |
|
| 1668 | 1668 | |
| 1669 | - // Retrieve the recurring name |
|
| 1669 | + // Retrieve the recurring name |
|
| 1670 | 1670 | $item = $this->get_recurring( true ); |
| 1671 | 1671 | |
| 1672 | - // Abort if it does not exist. |
|
| 1672 | + // Abort if it does not exist. |
|
| 1673 | 1673 | if ( empty( $item ) ) { |
| 1674 | 1674 | return ''; |
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | - // Return the item name. |
|
| 1677 | + // Return the item name. |
|
| 1678 | 1678 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1679 | - } |
|
| 1680 | - |
|
| 1681 | - /** |
|
| 1682 | - * Retrieves the view url. |
|
| 1683 | - * |
|
| 1684 | - * @since 1.0.19 |
|
| 1685 | - * @return string |
|
| 1686 | - */ |
|
| 1687 | - public function get_view_url() { |
|
| 1679 | + } |
|
| 1680 | + |
|
| 1681 | + /** |
|
| 1682 | + * Retrieves the view url. |
|
| 1683 | + * |
|
| 1684 | + * @since 1.0.19 |
|
| 1685 | + * @return string |
|
| 1686 | + */ |
|
| 1687 | + public function get_view_url() { |
|
| 1688 | 1688 | $invoice_url = get_permalink( $this->get_id() ); |
| 1689 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1689 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1690 | 1690 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1691 | - } |
|
| 1691 | + } |
|
| 1692 | 1692 | |
| 1693 | - /** |
|
| 1694 | - * Retrieves the payment url. |
|
| 1695 | - * |
|
| 1696 | - * @since 1.0.19 |
|
| 1697 | - * @return string |
|
| 1698 | - */ |
|
| 1699 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1693 | + /** |
|
| 1694 | + * Retrieves the payment url. |
|
| 1695 | + * |
|
| 1696 | + * @since 1.0.19 |
|
| 1697 | + * @return string |
|
| 1698 | + */ |
|
| 1699 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1700 | 1700 | |
| 1701 | - // Retrieve the checkout url. |
|
| 1701 | + // Retrieve the checkout url. |
|
| 1702 | 1702 | $pay_url = wpinv_get_checkout_uri(); |
| 1703 | 1703 | |
| 1704 | - // Maybe force ssl. |
|
| 1704 | + // Maybe force ssl. |
|
| 1705 | 1705 | if ( is_ssl() ) { |
| 1706 | 1706 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | - // Add the invoice key. |
|
| 1710 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1709 | + // Add the invoice key. |
|
| 1710 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1711 | 1711 | |
| 1712 | - // (Maybe?) add a secret |
|
| 1712 | + // (Maybe?) add a secret |
|
| 1713 | 1713 | if ( $secret ) { |
| 1714 | 1714 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1715 | 1715 | } |
@@ -1718,18 +1718,18 @@ discard block |
||
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | 1720 | /** |
| 1721 | - * Magic method for accessing invoice properties. |
|
| 1722 | - * |
|
| 1723 | - * @since 1.0.15 |
|
| 1724 | - * @access public |
|
| 1725 | - * |
|
| 1726 | - * @param string $key Discount data to retrieve |
|
| 1727 | - * @param string $context View or edit context. |
|
| 1728 | - * @return mixed Value of the given invoice property (if set). |
|
| 1729 | - */ |
|
| 1730 | - public function get( $key, $context = 'view' ) { |
|
| 1721 | + * Magic method for accessing invoice properties. |
|
| 1722 | + * |
|
| 1723 | + * @since 1.0.15 |
|
| 1724 | + * @access public |
|
| 1725 | + * |
|
| 1726 | + * @param string $key Discount data to retrieve |
|
| 1727 | + * @param string $context View or edit context. |
|
| 1728 | + * @return mixed Value of the given invoice property (if set). |
|
| 1729 | + */ |
|
| 1730 | + public function get( $key, $context = 'view' ) { |
|
| 1731 | 1731 | return $this->get_prop( $key, $context ); |
| 1732 | - } |
|
| 1732 | + } |
|
| 1733 | 1733 | |
| 1734 | 1734 | /* |
| 1735 | 1735 | |-------------------------------------------------------------------------- |
@@ -1742,118 +1742,118 @@ discard block |
||
| 1742 | 1742 | */ |
| 1743 | 1743 | |
| 1744 | 1744 | /** |
| 1745 | - * Magic method for setting invoice properties. |
|
| 1746 | - * |
|
| 1747 | - * @since 1.0.19 |
|
| 1748 | - * @access public |
|
| 1749 | - * |
|
| 1750 | - * @param string $key Discount data to retrieve |
|
| 1751 | - * @param mixed $value new value. |
|
| 1752 | - * @return mixed Value of the given invoice property (if set). |
|
| 1753 | - */ |
|
| 1754 | - public function set( $key, $value ) { |
|
| 1745 | + * Magic method for setting invoice properties. |
|
| 1746 | + * |
|
| 1747 | + * @since 1.0.19 |
|
| 1748 | + * @access public |
|
| 1749 | + * |
|
| 1750 | + * @param string $key Discount data to retrieve |
|
| 1751 | + * @param mixed $value new value. |
|
| 1752 | + * @return mixed Value of the given invoice property (if set). |
|
| 1753 | + */ |
|
| 1754 | + public function set( $key, $value ) { |
|
| 1755 | 1755 | |
| 1756 | 1756 | $setter = "set_$key"; |
| 1757 | 1757 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1758 | 1758 | $this->{$setter}( $value ); |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | - } |
|
| 1762 | - |
|
| 1763 | - /** |
|
| 1764 | - * Sets item status. |
|
| 1765 | - * |
|
| 1766 | - * @since 1.0.19 |
|
| 1767 | - * @param string $new_status New status. |
|
| 1768 | - * @param string $note Optional note to add. |
|
| 1769 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1770 | - * @return array details of change. |
|
| 1771 | - */ |
|
| 1772 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1773 | - $old_status = $this->get_status(); |
|
| 1774 | - |
|
| 1775 | - $this->set_prop( 'status', $new_status ); |
|
| 1776 | - |
|
| 1777 | - // If setting the status, ensure it's set to a valid status. |
|
| 1778 | - if ( true === $this->object_read ) { |
|
| 1779 | - |
|
| 1780 | - // Only allow valid new status. |
|
| 1781 | - if ( ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
| 1782 | - $new_status = 'wpi-pending'; |
|
| 1783 | - } |
|
| 1784 | - |
|
| 1785 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1786 | - if ( $old_status && ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
| 1787 | - $old_status = 'wpi-pending'; |
|
| 1788 | - } |
|
| 1789 | - } |
|
| 1790 | - |
|
| 1791 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1792 | - $this->status_transition = array( |
|
| 1793 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1794 | - 'to' => $new_status, |
|
| 1795 | - 'note' => $note, |
|
| 1796 | - 'manual' => (bool) $manual_update, |
|
| 1797 | - ); |
|
| 1798 | - |
|
| 1799 | - if ( $manual_update ) { |
|
| 1800 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1801 | - } |
|
| 1802 | - |
|
| 1803 | - $this->maybe_set_date_paid(); |
|
| 1804 | - |
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - return array( |
|
| 1808 | - 'from' => $old_status, |
|
| 1809 | - 'to' => $new_status, |
|
| 1810 | - ); |
|
| 1811 | - } |
|
| 1812 | - |
|
| 1813 | - /** |
|
| 1814 | - * Maybe set date paid. |
|
| 1815 | - * |
|
| 1816 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 1817 | - * order status. |
|
| 1818 | - * |
|
| 1819 | - * @since 1.0.19 |
|
| 1820 | - */ |
|
| 1821 | - public function maybe_set_date_paid() { |
|
| 1822 | - |
|
| 1823 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1824 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1825 | - } |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - /** |
|
| 1829 | - * Set parent invoice ID. |
|
| 1830 | - * |
|
| 1831 | - * @since 1.0.19 |
|
| 1832 | - */ |
|
| 1833 | - public function set_parent_id( $value ) { |
|
| 1834 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1835 | - return; |
|
| 1836 | - } |
|
| 1837 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1838 | - } |
|
| 1839 | - |
|
| 1840 | - /** |
|
| 1841 | - * Set plugin version when the invoice was created. |
|
| 1842 | - * |
|
| 1843 | - * @since 1.0.19 |
|
| 1844 | - */ |
|
| 1845 | - public function set_version( $value ) { |
|
| 1846 | - $this->set_prop( 'version', $value ); |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - /** |
|
| 1850 | - * Set date when the invoice was created. |
|
| 1851 | - * |
|
| 1852 | - * @since 1.0.19 |
|
| 1853 | - * @param string $value Value to set. |
|
| 1761 | + } |
|
| 1762 | + |
|
| 1763 | + /** |
|
| 1764 | + * Sets item status. |
|
| 1765 | + * |
|
| 1766 | + * @since 1.0.19 |
|
| 1767 | + * @param string $new_status New status. |
|
| 1768 | + * @param string $note Optional note to add. |
|
| 1769 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1770 | + * @return array details of change. |
|
| 1771 | + */ |
|
| 1772 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1773 | + $old_status = $this->get_status(); |
|
| 1774 | + |
|
| 1775 | + $this->set_prop( 'status', $new_status ); |
|
| 1776 | + |
|
| 1777 | + // If setting the status, ensure it's set to a valid status. |
|
| 1778 | + if ( true === $this->object_read ) { |
|
| 1779 | + |
|
| 1780 | + // Only allow valid new status. |
|
| 1781 | + if ( ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
| 1782 | + $new_status = 'wpi-pending'; |
|
| 1783 | + } |
|
| 1784 | + |
|
| 1785 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1786 | + if ( $old_status && ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
| 1787 | + $old_status = 'wpi-pending'; |
|
| 1788 | + } |
|
| 1789 | + } |
|
| 1790 | + |
|
| 1791 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1792 | + $this->status_transition = array( |
|
| 1793 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1794 | + 'to' => $new_status, |
|
| 1795 | + 'note' => $note, |
|
| 1796 | + 'manual' => (bool) $manual_update, |
|
| 1797 | + ); |
|
| 1798 | + |
|
| 1799 | + if ( $manual_update ) { |
|
| 1800 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + $this->maybe_set_date_paid(); |
|
| 1804 | + |
|
| 1805 | + } |
|
| 1806 | + |
|
| 1807 | + return array( |
|
| 1808 | + 'from' => $old_status, |
|
| 1809 | + 'to' => $new_status, |
|
| 1810 | + ); |
|
| 1811 | + } |
|
| 1812 | + |
|
| 1813 | + /** |
|
| 1814 | + * Maybe set date paid. |
|
| 1815 | + * |
|
| 1816 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 1817 | + * order status. |
|
| 1818 | + * |
|
| 1819 | + * @since 1.0.19 |
|
| 1820 | + */ |
|
| 1821 | + public function maybe_set_date_paid() { |
|
| 1822 | + |
|
| 1823 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1824 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1825 | + } |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + /** |
|
| 1829 | + * Set parent invoice ID. |
|
| 1830 | + * |
|
| 1831 | + * @since 1.0.19 |
|
| 1832 | + */ |
|
| 1833 | + public function set_parent_id( $value ) { |
|
| 1834 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1835 | + return; |
|
| 1836 | + } |
|
| 1837 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1838 | + } |
|
| 1839 | + |
|
| 1840 | + /** |
|
| 1841 | + * Set plugin version when the invoice was created. |
|
| 1842 | + * |
|
| 1843 | + * @since 1.0.19 |
|
| 1844 | + */ |
|
| 1845 | + public function set_version( $value ) { |
|
| 1846 | + $this->set_prop( 'version', $value ); |
|
| 1847 | + } |
|
| 1848 | + |
|
| 1849 | + /** |
|
| 1850 | + * Set date when the invoice was created. |
|
| 1851 | + * |
|
| 1852 | + * @since 1.0.19 |
|
| 1853 | + * @param string $value Value to set. |
|
| 1854 | 1854 | * @return bool Whether or not the date was set. |
| 1855 | - */ |
|
| 1856 | - public function set_date_created( $value ) { |
|
| 1855 | + */ |
|
| 1856 | + public function set_date_created( $value ) { |
|
| 1857 | 1857 | $date = strtotime( $value ); |
| 1858 | 1858 | |
| 1859 | 1859 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1866,13 +1866,13 @@ discard block |
||
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | /** |
| 1869 | - * Set date invoice due date. |
|
| 1870 | - * |
|
| 1871 | - * @since 1.0.19 |
|
| 1872 | - * @param string $value Value to set. |
|
| 1869 | + * Set date invoice due date. |
|
| 1870 | + * |
|
| 1871 | + * @since 1.0.19 |
|
| 1872 | + * @param string $value Value to set. |
|
| 1873 | 1873 | * @return bool Whether or not the date was set. |
| 1874 | - */ |
|
| 1875 | - public function set_due_date( $value ) { |
|
| 1874 | + */ |
|
| 1875 | + public function set_due_date( $value ) { |
|
| 1876 | 1876 | $date = strtotime( $value ); |
| 1877 | 1877 | |
| 1878 | 1878 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1880,29 +1880,29 @@ discard block |
||
| 1880 | 1880 | return true; |
| 1881 | 1881 | } |
| 1882 | 1882 | |
| 1883 | - $this->set_prop( 'due_date', '' ); |
|
| 1883 | + $this->set_prop( 'due_date', '' ); |
|
| 1884 | 1884 | return false; |
| 1885 | 1885 | |
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | /** |
| 1889 | - * Alias of self::set_due_date(). |
|
| 1890 | - * |
|
| 1891 | - * @since 1.0.19 |
|
| 1892 | - * @param string $value New name. |
|
| 1893 | - */ |
|
| 1894 | - public function set_date_due( $value ) { |
|
| 1895 | - $this->set_due_date( $value ); |
|
| 1889 | + * Alias of self::set_due_date(). |
|
| 1890 | + * |
|
| 1891 | + * @since 1.0.19 |
|
| 1892 | + * @param string $value New name. |
|
| 1893 | + */ |
|
| 1894 | + public function set_date_due( $value ) { |
|
| 1895 | + $this->set_due_date( $value ); |
|
| 1896 | 1896 | } |
| 1897 | 1897 | |
| 1898 | 1898 | /** |
| 1899 | - * Set date invoice was completed. |
|
| 1900 | - * |
|
| 1901 | - * @since 1.0.19 |
|
| 1902 | - * @param string $value Value to set. |
|
| 1899 | + * Set date invoice was completed. |
|
| 1900 | + * |
|
| 1901 | + * @since 1.0.19 |
|
| 1902 | + * @param string $value Value to set. |
|
| 1903 | 1903 | * @return bool Whether or not the date was set. |
| 1904 | - */ |
|
| 1905 | - public function set_completed_date( $value ) { |
|
| 1904 | + */ |
|
| 1905 | + public function set_completed_date( $value ) { |
|
| 1906 | 1906 | $date = strtotime( $value ); |
| 1907 | 1907 | |
| 1908 | 1908 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1910,29 +1910,29 @@ discard block |
||
| 1910 | 1910 | return true; |
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | - $this->set_prop( 'completed_date', '' ); |
|
| 1913 | + $this->set_prop( 'completed_date', '' ); |
|
| 1914 | 1914 | return false; |
| 1915 | 1915 | |
| 1916 | 1916 | } |
| 1917 | 1917 | |
| 1918 | 1918 | /** |
| 1919 | - * Alias of self::set_completed_date(). |
|
| 1920 | - * |
|
| 1921 | - * @since 1.0.19 |
|
| 1922 | - * @param string $value New name. |
|
| 1923 | - */ |
|
| 1924 | - public function set_date_completed( $value ) { |
|
| 1925 | - $this->set_completed_date( $value ); |
|
| 1919 | + * Alias of self::set_completed_date(). |
|
| 1920 | + * |
|
| 1921 | + * @since 1.0.19 |
|
| 1922 | + * @param string $value New name. |
|
| 1923 | + */ |
|
| 1924 | + public function set_date_completed( $value ) { |
|
| 1925 | + $this->set_completed_date( $value ); |
|
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | 1928 | /** |
| 1929 | - * Set date when the invoice was last modified. |
|
| 1930 | - * |
|
| 1931 | - * @since 1.0.19 |
|
| 1932 | - * @param string $value Value to set. |
|
| 1929 | + * Set date when the invoice was last modified. |
|
| 1930 | + * |
|
| 1931 | + * @since 1.0.19 |
|
| 1932 | + * @param string $value Value to set. |
|
| 1933 | 1933 | * @return bool Whether or not the date was set. |
| 1934 | - */ |
|
| 1935 | - public function set_date_modified( $value ) { |
|
| 1934 | + */ |
|
| 1935 | + public function set_date_modified( $value ) { |
|
| 1936 | 1936 | $date = strtotime( $value ); |
| 1937 | 1937 | |
| 1938 | 1938 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1940,706 +1940,706 @@ discard block |
||
| 1940 | 1940 | return true; |
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | - $this->set_prop( 'date_modified', '' ); |
|
| 1943 | + $this->set_prop( 'date_modified', '' ); |
|
| 1944 | 1944 | return false; |
| 1945 | 1945 | |
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | 1948 | /** |
| 1949 | - * Set the invoice number. |
|
| 1950 | - * |
|
| 1951 | - * @since 1.0.19 |
|
| 1952 | - * @param string $value New number. |
|
| 1953 | - */ |
|
| 1954 | - public function set_number( $value ) { |
|
| 1949 | + * Set the invoice number. |
|
| 1950 | + * |
|
| 1951 | + * @since 1.0.19 |
|
| 1952 | + * @param string $value New number. |
|
| 1953 | + */ |
|
| 1954 | + public function set_number( $value ) { |
|
| 1955 | 1955 | $number = sanitize_text_field( $value ); |
| 1956 | - $this->set_prop( 'number', $number ); |
|
| 1956 | + $this->set_prop( 'number', $number ); |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | /** |
| 1960 | - * Set the invoice type. |
|
| 1961 | - * |
|
| 1962 | - * @since 1.0.19 |
|
| 1963 | - * @param string $value Type. |
|
| 1964 | - */ |
|
| 1965 | - public function set_type( $value ) { |
|
| 1960 | + * Set the invoice type. |
|
| 1961 | + * |
|
| 1962 | + * @since 1.0.19 |
|
| 1963 | + * @param string $value Type. |
|
| 1964 | + */ |
|
| 1965 | + public function set_type( $value ) { |
|
| 1966 | 1966 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 1967 | - $this->set_prop( 'type', $type ); |
|
| 1968 | - } |
|
| 1967 | + $this->set_prop( 'type', $type ); |
|
| 1968 | + } |
|
| 1969 | 1969 | |
| 1970 | 1970 | /** |
| 1971 | - * Set the invoice post type. |
|
| 1972 | - * |
|
| 1973 | - * @since 1.0.19 |
|
| 1974 | - * @param string $value Post type. |
|
| 1975 | - */ |
|
| 1976 | - public function set_post_type( $value ) { |
|
| 1971 | + * Set the invoice post type. |
|
| 1972 | + * |
|
| 1973 | + * @since 1.0.19 |
|
| 1974 | + * @param string $value Post type. |
|
| 1975 | + */ |
|
| 1976 | + public function set_post_type( $value ) { |
|
| 1977 | 1977 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 1978 | - $this->set_type( $value ); |
|
| 1978 | + $this->set_type( $value ); |
|
| 1979 | 1979 | $this->set_prop( 'post_type', $value ); |
| 1980 | 1980 | } |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | /** |
| 1984 | - * Set the invoice key. |
|
| 1985 | - * |
|
| 1986 | - * @since 1.0.19 |
|
| 1987 | - * @param string $value New key. |
|
| 1988 | - */ |
|
| 1989 | - public function set_key( $value ) { |
|
| 1984 | + * Set the invoice key. |
|
| 1985 | + * |
|
| 1986 | + * @since 1.0.19 |
|
| 1987 | + * @param string $value New key. |
|
| 1988 | + */ |
|
| 1989 | + public function set_key( $value ) { |
|
| 1990 | 1990 | $key = sanitize_text_field( $value ); |
| 1991 | - $this->set_prop( 'key', $key ); |
|
| 1991 | + $this->set_prop( 'key', $key ); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | |
| 1994 | 1994 | /** |
| 1995 | - * Set the invoice mode. |
|
| 1996 | - * |
|
| 1997 | - * @since 1.0.19 |
|
| 1998 | - * @param string $value mode. |
|
| 1999 | - */ |
|
| 2000 | - public function set_mode( $value ) { |
|
| 1995 | + * Set the invoice mode. |
|
| 1996 | + * |
|
| 1997 | + * @since 1.0.19 |
|
| 1998 | + * @param string $value mode. |
|
| 1999 | + */ |
|
| 2000 | + public function set_mode( $value ) { |
|
| 2001 | 2001 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
| 2002 | 2002 | $this->set_prop( 'value', $value ); |
| 2003 | 2003 | } |
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | 2006 | /** |
| 2007 | - * Set the invoice path. |
|
| 2008 | - * |
|
| 2009 | - * @since 1.0.19 |
|
| 2010 | - * @param string $value path. |
|
| 2011 | - */ |
|
| 2012 | - public function set_path( $value ) { |
|
| 2007 | + * Set the invoice path. |
|
| 2008 | + * |
|
| 2009 | + * @since 1.0.19 |
|
| 2010 | + * @param string $value path. |
|
| 2011 | + */ |
|
| 2012 | + public function set_path( $value ) { |
|
| 2013 | 2013 | $this->set_prop( 'path', $value ); |
| 2014 | 2014 | } |
| 2015 | 2015 | |
| 2016 | 2016 | /** |
| 2017 | - * Set the invoice name. |
|
| 2018 | - * |
|
| 2019 | - * @since 1.0.19 |
|
| 2020 | - * @param string $value New name. |
|
| 2021 | - */ |
|
| 2022 | - public function set_name( $value ) { |
|
| 2017 | + * Set the invoice name. |
|
| 2018 | + * |
|
| 2019 | + * @since 1.0.19 |
|
| 2020 | + * @param string $value New name. |
|
| 2021 | + */ |
|
| 2022 | + public function set_name( $value ) { |
|
| 2023 | 2023 | $name = sanitize_text_field( $value ); |
| 2024 | - $this->set_prop( 'name', $name ); |
|
| 2024 | + $this->set_prop( 'name', $name ); |
|
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | /** |
| 2028 | - * Alias of self::set_name(). |
|
| 2029 | - * |
|
| 2030 | - * @since 1.0.19 |
|
| 2031 | - * @param string $value New name. |
|
| 2032 | - */ |
|
| 2033 | - public function set_title( $value ) { |
|
| 2034 | - $this->set_name( $value ); |
|
| 2028 | + * Alias of self::set_name(). |
|
| 2029 | + * |
|
| 2030 | + * @since 1.0.19 |
|
| 2031 | + * @param string $value New name. |
|
| 2032 | + */ |
|
| 2033 | + public function set_title( $value ) { |
|
| 2034 | + $this->set_name( $value ); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | /** |
| 2038 | - * Set the invoice description. |
|
| 2039 | - * |
|
| 2040 | - * @since 1.0.19 |
|
| 2041 | - * @param string $value New description. |
|
| 2042 | - */ |
|
| 2043 | - public function set_description( $value ) { |
|
| 2038 | + * Set the invoice description. |
|
| 2039 | + * |
|
| 2040 | + * @since 1.0.19 |
|
| 2041 | + * @param string $value New description. |
|
| 2042 | + */ |
|
| 2043 | + public function set_description( $value ) { |
|
| 2044 | 2044 | $description = wp_kses_post( $value ); |
| 2045 | - return $this->set_prop( 'description', $description ); |
|
| 2045 | + return $this->set_prop( 'description', $description ); |
|
| 2046 | + } |
|
| 2047 | + |
|
| 2048 | + /** |
|
| 2049 | + * Alias of self::set_description(). |
|
| 2050 | + * |
|
| 2051 | + * @since 1.0.19 |
|
| 2052 | + * @param string $value New description. |
|
| 2053 | + */ |
|
| 2054 | + public function set_excerpt( $value ) { |
|
| 2055 | + $this->set_description( $value ); |
|
| 2056 | + } |
|
| 2057 | + |
|
| 2058 | + /** |
|
| 2059 | + * Alias of self::set_description(). |
|
| 2060 | + * |
|
| 2061 | + * @since 1.0.19 |
|
| 2062 | + * @param string $value New description. |
|
| 2063 | + */ |
|
| 2064 | + public function set_summary( $value ) { |
|
| 2065 | + $this->set_description( $value ); |
|
| 2066 | + } |
|
| 2067 | + |
|
| 2068 | + /** |
|
| 2069 | + * Set the receiver of the invoice. |
|
| 2070 | + * |
|
| 2071 | + * @since 1.0.19 |
|
| 2072 | + * @param int $value New author. |
|
| 2073 | + */ |
|
| 2074 | + public function set_author( $value ) { |
|
| 2075 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2076 | + |
|
| 2077 | + if ( $user && $user->ID ) { |
|
| 2078 | + $this->set_prop( 'author', $user->ID ); |
|
| 2079 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2080 | + } |
|
| 2081 | + |
|
| 2046 | 2082 | } |
| 2047 | 2083 | |
| 2048 | 2084 | /** |
| 2049 | - * Alias of self::set_description(). |
|
| 2050 | - * |
|
| 2051 | - * @since 1.0.19 |
|
| 2052 | - * @param string $value New description. |
|
| 2053 | - */ |
|
| 2054 | - public function set_excerpt( $value ) { |
|
| 2055 | - $this->set_description( $value ); |
|
| 2085 | + * Alias of self::set_author(). |
|
| 2086 | + * |
|
| 2087 | + * @since 1.0.19 |
|
| 2088 | + * @param int $value New user id. |
|
| 2089 | + */ |
|
| 2090 | + public function set_user_id( $value ) { |
|
| 2091 | + $this->set_author( $value ); |
|
| 2056 | 2092 | } |
| 2057 | 2093 | |
| 2058 | 2094 | /** |
| 2059 | - * Alias of self::set_description(). |
|
| 2060 | - * |
|
| 2061 | - * @since 1.0.19 |
|
| 2062 | - * @param string $value New description. |
|
| 2063 | - */ |
|
| 2064 | - public function set_summary( $value ) { |
|
| 2065 | - $this->set_description( $value ); |
|
| 2095 | + * Alias of self::set_author(). |
|
| 2096 | + * |
|
| 2097 | + * @since 1.0.19 |
|
| 2098 | + * @param int $value New user id. |
|
| 2099 | + */ |
|
| 2100 | + public function set_customer_id( $value ) { |
|
| 2101 | + $this->set_author( $value ); |
|
| 2066 | 2102 | } |
| 2067 | 2103 | |
| 2068 | 2104 | /** |
| 2069 | - * Set the receiver of the invoice. |
|
| 2070 | - * |
|
| 2071 | - * @since 1.0.19 |
|
| 2072 | - * @param int $value New author. |
|
| 2073 | - */ |
|
| 2074 | - public function set_author( $value ) { |
|
| 2075 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2076 | - |
|
| 2077 | - if ( $user && $user->ID ) { |
|
| 2078 | - $this->set_prop( 'author', $user->ID ); |
|
| 2079 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2080 | - } |
|
| 2081 | - |
|
| 2105 | + * Set the customer's ip. |
|
| 2106 | + * |
|
| 2107 | + * @since 1.0.19 |
|
| 2108 | + * @param string $value ip address. |
|
| 2109 | + */ |
|
| 2110 | + public function set_ip( $value ) { |
|
| 2111 | + $this->set_prop( 'ip', $value ); |
|
| 2082 | 2112 | } |
| 2083 | 2113 | |
| 2084 | 2114 | /** |
| 2085 | - * Alias of self::set_author(). |
|
| 2086 | - * |
|
| 2087 | - * @since 1.0.19 |
|
| 2088 | - * @param int $value New user id. |
|
| 2089 | - */ |
|
| 2090 | - public function set_user_id( $value ) { |
|
| 2091 | - $this->set_author( $value ); |
|
| 2115 | + * Alias of self::set_ip(). |
|
| 2116 | + * |
|
| 2117 | + * @since 1.0.19 |
|
| 2118 | + * @param string $value ip address. |
|
| 2119 | + */ |
|
| 2120 | + public function set_user_ip( $value ) { |
|
| 2121 | + $this->set_ip( $value ); |
|
| 2092 | 2122 | } |
| 2093 | 2123 | |
| 2094 | 2124 | /** |
| 2095 | - * Alias of self::set_author(). |
|
| 2096 | - * |
|
| 2097 | - * @since 1.0.19 |
|
| 2098 | - * @param int $value New user id. |
|
| 2099 | - */ |
|
| 2100 | - public function set_customer_id( $value ) { |
|
| 2101 | - $this->set_author( $value ); |
|
| 2125 | + * Set the customer's first name. |
|
| 2126 | + * |
|
| 2127 | + * @since 1.0.19 |
|
| 2128 | + * @param string $value first name. |
|
| 2129 | + */ |
|
| 2130 | + public function set_first_name( $value ) { |
|
| 2131 | + $this->set_prop( 'first_name', $value ); |
|
| 2102 | 2132 | } |
| 2103 | 2133 | |
| 2104 | 2134 | /** |
| 2105 | - * Set the customer's ip. |
|
| 2106 | - * |
|
| 2107 | - * @since 1.0.19 |
|
| 2108 | - * @param string $value ip address. |
|
| 2109 | - */ |
|
| 2110 | - public function set_ip( $value ) { |
|
| 2111 | - $this->set_prop( 'ip', $value ); |
|
| 2135 | + * Alias of self::set_first_name(). |
|
| 2136 | + * |
|
| 2137 | + * @since 1.0.19 |
|
| 2138 | + * @param string $value first name. |
|
| 2139 | + */ |
|
| 2140 | + public function set_user_first_name( $value ) { |
|
| 2141 | + $this->set_first_name( $value ); |
|
| 2112 | 2142 | } |
| 2113 | 2143 | |
| 2114 | 2144 | /** |
| 2115 | - * Alias of self::set_ip(). |
|
| 2116 | - * |
|
| 2117 | - * @since 1.0.19 |
|
| 2118 | - * @param string $value ip address. |
|
| 2119 | - */ |
|
| 2120 | - public function set_user_ip( $value ) { |
|
| 2121 | - $this->set_ip( $value ); |
|
| 2145 | + * Alias of self::set_first_name(). |
|
| 2146 | + * |
|
| 2147 | + * @since 1.0.19 |
|
| 2148 | + * @param string $value first name. |
|
| 2149 | + */ |
|
| 2150 | + public function set_customer_first_name( $value ) { |
|
| 2151 | + $this->set_first_name( $value ); |
|
| 2122 | 2152 | } |
| 2123 | 2153 | |
| 2124 | 2154 | /** |
| 2125 | - * Set the customer's first name. |
|
| 2126 | - * |
|
| 2127 | - * @since 1.0.19 |
|
| 2128 | - * @param string $value first name. |
|
| 2129 | - */ |
|
| 2130 | - public function set_first_name( $value ) { |
|
| 2131 | - $this->set_prop( 'first_name', $value ); |
|
| 2155 | + * Set the customer's last name. |
|
| 2156 | + * |
|
| 2157 | + * @since 1.0.19 |
|
| 2158 | + * @param string $value last name. |
|
| 2159 | + */ |
|
| 2160 | + public function set_last_name( $value ) { |
|
| 2161 | + $this->set_prop( 'last_name', $value ); |
|
| 2132 | 2162 | } |
| 2133 | 2163 | |
| 2134 | 2164 | /** |
| 2135 | - * Alias of self::set_first_name(). |
|
| 2136 | - * |
|
| 2137 | - * @since 1.0.19 |
|
| 2138 | - * @param string $value first name. |
|
| 2139 | - */ |
|
| 2140 | - public function set_user_first_name( $value ) { |
|
| 2141 | - $this->set_first_name( $value ); |
|
| 2165 | + * Alias of self::set_last_name(). |
|
| 2166 | + * |
|
| 2167 | + * @since 1.0.19 |
|
| 2168 | + * @param string $value last name. |
|
| 2169 | + */ |
|
| 2170 | + public function set_user_last_name( $value ) { |
|
| 2171 | + $this->set_last_name( $value ); |
|
| 2142 | 2172 | } |
| 2143 | 2173 | |
| 2144 | 2174 | /** |
| 2145 | - * Alias of self::set_first_name(). |
|
| 2146 | - * |
|
| 2147 | - * @since 1.0.19 |
|
| 2148 | - * @param string $value first name. |
|
| 2149 | - */ |
|
| 2150 | - public function set_customer_first_name( $value ) { |
|
| 2151 | - $this->set_first_name( $value ); |
|
| 2175 | + * Alias of self::set_last_name(). |
|
| 2176 | + * |
|
| 2177 | + * @since 1.0.19 |
|
| 2178 | + * @param string $value last name. |
|
| 2179 | + */ |
|
| 2180 | + public function set_customer_last_name( $value ) { |
|
| 2181 | + $this->set_last_name( $value ); |
|
| 2152 | 2182 | } |
| 2153 | 2183 | |
| 2154 | 2184 | /** |
| 2155 | - * Set the customer's last name. |
|
| 2156 | - * |
|
| 2157 | - * @since 1.0.19 |
|
| 2158 | - * @param string $value last name. |
|
| 2159 | - */ |
|
| 2160 | - public function set_last_name( $value ) { |
|
| 2161 | - $this->set_prop( 'last_name', $value ); |
|
| 2185 | + * Set the customer's phone number. |
|
| 2186 | + * |
|
| 2187 | + * @since 1.0.19 |
|
| 2188 | + * @param string $value phone. |
|
| 2189 | + */ |
|
| 2190 | + public function set_phone( $value ) { |
|
| 2191 | + $this->set_prop( 'phone', $value ); |
|
| 2162 | 2192 | } |
| 2163 | 2193 | |
| 2164 | 2194 | /** |
| 2165 | - * Alias of self::set_last_name(). |
|
| 2166 | - * |
|
| 2167 | - * @since 1.0.19 |
|
| 2168 | - * @param string $value last name. |
|
| 2169 | - */ |
|
| 2170 | - public function set_user_last_name( $value ) { |
|
| 2171 | - $this->set_last_name( $value ); |
|
| 2195 | + * Alias of self::set_phone(). |
|
| 2196 | + * |
|
| 2197 | + * @since 1.0.19 |
|
| 2198 | + * @param string $value phone. |
|
| 2199 | + */ |
|
| 2200 | + public function set_user_phone( $value ) { |
|
| 2201 | + $this->set_phone( $value ); |
|
| 2172 | 2202 | } |
| 2173 | 2203 | |
| 2174 | 2204 | /** |
| 2175 | - * Alias of self::set_last_name(). |
|
| 2176 | - * |
|
| 2177 | - * @since 1.0.19 |
|
| 2178 | - * @param string $value last name. |
|
| 2179 | - */ |
|
| 2180 | - public function set_customer_last_name( $value ) { |
|
| 2181 | - $this->set_last_name( $value ); |
|
| 2205 | + * Alias of self::set_phone(). |
|
| 2206 | + * |
|
| 2207 | + * @since 1.0.19 |
|
| 2208 | + * @param string $value phone. |
|
| 2209 | + */ |
|
| 2210 | + public function set_customer_phone( $value ) { |
|
| 2211 | + $this->set_phone( $value ); |
|
| 2182 | 2212 | } |
| 2183 | 2213 | |
| 2184 | 2214 | /** |
| 2185 | - * Set the customer's phone number. |
|
| 2186 | - * |
|
| 2187 | - * @since 1.0.19 |
|
| 2188 | - * @param string $value phone. |
|
| 2189 | - */ |
|
| 2190 | - public function set_phone( $value ) { |
|
| 2191 | - $this->set_prop( 'phone', $value ); |
|
| 2215 | + * Alias of self::set_phone(). |
|
| 2216 | + * |
|
| 2217 | + * @since 1.0.19 |
|
| 2218 | + * @param string $value phone. |
|
| 2219 | + */ |
|
| 2220 | + public function set_phone_number( $value ) { |
|
| 2221 | + $this->set_phone( $value ); |
|
| 2192 | 2222 | } |
| 2193 | 2223 | |
| 2194 | 2224 | /** |
| 2195 | - * Alias of self::set_phone(). |
|
| 2196 | - * |
|
| 2197 | - * @since 1.0.19 |
|
| 2198 | - * @param string $value phone. |
|
| 2199 | - */ |
|
| 2200 | - public function set_user_phone( $value ) { |
|
| 2201 | - $this->set_phone( $value ); |
|
| 2225 | + * Set the customer's email address. |
|
| 2226 | + * |
|
| 2227 | + * @since 1.0.19 |
|
| 2228 | + * @param string $value email address. |
|
| 2229 | + */ |
|
| 2230 | + public function set_email( $value ) { |
|
| 2231 | + $this->set_prop( 'email', $value ); |
|
| 2202 | 2232 | } |
| 2203 | 2233 | |
| 2204 | 2234 | /** |
| 2205 | - * Alias of self::set_phone(). |
|
| 2206 | - * |
|
| 2207 | - * @since 1.0.19 |
|
| 2208 | - * @param string $value phone. |
|
| 2209 | - */ |
|
| 2210 | - public function set_customer_phone( $value ) { |
|
| 2211 | - $this->set_phone( $value ); |
|
| 2235 | + * Alias of self::set_email(). |
|
| 2236 | + * |
|
| 2237 | + * @since 1.0.19 |
|
| 2238 | + * @param string $value email address. |
|
| 2239 | + */ |
|
| 2240 | + public function set_user_email( $value ) { |
|
| 2241 | + $this->set_email( $value ); |
|
| 2212 | 2242 | } |
| 2213 | 2243 | |
| 2214 | 2244 | /** |
| 2215 | - * Alias of self::set_phone(). |
|
| 2216 | - * |
|
| 2217 | - * @since 1.0.19 |
|
| 2218 | - * @param string $value phone. |
|
| 2219 | - */ |
|
| 2220 | - public function set_phone_number( $value ) { |
|
| 2221 | - $this->set_phone( $value ); |
|
| 2245 | + * Alias of self::set_email(). |
|
| 2246 | + * |
|
| 2247 | + * @since 1.0.19 |
|
| 2248 | + * @param string $value email address. |
|
| 2249 | + */ |
|
| 2250 | + public function set_email_address( $value ) { |
|
| 2251 | + $this->set_email( $value ); |
|
| 2222 | 2252 | } |
| 2223 | 2253 | |
| 2224 | 2254 | /** |
| 2225 | - * Set the customer's email address. |
|
| 2226 | - * |
|
| 2227 | - * @since 1.0.19 |
|
| 2228 | - * @param string $value email address. |
|
| 2229 | - */ |
|
| 2230 | - public function set_email( $value ) { |
|
| 2231 | - $this->set_prop( 'email', $value ); |
|
| 2255 | + * Alias of self::set_email(). |
|
| 2256 | + * |
|
| 2257 | + * @since 1.0.19 |
|
| 2258 | + * @param string $value email address. |
|
| 2259 | + */ |
|
| 2260 | + public function set_customer_email( $value ) { |
|
| 2261 | + $this->set_email( $value ); |
|
| 2232 | 2262 | } |
| 2233 | 2263 | |
| 2234 | 2264 | /** |
| 2235 | - * Alias of self::set_email(). |
|
| 2236 | - * |
|
| 2237 | - * @since 1.0.19 |
|
| 2238 | - * @param string $value email address. |
|
| 2239 | - */ |
|
| 2240 | - public function set_user_email( $value ) { |
|
| 2241 | - $this->set_email( $value ); |
|
| 2265 | + * Set the customer's country. |
|
| 2266 | + * |
|
| 2267 | + * @since 1.0.19 |
|
| 2268 | + * @param string $value country. |
|
| 2269 | + */ |
|
| 2270 | + public function set_country( $value ) { |
|
| 2271 | + $this->set_prop( 'country', $value ); |
|
| 2242 | 2272 | } |
| 2243 | 2273 | |
| 2244 | 2274 | /** |
| 2245 | - * Alias of self::set_email(). |
|
| 2246 | - * |
|
| 2247 | - * @since 1.0.19 |
|
| 2248 | - * @param string $value email address. |
|
| 2249 | - */ |
|
| 2250 | - public function set_email_address( $value ) { |
|
| 2251 | - $this->set_email( $value ); |
|
| 2275 | + * Alias of self::set_country(). |
|
| 2276 | + * |
|
| 2277 | + * @since 1.0.19 |
|
| 2278 | + * @param string $value country. |
|
| 2279 | + */ |
|
| 2280 | + public function set_user_country( $value ) { |
|
| 2281 | + $this->set_country( $value ); |
|
| 2252 | 2282 | } |
| 2253 | 2283 | |
| 2254 | 2284 | /** |
| 2255 | - * Alias of self::set_email(). |
|
| 2256 | - * |
|
| 2257 | - * @since 1.0.19 |
|
| 2258 | - * @param string $value email address. |
|
| 2259 | - */ |
|
| 2260 | - public function set_customer_email( $value ) { |
|
| 2261 | - $this->set_email( $value ); |
|
| 2285 | + * Alias of self::set_country(). |
|
| 2286 | + * |
|
| 2287 | + * @since 1.0.19 |
|
| 2288 | + * @param string $value country. |
|
| 2289 | + */ |
|
| 2290 | + public function set_customer_country( $value ) { |
|
| 2291 | + $this->set_country( $value ); |
|
| 2262 | 2292 | } |
| 2263 | 2293 | |
| 2264 | 2294 | /** |
| 2265 | - * Set the customer's country. |
|
| 2266 | - * |
|
| 2267 | - * @since 1.0.19 |
|
| 2268 | - * @param string $value country. |
|
| 2269 | - */ |
|
| 2270 | - public function set_country( $value ) { |
|
| 2271 | - $this->set_prop( 'country', $value ); |
|
| 2295 | + * Set the customer's state. |
|
| 2296 | + * |
|
| 2297 | + * @since 1.0.19 |
|
| 2298 | + * @param string $value state. |
|
| 2299 | + */ |
|
| 2300 | + public function set_state( $value ) { |
|
| 2301 | + $this->set_prop( 'state', $value ); |
|
| 2272 | 2302 | } |
| 2273 | 2303 | |
| 2274 | 2304 | /** |
| 2275 | - * Alias of self::set_country(). |
|
| 2276 | - * |
|
| 2277 | - * @since 1.0.19 |
|
| 2278 | - * @param string $value country. |
|
| 2279 | - */ |
|
| 2280 | - public function set_user_country( $value ) { |
|
| 2281 | - $this->set_country( $value ); |
|
| 2305 | + * Alias of self::set_state(). |
|
| 2306 | + * |
|
| 2307 | + * @since 1.0.19 |
|
| 2308 | + * @param string $value state. |
|
| 2309 | + */ |
|
| 2310 | + public function set_user_state( $value ) { |
|
| 2311 | + $this->set_state( $value ); |
|
| 2282 | 2312 | } |
| 2283 | 2313 | |
| 2284 | 2314 | /** |
| 2285 | - * Alias of self::set_country(). |
|
| 2286 | - * |
|
| 2287 | - * @since 1.0.19 |
|
| 2288 | - * @param string $value country. |
|
| 2289 | - */ |
|
| 2290 | - public function set_customer_country( $value ) { |
|
| 2291 | - $this->set_country( $value ); |
|
| 2315 | + * Alias of self::set_state(). |
|
| 2316 | + * |
|
| 2317 | + * @since 1.0.19 |
|
| 2318 | + * @param string $value state. |
|
| 2319 | + */ |
|
| 2320 | + public function set_customer_state( $value ) { |
|
| 2321 | + $this->set_state( $value ); |
|
| 2292 | 2322 | } |
| 2293 | 2323 | |
| 2294 | 2324 | /** |
| 2295 | - * Set the customer's state. |
|
| 2296 | - * |
|
| 2297 | - * @since 1.0.19 |
|
| 2298 | - * @param string $value state. |
|
| 2299 | - */ |
|
| 2300 | - public function set_state( $value ) { |
|
| 2301 | - $this->set_prop( 'state', $value ); |
|
| 2325 | + * Set the customer's city. |
|
| 2326 | + * |
|
| 2327 | + * @since 1.0.19 |
|
| 2328 | + * @param string $value city. |
|
| 2329 | + */ |
|
| 2330 | + public function set_city( $value ) { |
|
| 2331 | + $this->set_prop( 'city', $value ); |
|
| 2302 | 2332 | } |
| 2303 | 2333 | |
| 2304 | 2334 | /** |
| 2305 | - * Alias of self::set_state(). |
|
| 2306 | - * |
|
| 2307 | - * @since 1.0.19 |
|
| 2308 | - * @param string $value state. |
|
| 2309 | - */ |
|
| 2310 | - public function set_user_state( $value ) { |
|
| 2311 | - $this->set_state( $value ); |
|
| 2335 | + * Alias of self::set_city(). |
|
| 2336 | + * |
|
| 2337 | + * @since 1.0.19 |
|
| 2338 | + * @param string $value city. |
|
| 2339 | + */ |
|
| 2340 | + public function set_user_city( $value ) { |
|
| 2341 | + $this->set_city( $value ); |
|
| 2312 | 2342 | } |
| 2313 | 2343 | |
| 2314 | 2344 | /** |
| 2315 | - * Alias of self::set_state(). |
|
| 2316 | - * |
|
| 2317 | - * @since 1.0.19 |
|
| 2318 | - * @param string $value state. |
|
| 2319 | - */ |
|
| 2320 | - public function set_customer_state( $value ) { |
|
| 2321 | - $this->set_state( $value ); |
|
| 2345 | + * Alias of self::set_city(). |
|
| 2346 | + * |
|
| 2347 | + * @since 1.0.19 |
|
| 2348 | + * @param string $value city. |
|
| 2349 | + */ |
|
| 2350 | + public function set_customer_city( $value ) { |
|
| 2351 | + $this->set_city( $value ); |
|
| 2322 | 2352 | } |
| 2323 | 2353 | |
| 2324 | 2354 | /** |
| 2325 | - * Set the customer's city. |
|
| 2326 | - * |
|
| 2327 | - * @since 1.0.19 |
|
| 2328 | - * @param string $value city. |
|
| 2329 | - */ |
|
| 2330 | - public function set_city( $value ) { |
|
| 2331 | - $this->set_prop( 'city', $value ); |
|
| 2355 | + * Set the customer's zip code. |
|
| 2356 | + * |
|
| 2357 | + * @since 1.0.19 |
|
| 2358 | + * @param string $value zip. |
|
| 2359 | + */ |
|
| 2360 | + public function set_zip( $value ) { |
|
| 2361 | + $this->set_prop( 'zip', $value ); |
|
| 2332 | 2362 | } |
| 2333 | 2363 | |
| 2334 | 2364 | /** |
| 2335 | - * Alias of self::set_city(). |
|
| 2336 | - * |
|
| 2337 | - * @since 1.0.19 |
|
| 2338 | - * @param string $value city. |
|
| 2339 | - */ |
|
| 2340 | - public function set_user_city( $value ) { |
|
| 2341 | - $this->set_city( $value ); |
|
| 2365 | + * Alias of self::set_zip(). |
|
| 2366 | + * |
|
| 2367 | + * @since 1.0.19 |
|
| 2368 | + * @param string $value zip. |
|
| 2369 | + */ |
|
| 2370 | + public function set_user_zip( $value ) { |
|
| 2371 | + $this->set_zip( $value ); |
|
| 2342 | 2372 | } |
| 2343 | 2373 | |
| 2344 | 2374 | /** |
| 2345 | - * Alias of self::set_city(). |
|
| 2346 | - * |
|
| 2347 | - * @since 1.0.19 |
|
| 2348 | - * @param string $value city. |
|
| 2349 | - */ |
|
| 2350 | - public function set_customer_city( $value ) { |
|
| 2351 | - $this->set_city( $value ); |
|
| 2375 | + * Alias of self::set_zip(). |
|
| 2376 | + * |
|
| 2377 | + * @since 1.0.19 |
|
| 2378 | + * @param string $value zip. |
|
| 2379 | + */ |
|
| 2380 | + public function set_customer_zip( $value ) { |
|
| 2381 | + $this->set_zip( $value ); |
|
| 2352 | 2382 | } |
| 2353 | 2383 | |
| 2354 | 2384 | /** |
| 2355 | - * Set the customer's zip code. |
|
| 2356 | - * |
|
| 2357 | - * @since 1.0.19 |
|
| 2358 | - * @param string $value zip. |
|
| 2359 | - */ |
|
| 2360 | - public function set_zip( $value ) { |
|
| 2361 | - $this->set_prop( 'zip', $value ); |
|
| 2385 | + * Set the customer's company. |
|
| 2386 | + * |
|
| 2387 | + * @since 1.0.19 |
|
| 2388 | + * @param string $value company. |
|
| 2389 | + */ |
|
| 2390 | + public function set_company( $value ) { |
|
| 2391 | + $this->set_prop( 'company', $value ); |
|
| 2362 | 2392 | } |
| 2363 | 2393 | |
| 2364 | 2394 | /** |
| 2365 | - * Alias of self::set_zip(). |
|
| 2366 | - * |
|
| 2367 | - * @since 1.0.19 |
|
| 2368 | - * @param string $value zip. |
|
| 2369 | - */ |
|
| 2370 | - public function set_user_zip( $value ) { |
|
| 2371 | - $this->set_zip( $value ); |
|
| 2395 | + * Alias of self::set_company(). |
|
| 2396 | + * |
|
| 2397 | + * @since 1.0.19 |
|
| 2398 | + * @param string $value company. |
|
| 2399 | + */ |
|
| 2400 | + public function set_user_company( $value ) { |
|
| 2401 | + $this->set_company( $value ); |
|
| 2372 | 2402 | } |
| 2373 | 2403 | |
| 2374 | 2404 | /** |
| 2375 | - * Alias of self::set_zip(). |
|
| 2376 | - * |
|
| 2377 | - * @since 1.0.19 |
|
| 2378 | - * @param string $value zip. |
|
| 2379 | - */ |
|
| 2380 | - public function set_customer_zip( $value ) { |
|
| 2381 | - $this->set_zip( $value ); |
|
| 2405 | + * Alias of self::set_company(). |
|
| 2406 | + * |
|
| 2407 | + * @since 1.0.19 |
|
| 2408 | + * @param string $value company. |
|
| 2409 | + */ |
|
| 2410 | + public function set_customer_company( $value ) { |
|
| 2411 | + $this->set_company( $value ); |
|
| 2382 | 2412 | } |
| 2383 | 2413 | |
| 2384 | 2414 | /** |
| 2385 | - * Set the customer's company. |
|
| 2386 | - * |
|
| 2387 | - * @since 1.0.19 |
|
| 2388 | - * @param string $value company. |
|
| 2389 | - */ |
|
| 2390 | - public function set_company( $value ) { |
|
| 2391 | - $this->set_prop( 'company', $value ); |
|
| 2415 | + * Set the customer's var number. |
|
| 2416 | + * |
|
| 2417 | + * @since 1.0.19 |
|
| 2418 | + * @param string $value var number. |
|
| 2419 | + */ |
|
| 2420 | + public function set_vat_number( $value ) { |
|
| 2421 | + $this->set_prop( 'vat_number', $value ); |
|
| 2392 | 2422 | } |
| 2393 | 2423 | |
| 2394 | 2424 | /** |
| 2395 | - * Alias of self::set_company(). |
|
| 2396 | - * |
|
| 2397 | - * @since 1.0.19 |
|
| 2398 | - * @param string $value company. |
|
| 2399 | - */ |
|
| 2400 | - public function set_user_company( $value ) { |
|
| 2401 | - $this->set_company( $value ); |
|
| 2425 | + * Alias of self::set_vat_number(). |
|
| 2426 | + * |
|
| 2427 | + * @since 1.0.19 |
|
| 2428 | + * @param string $value var number. |
|
| 2429 | + */ |
|
| 2430 | + public function set_user_vat_number( $value ) { |
|
| 2431 | + $this->set_vat_number( $value ); |
|
| 2402 | 2432 | } |
| 2403 | 2433 | |
| 2404 | 2434 | /** |
| 2405 | - * Alias of self::set_company(). |
|
| 2406 | - * |
|
| 2407 | - * @since 1.0.19 |
|
| 2408 | - * @param string $value company. |
|
| 2409 | - */ |
|
| 2410 | - public function set_customer_company( $value ) { |
|
| 2411 | - $this->set_company( $value ); |
|
| 2435 | + * Alias of self::set_vat_number(). |
|
| 2436 | + * |
|
| 2437 | + * @since 1.0.19 |
|
| 2438 | + * @param string $value var number. |
|
| 2439 | + */ |
|
| 2440 | + public function set_customer_vat_number( $value ) { |
|
| 2441 | + $this->set_vat_number( $value ); |
|
| 2412 | 2442 | } |
| 2413 | 2443 | |
| 2414 | 2444 | /** |
| 2415 | - * Set the customer's var number. |
|
| 2416 | - * |
|
| 2417 | - * @since 1.0.19 |
|
| 2418 | - * @param string $value var number. |
|
| 2419 | - */ |
|
| 2420 | - public function set_vat_number( $value ) { |
|
| 2421 | - $this->set_prop( 'vat_number', $value ); |
|
| 2445 | + * Set the customer's vat rate. |
|
| 2446 | + * |
|
| 2447 | + * @since 1.0.19 |
|
| 2448 | + * @param string $value var rate. |
|
| 2449 | + */ |
|
| 2450 | + public function set_vat_rate( $value ) { |
|
| 2451 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2422 | 2452 | } |
| 2423 | 2453 | |
| 2424 | 2454 | /** |
| 2425 | - * Alias of self::set_vat_number(). |
|
| 2426 | - * |
|
| 2427 | - * @since 1.0.19 |
|
| 2428 | - * @param string $value var number. |
|
| 2429 | - */ |
|
| 2430 | - public function set_user_vat_number( $value ) { |
|
| 2431 | - $this->set_vat_number( $value ); |
|
| 2455 | + * Alias of self::set_vat_rate(). |
|
| 2456 | + * |
|
| 2457 | + * @since 1.0.19 |
|
| 2458 | + * @param string $value var number. |
|
| 2459 | + */ |
|
| 2460 | + public function set_user_vat_rate( $value ) { |
|
| 2461 | + $this->set_vat_rate( $value ); |
|
| 2432 | 2462 | } |
| 2433 | 2463 | |
| 2434 | 2464 | /** |
| 2435 | - * Alias of self::set_vat_number(). |
|
| 2436 | - * |
|
| 2437 | - * @since 1.0.19 |
|
| 2438 | - * @param string $value var number. |
|
| 2439 | - */ |
|
| 2440 | - public function set_customer_vat_number( $value ) { |
|
| 2441 | - $this->set_vat_number( $value ); |
|
| 2465 | + * Alias of self::set_vat_rate(). |
|
| 2466 | + * |
|
| 2467 | + * @since 1.0.19 |
|
| 2468 | + * @param string $value var number. |
|
| 2469 | + */ |
|
| 2470 | + public function set_customer_vat_rate( $value ) { |
|
| 2471 | + $this->set_vat_rate( $value ); |
|
| 2442 | 2472 | } |
| 2443 | 2473 | |
| 2444 | 2474 | /** |
| 2445 | - * Set the customer's vat rate. |
|
| 2446 | - * |
|
| 2447 | - * @since 1.0.19 |
|
| 2448 | - * @param string $value var rate. |
|
| 2449 | - */ |
|
| 2450 | - public function set_vat_rate( $value ) { |
|
| 2451 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2475 | + * Set the customer's address. |
|
| 2476 | + * |
|
| 2477 | + * @since 1.0.19 |
|
| 2478 | + * @param string $value address. |
|
| 2479 | + */ |
|
| 2480 | + public function set_address( $value ) { |
|
| 2481 | + $this->set_prop( 'address', $value ); |
|
| 2452 | 2482 | } |
| 2453 | 2483 | |
| 2454 | 2484 | /** |
| 2455 | - * Alias of self::set_vat_rate(). |
|
| 2456 | - * |
|
| 2457 | - * @since 1.0.19 |
|
| 2458 | - * @param string $value var number. |
|
| 2459 | - */ |
|
| 2460 | - public function set_user_vat_rate( $value ) { |
|
| 2461 | - $this->set_vat_rate( $value ); |
|
| 2485 | + * Alias of self::set_address(). |
|
| 2486 | + * |
|
| 2487 | + * @since 1.0.19 |
|
| 2488 | + * @param string $value address. |
|
| 2489 | + */ |
|
| 2490 | + public function set_user_address( $value ) { |
|
| 2491 | + $this->set_address( $value ); |
|
| 2462 | 2492 | } |
| 2463 | 2493 | |
| 2464 | 2494 | /** |
| 2465 | - * Alias of self::set_vat_rate(). |
|
| 2466 | - * |
|
| 2467 | - * @since 1.0.19 |
|
| 2468 | - * @param string $value var number. |
|
| 2469 | - */ |
|
| 2470 | - public function set_customer_vat_rate( $value ) { |
|
| 2471 | - $this->set_vat_rate( $value ); |
|
| 2495 | + * Alias of self::set_address(). |
|
| 2496 | + * |
|
| 2497 | + * @since 1.0.19 |
|
| 2498 | + * @param string $value address. |
|
| 2499 | + */ |
|
| 2500 | + public function set_customer_address( $value ) { |
|
| 2501 | + $this->set_address( $value ); |
|
| 2472 | 2502 | } |
| 2473 | 2503 | |
| 2474 | 2504 | /** |
| 2475 | - * Set the customer's address. |
|
| 2476 | - * |
|
| 2477 | - * @since 1.0.19 |
|
| 2478 | - * @param string $value address. |
|
| 2479 | - */ |
|
| 2480 | - public function set_address( $value ) { |
|
| 2481 | - $this->set_prop( 'address', $value ); |
|
| 2505 | + * Set whether the customer has viewed the invoice or not. |
|
| 2506 | + * |
|
| 2507 | + * @since 1.0.19 |
|
| 2508 | + * @param int|bool $value confirmed. |
|
| 2509 | + */ |
|
| 2510 | + public function set_is_viewed( $value ) { |
|
| 2511 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2482 | 2512 | } |
| 2483 | 2513 | |
| 2484 | 2514 | /** |
| 2485 | - * Alias of self::set_address(). |
|
| 2486 | - * |
|
| 2487 | - * @since 1.0.19 |
|
| 2488 | - * @param string $value address. |
|
| 2489 | - */ |
|
| 2490 | - public function set_user_address( $value ) { |
|
| 2491 | - $this->set_address( $value ); |
|
| 2515 | + * Set extra email recipients. |
|
| 2516 | + * |
|
| 2517 | + * @since 1.0.19 |
|
| 2518 | + * @param string $value email recipients. |
|
| 2519 | + */ |
|
| 2520 | + public function set_email_cc( $value ) { |
|
| 2521 | + $this->set_prop( 'email_cc', $value ); |
|
| 2492 | 2522 | } |
| 2493 | 2523 | |
| 2494 | 2524 | /** |
| 2495 | - * Alias of self::set_address(). |
|
| 2496 | - * |
|
| 2497 | - * @since 1.0.19 |
|
| 2498 | - * @param string $value address. |
|
| 2499 | - */ |
|
| 2500 | - public function set_customer_address( $value ) { |
|
| 2501 | - $this->set_address( $value ); |
|
| 2525 | + * Set the invoice template. |
|
| 2526 | + * |
|
| 2527 | + * @since 1.0.19 |
|
| 2528 | + * @param string $value email recipients. |
|
| 2529 | + */ |
|
| 2530 | + public function set_template( $value ) { |
|
| 2531 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2532 | + $this->set_prop( 'template', $value ); |
|
| 2533 | + } |
|
| 2502 | 2534 | } |
| 2503 | 2535 | |
| 2504 | 2536 | /** |
| 2505 | - * Set whether the customer has viewed the invoice or not. |
|
| 2506 | - * |
|
| 2507 | - * @since 1.0.19 |
|
| 2508 | - * @param int|bool $value confirmed. |
|
| 2509 | - */ |
|
| 2510 | - public function set_is_viewed( $value ) { |
|
| 2511 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2512 | - } |
|
| 2513 | - |
|
| 2514 | - /** |
|
| 2515 | - * Set extra email recipients. |
|
| 2516 | - * |
|
| 2517 | - * @since 1.0.19 |
|
| 2518 | - * @param string $value email recipients. |
|
| 2519 | - */ |
|
| 2520 | - public function set_email_cc( $value ) { |
|
| 2521 | - $this->set_prop( 'email_cc', $value ); |
|
| 2522 | - } |
|
| 2523 | - |
|
| 2524 | - /** |
|
| 2525 | - * Set the invoice template. |
|
| 2526 | - * |
|
| 2527 | - * @since 1.0.19 |
|
| 2528 | - * @param string $value email recipients. |
|
| 2529 | - */ |
|
| 2530 | - public function set_template( $value ) { |
|
| 2531 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2532 | - $this->set_prop( 'template', $value ); |
|
| 2533 | - } |
|
| 2534 | - } |
|
| 2535 | - |
|
| 2536 | - /** |
|
| 2537 | - * Set the customer's address confirmed status. |
|
| 2538 | - * |
|
| 2539 | - * @since 1.0.19 |
|
| 2540 | - * @param int|bool $value confirmed. |
|
| 2541 | - */ |
|
| 2542 | - public function set_address_confirmed( $value ) { |
|
| 2543 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2537 | + * Set the customer's address confirmed status. |
|
| 2538 | + * |
|
| 2539 | + * @since 1.0.19 |
|
| 2540 | + * @param int|bool $value confirmed. |
|
| 2541 | + */ |
|
| 2542 | + public function set_address_confirmed( $value ) { |
|
| 2543 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | 2546 | /** |
| 2547 | - * Alias of self::set_address_confirmed(). |
|
| 2548 | - * |
|
| 2549 | - * @since 1.0.19 |
|
| 2550 | - * @param int|bool $value confirmed. |
|
| 2551 | - */ |
|
| 2552 | - public function set_user_address_confirmed( $value ) { |
|
| 2553 | - $this->set_address_confirmed( $value ); |
|
| 2547 | + * Alias of self::set_address_confirmed(). |
|
| 2548 | + * |
|
| 2549 | + * @since 1.0.19 |
|
| 2550 | + * @param int|bool $value confirmed. |
|
| 2551 | + */ |
|
| 2552 | + public function set_user_address_confirmed( $value ) { |
|
| 2553 | + $this->set_address_confirmed( $value ); |
|
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | 2556 | /** |
| 2557 | - * Alias of self::set_address_confirmed(). |
|
| 2558 | - * |
|
| 2559 | - * @since 1.0.19 |
|
| 2560 | - * @param int|bool $value confirmed. |
|
| 2561 | - */ |
|
| 2562 | - public function set_customer_address_confirmed( $value ) { |
|
| 2563 | - $this->set_address_confirmed( $value ); |
|
| 2557 | + * Alias of self::set_address_confirmed(). |
|
| 2558 | + * |
|
| 2559 | + * @since 1.0.19 |
|
| 2560 | + * @param int|bool $value confirmed. |
|
| 2561 | + */ |
|
| 2562 | + public function set_customer_address_confirmed( $value ) { |
|
| 2563 | + $this->set_address_confirmed( $value ); |
|
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | 2566 | /** |
| 2567 | - * Set the invoice sub total. |
|
| 2568 | - * |
|
| 2569 | - * @since 1.0.19 |
|
| 2570 | - * @param float $value sub total. |
|
| 2571 | - */ |
|
| 2572 | - public function set_subtotal( $value ) { |
|
| 2573 | - $this->set_prop( 'subtotal', $value ); |
|
| 2567 | + * Set the invoice sub total. |
|
| 2568 | + * |
|
| 2569 | + * @since 1.0.19 |
|
| 2570 | + * @param float $value sub total. |
|
| 2571 | + */ |
|
| 2572 | + public function set_subtotal( $value ) { |
|
| 2573 | + $this->set_prop( 'subtotal', $value ); |
|
| 2574 | 2574 | } |
| 2575 | 2575 | |
| 2576 | 2576 | /** |
| 2577 | - * Set the invoice discount amount. |
|
| 2578 | - * |
|
| 2579 | - * @since 1.0.19 |
|
| 2580 | - * @param float $value discount total. |
|
| 2581 | - */ |
|
| 2582 | - public function set_total_discount( $value ) { |
|
| 2583 | - $this->set_prop( 'total_discount', $value ); |
|
| 2577 | + * Set the invoice discount amount. |
|
| 2578 | + * |
|
| 2579 | + * @since 1.0.19 |
|
| 2580 | + * @param float $value discount total. |
|
| 2581 | + */ |
|
| 2582 | + public function set_total_discount( $value ) { |
|
| 2583 | + $this->set_prop( 'total_discount', $value ); |
|
| 2584 | 2584 | } |
| 2585 | 2585 | |
| 2586 | 2586 | /** |
| 2587 | - * Alias of self::set_total_discount(). |
|
| 2588 | - * |
|
| 2589 | - * @since 1.0.19 |
|
| 2590 | - * @param float $value discount total. |
|
| 2591 | - */ |
|
| 2592 | - public function set_discount( $value ) { |
|
| 2593 | - $this->set_total_discount( $value ); |
|
| 2587 | + * Alias of self::set_total_discount(). |
|
| 2588 | + * |
|
| 2589 | + * @since 1.0.19 |
|
| 2590 | + * @param float $value discount total. |
|
| 2591 | + */ |
|
| 2592 | + public function set_discount( $value ) { |
|
| 2593 | + $this->set_total_discount( $value ); |
|
| 2594 | 2594 | } |
| 2595 | 2595 | |
| 2596 | 2596 | /** |
| 2597 | - * Set the invoice tax amount. |
|
| 2598 | - * |
|
| 2599 | - * @since 1.0.19 |
|
| 2600 | - * @param float $value tax total. |
|
| 2601 | - */ |
|
| 2602 | - public function set_total_tax( $value ) { |
|
| 2603 | - $this->set_prop( 'total_tax', $value ); |
|
| 2597 | + * Set the invoice tax amount. |
|
| 2598 | + * |
|
| 2599 | + * @since 1.0.19 |
|
| 2600 | + * @param float $value tax total. |
|
| 2601 | + */ |
|
| 2602 | + public function set_total_tax( $value ) { |
|
| 2603 | + $this->set_prop( 'total_tax', $value ); |
|
| 2604 | 2604 | } |
| 2605 | 2605 | |
| 2606 | 2606 | /** |
| 2607 | - * Alias of self::set_total_tax(). |
|
| 2608 | - * |
|
| 2609 | - * @since 1.0.19 |
|
| 2610 | - * @param float $value tax total. |
|
| 2611 | - */ |
|
| 2612 | - public function set_tax_total( $value ) { |
|
| 2613 | - $this->set_total_tax( $value ); |
|
| 2607 | + * Alias of self::set_total_tax(). |
|
| 2608 | + * |
|
| 2609 | + * @since 1.0.19 |
|
| 2610 | + * @param float $value tax total. |
|
| 2611 | + */ |
|
| 2612 | + public function set_tax_total( $value ) { |
|
| 2613 | + $this->set_total_tax( $value ); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | |
| 2616 | 2616 | /** |
| 2617 | - * Set the invoice fees amount. |
|
| 2618 | - * |
|
| 2619 | - * @since 1.0.19 |
|
| 2620 | - * @param float $value fees total. |
|
| 2621 | - */ |
|
| 2622 | - public function set_total_fees( $value ) { |
|
| 2623 | - $this->set_prop( 'total_fees', $value ); |
|
| 2617 | + * Set the invoice fees amount. |
|
| 2618 | + * |
|
| 2619 | + * @since 1.0.19 |
|
| 2620 | + * @param float $value fees total. |
|
| 2621 | + */ |
|
| 2622 | + public function set_total_fees( $value ) { |
|
| 2623 | + $this->set_prop( 'total_fees', $value ); |
|
| 2624 | 2624 | } |
| 2625 | 2625 | |
| 2626 | 2626 | /** |
| 2627 | - * Alias of self::set_total_fees(). |
|
| 2628 | - * |
|
| 2629 | - * @since 1.0.19 |
|
| 2630 | - * @param float $value fees total. |
|
| 2631 | - */ |
|
| 2632 | - public function set_fees_total( $value ) { |
|
| 2633 | - $this->set_total_fees( $value ); |
|
| 2627 | + * Alias of self::set_total_fees(). |
|
| 2628 | + * |
|
| 2629 | + * @since 1.0.19 |
|
| 2630 | + * @param float $value fees total. |
|
| 2631 | + */ |
|
| 2632 | + public function set_fees_total( $value ) { |
|
| 2633 | + $this->set_total_fees( $value ); |
|
| 2634 | 2634 | } |
| 2635 | 2635 | |
| 2636 | 2636 | /** |
| 2637 | - * Set the invoice fees. |
|
| 2638 | - * |
|
| 2639 | - * @since 1.0.19 |
|
| 2640 | - * @param array $value fees. |
|
| 2641 | - */ |
|
| 2642 | - public function set_fees( $value ) { |
|
| 2637 | + * Set the invoice fees. |
|
| 2638 | + * |
|
| 2639 | + * @since 1.0.19 |
|
| 2640 | + * @param array $value fees. |
|
| 2641 | + */ |
|
| 2642 | + public function set_fees( $value ) { |
|
| 2643 | 2643 | |
| 2644 | 2644 | $this->set_prop( 'fees', array() ); |
| 2645 | 2645 | |
@@ -2657,23 +2657,23 @@ discard block |
||
| 2657 | 2657 | } |
| 2658 | 2658 | |
| 2659 | 2659 | /** |
| 2660 | - * Set the invoice taxes. |
|
| 2661 | - * |
|
| 2662 | - * @since 1.0.19 |
|
| 2663 | - * @param array $value taxes. |
|
| 2664 | - */ |
|
| 2665 | - public function set_taxes( $value ) { |
|
| 2666 | - $this->set_prop( 'taxes', $value ); |
|
| 2660 | + * Set the invoice taxes. |
|
| 2661 | + * |
|
| 2662 | + * @since 1.0.19 |
|
| 2663 | + * @param array $value taxes. |
|
| 2664 | + */ |
|
| 2665 | + public function set_taxes( $value ) { |
|
| 2666 | + $this->set_prop( 'taxes', $value ); |
|
| 2667 | 2667 | } |
| 2668 | 2668 | |
| 2669 | 2669 | /** |
| 2670 | - * Set the invoice discounts. |
|
| 2671 | - * |
|
| 2672 | - * @since 1.0.19 |
|
| 2673 | - * @param array $value discounts. |
|
| 2674 | - */ |
|
| 2675 | - public function set_discounts( $value ) { |
|
| 2676 | - $this->set_prop( 'discounts', array() ); |
|
| 2670 | + * Set the invoice discounts. |
|
| 2671 | + * |
|
| 2672 | + * @since 1.0.19 |
|
| 2673 | + * @param array $value discounts. |
|
| 2674 | + */ |
|
| 2675 | + public function set_discounts( $value ) { |
|
| 2676 | + $this->set_prop( 'discounts', array() ); |
|
| 2677 | 2677 | |
| 2678 | 2678 | // Ensure that we have an array. |
| 2679 | 2679 | if ( ! is_array( $value ) ) { |
@@ -2688,12 +2688,12 @@ discard block |
||
| 2688 | 2688 | } |
| 2689 | 2689 | |
| 2690 | 2690 | /** |
| 2691 | - * Set the invoice items. |
|
| 2692 | - * |
|
| 2693 | - * @since 1.0.19 |
|
| 2694 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2695 | - */ |
|
| 2696 | - public function set_items( $value ) { |
|
| 2691 | + * Set the invoice items. |
|
| 2692 | + * |
|
| 2693 | + * @since 1.0.19 |
|
| 2694 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2695 | + */ |
|
| 2696 | + public function set_items( $value ) { |
|
| 2697 | 2697 | |
| 2698 | 2698 | // Remove existing items. |
| 2699 | 2699 | $this->set_prop( 'items', array() ); |
@@ -2710,83 +2710,83 @@ discard block |
||
| 2710 | 2710 | } |
| 2711 | 2711 | |
| 2712 | 2712 | /** |
| 2713 | - * Set the payment form. |
|
| 2714 | - * |
|
| 2715 | - * @since 1.0.19 |
|
| 2716 | - * @param int $value payment form. |
|
| 2717 | - */ |
|
| 2718 | - public function set_payment_form( $value ) { |
|
| 2719 | - $this->set_prop( 'payment_form', $value ); |
|
| 2713 | + * Set the payment form. |
|
| 2714 | + * |
|
| 2715 | + * @since 1.0.19 |
|
| 2716 | + * @param int $value payment form. |
|
| 2717 | + */ |
|
| 2718 | + public function set_payment_form( $value ) { |
|
| 2719 | + $this->set_prop( 'payment_form', $value ); |
|
| 2720 | 2720 | } |
| 2721 | 2721 | |
| 2722 | 2722 | /** |
| 2723 | - * Set the submission id. |
|
| 2724 | - * |
|
| 2725 | - * @since 1.0.19 |
|
| 2726 | - * @param string $value submission id. |
|
| 2727 | - */ |
|
| 2728 | - public function set_submission_id( $value ) { |
|
| 2729 | - $this->set_prop( 'submission_id', $value ); |
|
| 2723 | + * Set the submission id. |
|
| 2724 | + * |
|
| 2725 | + * @since 1.0.19 |
|
| 2726 | + * @param string $value submission id. |
|
| 2727 | + */ |
|
| 2728 | + public function set_submission_id( $value ) { |
|
| 2729 | + $this->set_prop( 'submission_id', $value ); |
|
| 2730 | 2730 | } |
| 2731 | 2731 | |
| 2732 | 2732 | /** |
| 2733 | - * Set the discount code. |
|
| 2734 | - * |
|
| 2735 | - * @since 1.0.19 |
|
| 2736 | - * @param string $value discount code. |
|
| 2737 | - */ |
|
| 2738 | - public function set_discount_code( $value ) { |
|
| 2739 | - $this->set_prop( 'discount_code', $value ); |
|
| 2733 | + * Set the discount code. |
|
| 2734 | + * |
|
| 2735 | + * @since 1.0.19 |
|
| 2736 | + * @param string $value discount code. |
|
| 2737 | + */ |
|
| 2738 | + public function set_discount_code( $value ) { |
|
| 2739 | + $this->set_prop( 'discount_code', $value ); |
|
| 2740 | 2740 | } |
| 2741 | 2741 | |
| 2742 | 2742 | /** |
| 2743 | - * Set the gateway. |
|
| 2744 | - * |
|
| 2745 | - * @since 1.0.19 |
|
| 2746 | - * @param string $value gateway. |
|
| 2747 | - */ |
|
| 2748 | - public function set_gateway( $value ) { |
|
| 2749 | - $this->set_prop( 'gateway', $value ); |
|
| 2743 | + * Set the gateway. |
|
| 2744 | + * |
|
| 2745 | + * @since 1.0.19 |
|
| 2746 | + * @param string $value gateway. |
|
| 2747 | + */ |
|
| 2748 | + public function set_gateway( $value ) { |
|
| 2749 | + $this->set_prop( 'gateway', $value ); |
|
| 2750 | 2750 | } |
| 2751 | 2751 | |
| 2752 | 2752 | /** |
| 2753 | - * Set the transaction id. |
|
| 2754 | - * |
|
| 2755 | - * @since 1.0.19 |
|
| 2756 | - * @param string $value transaction id. |
|
| 2757 | - */ |
|
| 2758 | - public function set_transaction_id( $value ) { |
|
| 2759 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2753 | + * Set the transaction id. |
|
| 2754 | + * |
|
| 2755 | + * @since 1.0.19 |
|
| 2756 | + * @param string $value transaction id. |
|
| 2757 | + */ |
|
| 2758 | + public function set_transaction_id( $value ) { |
|
| 2759 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2760 | 2760 | } |
| 2761 | 2761 | |
| 2762 | 2762 | /** |
| 2763 | - * Set the currency id. |
|
| 2764 | - * |
|
| 2765 | - * @since 1.0.19 |
|
| 2766 | - * @param string $value currency id. |
|
| 2767 | - */ |
|
| 2768 | - public function set_currency( $value ) { |
|
| 2769 | - $this->set_prop( 'currency', $value ); |
|
| 2763 | + * Set the currency id. |
|
| 2764 | + * |
|
| 2765 | + * @since 1.0.19 |
|
| 2766 | + * @param string $value currency id. |
|
| 2767 | + */ |
|
| 2768 | + public function set_currency( $value ) { |
|
| 2769 | + $this->set_prop( 'currency', $value ); |
|
| 2770 | 2770 | } |
| 2771 | 2771 | |
| 2772 | - /** |
|
| 2773 | - * Set whether to disable taxes. |
|
| 2774 | - * |
|
| 2775 | - * @since 1.0.19 |
|
| 2776 | - * @param bool $value value. |
|
| 2777 | - */ |
|
| 2778 | - public function set_disable_taxes( $value ) { |
|
| 2779 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2780 | - } |
|
| 2772 | + /** |
|
| 2773 | + * Set whether to disable taxes. |
|
| 2774 | + * |
|
| 2775 | + * @since 1.0.19 |
|
| 2776 | + * @param bool $value value. |
|
| 2777 | + */ |
|
| 2778 | + public function set_disable_taxes( $value ) { |
|
| 2779 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2780 | + } |
|
| 2781 | 2781 | |
| 2782 | 2782 | /** |
| 2783 | - * Set the subscription id. |
|
| 2784 | - * |
|
| 2785 | - * @since 1.0.19 |
|
| 2786 | - * @param string $value subscription id. |
|
| 2787 | - */ |
|
| 2788 | - public function set_subscription_id( $value ) { |
|
| 2789 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2783 | + * Set the subscription id. |
|
| 2784 | + * |
|
| 2785 | + * @since 1.0.19 |
|
| 2786 | + * @param string $value subscription id. |
|
| 2787 | + */ |
|
| 2788 | + public function set_subscription_id( $value ) { |
|
| 2789 | + $this->set_prop( 'subscription_id', $value ); |
|
| 2790 | 2790 | } |
| 2791 | 2791 | |
| 2792 | 2792 | /* |
@@ -2825,12 +2825,12 @@ discard block |
||
| 2825 | 2825 | */ |
| 2826 | 2826 | public function is_taxable() { |
| 2827 | 2827 | return $this->get_disable_taxes(); |
| 2828 | - } |
|
| 2828 | + } |
|
| 2829 | 2829 | |
| 2830 | - /** |
|
| 2831 | - * @deprecated |
|
| 2832 | - */ |
|
| 2833 | - public function has_vat() { |
|
| 2830 | + /** |
|
| 2831 | + * @deprecated |
|
| 2832 | + */ |
|
| 2833 | + public function has_vat() { |
|
| 2834 | 2834 | global $wpinv_euvat, $wpi_country; |
| 2835 | 2835 | |
| 2836 | 2836 | $requires_vat = false; |
@@ -2841,17 +2841,17 @@ discard block |
||
| 2841 | 2841 | } |
| 2842 | 2842 | |
| 2843 | 2843 | return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
| 2844 | - } |
|
| 2844 | + } |
|
| 2845 | 2845 | |
| 2846 | - /** |
|
| 2847 | - * Checks to see if the invoice requires payment. |
|
| 2848 | - */ |
|
| 2849 | - public function is_free() { |
|
| 2846 | + /** |
|
| 2847 | + * Checks to see if the invoice requires payment. |
|
| 2848 | + */ |
|
| 2849 | + public function is_free() { |
|
| 2850 | 2850 | $is_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 2851 | 2851 | |
| 2852 | - if ( $is_free && $this->is_recurring() ) { |
|
| 2853 | - $is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 ); |
|
| 2854 | - } |
|
| 2852 | + if ( $is_free && $this->is_recurring() ) { |
|
| 2853 | + $is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 ); |
|
| 2854 | + } |
|
| 2855 | 2855 | |
| 2856 | 2856 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 2857 | 2857 | } |
@@ -2862,30 +2862,30 @@ discard block |
||
| 2862 | 2862 | public function is_paid() { |
| 2863 | 2863 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 2864 | 2864 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 2865 | - } |
|
| 2865 | + } |
|
| 2866 | 2866 | |
| 2867 | - /** |
|
| 2867 | + /** |
|
| 2868 | 2868 | * Checks if the invoice needs payment. |
| 2869 | 2869 | */ |
| 2870 | - public function needs_payment() { |
|
| 2871 | - $needs_payment = ! $this->is_paid() && ! $this->is_free(); |
|
| 2870 | + public function needs_payment() { |
|
| 2871 | + $needs_payment = ! $this->is_paid() && ! $this->is_free(); |
|
| 2872 | 2872 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | - /** |
|
| 2875 | + /** |
|
| 2876 | 2876 | * Checks if the invoice is refunded. |
| 2877 | 2877 | */ |
| 2878 | - public function is_refunded() { |
|
| 2878 | + public function is_refunded() { |
|
| 2879 | 2879 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 2880 | 2880 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 2881 | - } |
|
| 2881 | + } |
|
| 2882 | 2882 | |
| 2883 | - /** |
|
| 2883 | + /** |
|
| 2884 | 2884 | * Checks if the invoice is draft. |
| 2885 | 2885 | */ |
| 2886 | - public function is_draft() { |
|
| 2886 | + public function is_draft() { |
|
| 2887 | 2887 | return $this->has_status( 'draft, auto-draft' ); |
| 2888 | - } |
|
| 2888 | + } |
|
| 2889 | 2889 | |
| 2890 | 2890 | /** |
| 2891 | 2891 | * Checks if the invoice has a given status. |
@@ -2893,9 +2893,9 @@ discard block |
||
| 2893 | 2893 | public function has_status( $status ) { |
| 2894 | 2894 | $status = wpinv_parse_list( $status ); |
| 2895 | 2895 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 2896 | - } |
|
| 2896 | + } |
|
| 2897 | 2897 | |
| 2898 | - /** |
|
| 2898 | + /** |
|
| 2899 | 2899 | * Checks if the invoice is of a given type. |
| 2900 | 2900 | */ |
| 2901 | 2901 | public function is_type( $type ) { |
@@ -2918,25 +2918,25 @@ discard block |
||
| 2918 | 2918 | */ |
| 2919 | 2919 | public function has_free_trial() { |
| 2920 | 2920 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 2921 | - } |
|
| 2921 | + } |
|
| 2922 | 2922 | |
| 2923 | - /** |
|
| 2923 | + /** |
|
| 2924 | 2924 | * @deprecated |
| 2925 | 2925 | */ |
| 2926 | 2926 | public function is_free_trial() { |
| 2927 | 2927 | $this->has_free_trial(); |
| 2928 | 2928 | } |
| 2929 | 2929 | |
| 2930 | - /** |
|
| 2930 | + /** |
|
| 2931 | 2931 | * Check if the initial payment if 0. |
| 2932 | 2932 | * |
| 2933 | 2933 | */ |
| 2934 | - public function is_initial_free() { |
|
| 2934 | + public function is_initial_free() { |
|
| 2935 | 2935 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 2936 | 2936 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 2937 | 2937 | } |
| 2938 | 2938 | |
| 2939 | - /** |
|
| 2939 | + /** |
|
| 2940 | 2940 | * Check if the recurring item has a free trial. |
| 2941 | 2941 | * |
| 2942 | 2942 | */ |
@@ -2949,21 +2949,21 @@ discard block |
||
| 2949 | 2949 | |
| 2950 | 2950 | $item = new WPInv_Item( $this->recurring_item ); |
| 2951 | 2951 | return $item->has_free_trial(); |
| 2952 | - } |
|
| 2952 | + } |
|
| 2953 | 2953 | |
| 2954 | - /** |
|
| 2954 | + /** |
|
| 2955 | 2955 | * Check if the free trial is a result of a discount. |
| 2956 | 2956 | */ |
| 2957 | 2957 | public function is_free_trial_from_discount() { |
| 2958 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 2959 | - } |
|
| 2958 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 2959 | + } |
|
| 2960 | 2960 | |
| 2961 | - /** |
|
| 2961 | + /** |
|
| 2962 | 2962 | * @deprecated |
| 2963 | 2963 | */ |
| 2964 | 2964 | public function discount_first_payment_only() { |
| 2965 | 2965 | |
| 2966 | - $discount_code = $this->get_discount_code(); |
|
| 2966 | + $discount_code = $this->get_discount_code(); |
|
| 2967 | 2967 | if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
| 2968 | 2968 | return true; |
| 2969 | 2969 | } |
@@ -2995,19 +2995,19 @@ discard block |
||
| 2995 | 2995 | public function add_item( $item ) { |
| 2996 | 2996 | |
| 2997 | 2997 | // Make sure that it is available for purchase. |
| 2998 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 2999 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 2998 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 2999 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3000 | 3000 | } |
| 3001 | 3001 | |
| 3002 | 3002 | // Do we have a recurring item? |
| 3003 | - if ( $item->is_recurring() ) { |
|
| 3003 | + if ( $item->is_recurring() ) { |
|
| 3004 | 3004 | |
| 3005 | - // An invoice can only contain one recurring item. |
|
| 3006 | - if ( ! empty( $this->recurring_item ) ) { |
|
| 3007 | - return false; |
|
| 3008 | - } |
|
| 3005 | + // An invoice can only contain one recurring item. |
|
| 3006 | + if ( ! empty( $this->recurring_item ) ) { |
|
| 3007 | + return false; |
|
| 3008 | + } |
|
| 3009 | 3009 | |
| 3010 | - $this->recurring_item = $item->get_id(); |
|
| 3010 | + $this->recurring_item = $item->get_id(); |
|
| 3011 | 3011 | } |
| 3012 | 3012 | |
| 3013 | 3013 | // Invoice id. |
@@ -3018,25 +3018,25 @@ discard block |
||
| 3018 | 3018 | $items[ $item->get_id() ] = $item; |
| 3019 | 3019 | |
| 3020 | 3020 | $this->set_prop( 'items', $items ); |
| 3021 | - return true; |
|
| 3021 | + return true; |
|
| 3022 | 3022 | } |
| 3023 | 3023 | |
| 3024 | 3024 | /** |
| 3025 | - * Retrieves a specific item. |
|
| 3026 | - * |
|
| 3027 | - * @since 1.0.19 |
|
| 3028 | - */ |
|
| 3029 | - public function get_item( $item_id ) { |
|
| 3025 | + * Retrieves a specific item. |
|
| 3026 | + * |
|
| 3027 | + * @since 1.0.19 |
|
| 3028 | + */ |
|
| 3029 | + public function get_item( $item_id ) { |
|
| 3030 | 3030 | $items = $this->get_items(); |
| 3031 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3031 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3032 | 3032 | } |
| 3033 | 3033 | |
| 3034 | 3034 | /** |
| 3035 | - * Removes a specific item. |
|
| 3036 | - * |
|
| 3037 | - * @since 1.0.19 |
|
| 3038 | - */ |
|
| 3039 | - public function remove_item( $item_id ) { |
|
| 3035 | + * Removes a specific item. |
|
| 3036 | + * |
|
| 3037 | + * @since 1.0.19 |
|
| 3038 | + */ |
|
| 3039 | + public function remove_item( $item_id ) { |
|
| 3040 | 3040 | $items = $this->get_items(); |
| 3041 | 3041 | |
| 3042 | 3042 | if ( $item_id == $this->recurring_item ) { |
@@ -3064,38 +3064,38 @@ discard block |
||
| 3064 | 3064 | if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
| 3065 | 3065 | |
| 3066 | 3066 | $amount = $fees[ $fee ]['amount'] += $amount; |
| 3067 | - $fees[ $fee ] = array( |
|
| 3067 | + $fees[ $fee ] = array( |
|
| 3068 | 3068 | 'amount' => $amount, |
| 3069 | 3069 | 'recurring' => (bool) $recurring, |
| 3070 | 3070 | ); |
| 3071 | 3071 | |
| 3072 | - } else { |
|
| 3073 | - $fees[ $fee ] = array( |
|
| 3072 | + } else { |
|
| 3073 | + $fees[ $fee ] = array( |
|
| 3074 | 3074 | 'amount' => $amount, |
| 3075 | 3075 | 'recurring' => (bool) $recurring, |
| 3076 | 3076 | ); |
| 3077 | - } |
|
| 3077 | + } |
|
| 3078 | 3078 | |
| 3079 | 3079 | $this->set_prop( 'fees', $fee ); |
| 3080 | 3080 | |
| 3081 | 3081 | } |
| 3082 | 3082 | |
| 3083 | 3083 | /** |
| 3084 | - * Retrieves a specific fee. |
|
| 3085 | - * |
|
| 3086 | - * @since 1.0.19 |
|
| 3087 | - */ |
|
| 3088 | - public function get_fee( $fee ) { |
|
| 3084 | + * Retrieves a specific fee. |
|
| 3085 | + * |
|
| 3086 | + * @since 1.0.19 |
|
| 3087 | + */ |
|
| 3088 | + public function get_fee( $fee ) { |
|
| 3089 | 3089 | $fees = $this->get_fees(); |
| 3090 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3090 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3091 | 3091 | } |
| 3092 | 3092 | |
| 3093 | 3093 | /** |
| 3094 | - * Removes a specific fee. |
|
| 3095 | - * |
|
| 3096 | - * @since 1.0.19 |
|
| 3097 | - */ |
|
| 3098 | - public function remove_fee( $fee ) { |
|
| 3094 | + * Removes a specific fee. |
|
| 3095 | + * |
|
| 3096 | + * @since 1.0.19 |
|
| 3097 | + */ |
|
| 3098 | + public function remove_fee( $fee ) { |
|
| 3099 | 3099 | $fees = $this->get_fees(); |
| 3100 | 3100 | if ( isset( $fees[ $fee ] ) ) { |
| 3101 | 3101 | unset( $fees[ $fee ] ); |
@@ -3118,44 +3118,44 @@ discard block |
||
| 3118 | 3118 | if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
| 3119 | 3119 | |
| 3120 | 3120 | $amount = $discounts[ $discount ]['amount'] += $amount; |
| 3121 | - $discounts[ $discount ] = array( |
|
| 3121 | + $discounts[ $discount ] = array( |
|
| 3122 | 3122 | 'amount' => $amount, |
| 3123 | 3123 | 'recurring' => (bool) $recurring, |
| 3124 | 3124 | ); |
| 3125 | 3125 | |
| 3126 | - } else { |
|
| 3127 | - $discounts[ $discount ] = array( |
|
| 3126 | + } else { |
|
| 3127 | + $discounts[ $discount ] = array( |
|
| 3128 | 3128 | 'amount' => $amount, |
| 3129 | 3129 | 'recurring' => (bool) $recurring, |
| 3130 | 3130 | ); |
| 3131 | - } |
|
| 3131 | + } |
|
| 3132 | 3132 | |
| 3133 | 3133 | $this->set_prop( 'discounts', $discount ); |
| 3134 | 3134 | |
| 3135 | 3135 | } |
| 3136 | 3136 | |
| 3137 | 3137 | /** |
| 3138 | - * Retrieves a specific discount. |
|
| 3139 | - * |
|
| 3140 | - * @since 1.0.19 |
|
| 3141 | - */ |
|
| 3142 | - public function get_discount( $discount = false ) { |
|
| 3138 | + * Retrieves a specific discount. |
|
| 3139 | + * |
|
| 3140 | + * @since 1.0.19 |
|
| 3141 | + */ |
|
| 3142 | + public function get_discount( $discount = false ) { |
|
| 3143 | 3143 | |
| 3144 | - // Backwards compatibilty. |
|
| 3145 | - if ( empty( $discount ) ) { |
|
| 3146 | - return $this->get_total_discount(); |
|
| 3147 | - } |
|
| 3144 | + // Backwards compatibilty. |
|
| 3145 | + if ( empty( $discount ) ) { |
|
| 3146 | + return $this->get_total_discount(); |
|
| 3147 | + } |
|
| 3148 | 3148 | |
| 3149 | 3149 | $discounts = $this->get_discounts(); |
| 3150 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3150 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3151 | 3151 | } |
| 3152 | 3152 | |
| 3153 | 3153 | /** |
| 3154 | - * Removes a specific discount. |
|
| 3155 | - * |
|
| 3156 | - * @since 1.0.19 |
|
| 3157 | - */ |
|
| 3158 | - public function remove_discount( $discount ) { |
|
| 3154 | + * Removes a specific discount. |
|
| 3155 | + * |
|
| 3156 | + * @since 1.0.19 |
|
| 3157 | + */ |
|
| 3158 | + public function remove_discount( $discount ) { |
|
| 3159 | 3159 | $discounts = $this->get_discounts(); |
| 3160 | 3160 | if ( isset( $discounts[ $discount ] ) ) { |
| 3161 | 3161 | unset( $discounts[ $discount ] ); |
@@ -3181,38 +3181,38 @@ discard block |
||
| 3181 | 3181 | if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
| 3182 | 3182 | |
| 3183 | 3183 | $amount = $taxes[ $tax ]['amount'] += $amount; |
| 3184 | - $taxes[ $tax ] = array( |
|
| 3184 | + $taxes[ $tax ] = array( |
|
| 3185 | 3185 | 'amount' => $amount, |
| 3186 | 3186 | 'recurring' => (bool) $recurring, |
| 3187 | 3187 | ); |
| 3188 | 3188 | |
| 3189 | - } else { |
|
| 3190 | - $taxes[ $tax ] = array( |
|
| 3189 | + } else { |
|
| 3190 | + $taxes[ $tax ] = array( |
|
| 3191 | 3191 | 'amount' => $amount, |
| 3192 | 3192 | 'recurring' => (bool) $recurring, |
| 3193 | 3193 | ); |
| 3194 | - } |
|
| 3194 | + } |
|
| 3195 | 3195 | |
| 3196 | 3196 | $this->set_prop( 'taxes', $tax ); |
| 3197 | 3197 | |
| 3198 | 3198 | } |
| 3199 | 3199 | |
| 3200 | 3200 | /** |
| 3201 | - * Retrieves a specific tax. |
|
| 3202 | - * |
|
| 3203 | - * @since 1.0.19 |
|
| 3204 | - */ |
|
| 3205 | - public function get_tax( $tax ) { |
|
| 3201 | + * Retrieves a specific tax. |
|
| 3202 | + * |
|
| 3203 | + * @since 1.0.19 |
|
| 3204 | + */ |
|
| 3205 | + public function get_tax( $tax ) { |
|
| 3206 | 3206 | $taxes = $this->get_taxes(); |
| 3207 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3207 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | /** |
| 3211 | - * Removes a specific tax. |
|
| 3212 | - * |
|
| 3213 | - * @since 1.0.19 |
|
| 3214 | - */ |
|
| 3215 | - public function remove_tax( $tax ) { |
|
| 3211 | + * Removes a specific tax. |
|
| 3212 | + * |
|
| 3213 | + * @since 1.0.19 |
|
| 3214 | + */ |
|
| 3215 | + public function remove_tax( $tax ) { |
|
| 3216 | 3216 | $taxes = $this->get_discounts(); |
| 3217 | 3217 | if ( isset( $taxes[ $tax ] ) ) { |
| 3218 | 3218 | unset( $taxes[ $tax ] ); |
@@ -3221,160 +3221,160 @@ discard block |
||
| 3221 | 3221 | } |
| 3222 | 3222 | |
| 3223 | 3223 | /** |
| 3224 | - * Recalculates the invoice subtotal. |
|
| 3225 | - * |
|
| 3226 | - * @since 1.0.19 |
|
| 3227 | - * @return float The recalculated subtotal |
|
| 3228 | - */ |
|
| 3229 | - public function recalculate_subtotal() { |
|
| 3224 | + * Recalculates the invoice subtotal. |
|
| 3225 | + * |
|
| 3226 | + * @since 1.0.19 |
|
| 3227 | + * @return float The recalculated subtotal |
|
| 3228 | + */ |
|
| 3229 | + public function recalculate_subtotal() { |
|
| 3230 | 3230 | $items = $this->get_items(); |
| 3231 | - $subtotal = 0; |
|
| 3232 | - $recurring = 0; |
|
| 3231 | + $subtotal = 0; |
|
| 3232 | + $recurring = 0; |
|
| 3233 | 3233 | |
| 3234 | 3234 | foreach ( $items as $item ) { |
| 3235 | - $subtotal += $item->get_sub_total(); |
|
| 3236 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3235 | + $subtotal += $item->get_sub_total(); |
|
| 3236 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3237 | 3237 | } |
| 3238 | 3238 | |
| 3239 | - if ( $this->is_renewal() ) { |
|
| 3240 | - $this->set_subtotal( $recurring ); |
|
| 3241 | - } else { |
|
| 3242 | - $this->set_subtotal( $subtotal ); |
|
| 3243 | - } |
|
| 3239 | + if ( $this->is_renewal() ) { |
|
| 3240 | + $this->set_subtotal( $recurring ); |
|
| 3241 | + } else { |
|
| 3242 | + $this->set_subtotal( $subtotal ); |
|
| 3243 | + } |
|
| 3244 | 3244 | |
| 3245 | - $this->totals['subtotal'] = array( |
|
| 3246 | - 'initial' => $subtotal, |
|
| 3247 | - 'recurring' => $recurring, |
|
| 3248 | - ); |
|
| 3245 | + $this->totals['subtotal'] = array( |
|
| 3246 | + 'initial' => $subtotal, |
|
| 3247 | + 'recurring' => $recurring, |
|
| 3248 | + ); |
|
| 3249 | 3249 | |
| 3250 | 3250 | return $this->is_renewal() ? $recurring : $subtotal; |
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | 3253 | /** |
| 3254 | - * Recalculates the invoice discount total. |
|
| 3255 | - * |
|
| 3256 | - * @since 1.0.19 |
|
| 3257 | - * @return float The recalculated discount |
|
| 3258 | - */ |
|
| 3259 | - public function recalculate_total_discount() { |
|
| 3254 | + * Recalculates the invoice discount total. |
|
| 3255 | + * |
|
| 3256 | + * @since 1.0.19 |
|
| 3257 | + * @return float The recalculated discount |
|
| 3258 | + */ |
|
| 3259 | + public function recalculate_total_discount() { |
|
| 3260 | 3260 | $discounts = $this->get_discounts(); |
| 3261 | - $discount = 0; |
|
| 3262 | - $recurring = 0; |
|
| 3261 | + $discount = 0; |
|
| 3262 | + $recurring = 0; |
|
| 3263 | 3263 | |
| 3264 | 3264 | foreach ( $discounts as $data ) { |
| 3265 | 3265 | |
| 3266 | - if ( $data['recurring'] ) { |
|
| 3267 | - $recurring += $data['amount']; |
|
| 3268 | - } else { |
|
| 3269 | - $discount += $data['amount']; |
|
| 3270 | - } |
|
| 3266 | + if ( $data['recurring'] ) { |
|
| 3267 | + $recurring += $data['amount']; |
|
| 3268 | + } else { |
|
| 3269 | + $discount += $data['amount']; |
|
| 3270 | + } |
|
| 3271 | 3271 | |
| 3272 | - } |
|
| 3272 | + } |
|
| 3273 | 3273 | |
| 3274 | - if ( $this->is_renewal() ) { |
|
| 3275 | - $this->set_total_discount( $recurring ); |
|
| 3276 | - } else { |
|
| 3277 | - $this->set_total_discount( $discount ); |
|
| 3278 | - } |
|
| 3274 | + if ( $this->is_renewal() ) { |
|
| 3275 | + $this->set_total_discount( $recurring ); |
|
| 3276 | + } else { |
|
| 3277 | + $this->set_total_discount( $discount ); |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | - $this->totals['discount'] = array( |
|
| 3281 | - 'initial' => $discount, |
|
| 3282 | - 'recurring' => $recurring, |
|
| 3283 | - ); |
|
| 3280 | + $this->totals['discount'] = array( |
|
| 3281 | + 'initial' => $discount, |
|
| 3282 | + 'recurring' => $recurring, |
|
| 3283 | + ); |
|
| 3284 | 3284 | |
| 3285 | - return $this->is_renewal() ? $recurring : $discount; |
|
| 3285 | + return $this->is_renewal() ? $recurring : $discount; |
|
| 3286 | 3286 | |
| 3287 | 3287 | } |
| 3288 | 3288 | |
| 3289 | 3289 | /** |
| 3290 | - * Recalculates the invoice tax total. |
|
| 3291 | - * |
|
| 3292 | - * @since 1.0.19 |
|
| 3293 | - * @return float The recalculated tax |
|
| 3294 | - */ |
|
| 3295 | - public function recalculate_total_tax() { |
|
| 3290 | + * Recalculates the invoice tax total. |
|
| 3291 | + * |
|
| 3292 | + * @since 1.0.19 |
|
| 3293 | + * @return float The recalculated tax |
|
| 3294 | + */ |
|
| 3295 | + public function recalculate_total_tax() { |
|
| 3296 | 3296 | $taxes = $this->get_taxes(); |
| 3297 | - $tax = 0; |
|
| 3298 | - $recurring = 0; |
|
| 3297 | + $tax = 0; |
|
| 3298 | + $recurring = 0; |
|
| 3299 | 3299 | |
| 3300 | 3300 | foreach ( $taxes as $data ) { |
| 3301 | 3301 | |
| 3302 | - if ( $data['recurring'] ) { |
|
| 3303 | - $recurring += $data['amount']; |
|
| 3304 | - } else { |
|
| 3305 | - $tax += $data['amount']; |
|
| 3306 | - } |
|
| 3302 | + if ( $data['recurring'] ) { |
|
| 3303 | + $recurring += $data['amount']; |
|
| 3304 | + } else { |
|
| 3305 | + $tax += $data['amount']; |
|
| 3306 | + } |
|
| 3307 | 3307 | |
| 3308 | - } |
|
| 3308 | + } |
|
| 3309 | 3309 | |
| 3310 | - if ( $this->is_renewal() ) { |
|
| 3311 | - $this->set_total_tax( $recurring ); |
|
| 3312 | - } else { |
|
| 3313 | - $this->set_total_tax( $tax ); |
|
| 3314 | - } |
|
| 3310 | + if ( $this->is_renewal() ) { |
|
| 3311 | + $this->set_total_tax( $recurring ); |
|
| 3312 | + } else { |
|
| 3313 | + $this->set_total_tax( $tax ); |
|
| 3314 | + } |
|
| 3315 | 3315 | |
| 3316 | - $this->totals['tax'] = array( |
|
| 3317 | - 'initial' => $tax, |
|
| 3318 | - 'recurring' => $recurring, |
|
| 3319 | - ); |
|
| 3316 | + $this->totals['tax'] = array( |
|
| 3317 | + 'initial' => $tax, |
|
| 3318 | + 'recurring' => $recurring, |
|
| 3319 | + ); |
|
| 3320 | 3320 | |
| 3321 | - return $this->is_renewal() ? $recurring : $tax; |
|
| 3321 | + return $this->is_renewal() ? $recurring : $tax; |
|
| 3322 | 3322 | |
| 3323 | 3323 | } |
| 3324 | 3324 | |
| 3325 | 3325 | /** |
| 3326 | - * Recalculates the invoice fees total. |
|
| 3327 | - * |
|
| 3328 | - * @since 1.0.19 |
|
| 3329 | - * @return float The recalculated fee |
|
| 3330 | - */ |
|
| 3331 | - public function recalculate_total_fees() { |
|
| 3332 | - $fees = $this->get_fees(); |
|
| 3333 | - $fee = 0; |
|
| 3334 | - $recurring = 0; |
|
| 3326 | + * Recalculates the invoice fees total. |
|
| 3327 | + * |
|
| 3328 | + * @since 1.0.19 |
|
| 3329 | + * @return float The recalculated fee |
|
| 3330 | + */ |
|
| 3331 | + public function recalculate_total_fees() { |
|
| 3332 | + $fees = $this->get_fees(); |
|
| 3333 | + $fee = 0; |
|
| 3334 | + $recurring = 0; |
|
| 3335 | 3335 | |
| 3336 | 3336 | foreach ( $fees as $data ) { |
| 3337 | 3337 | |
| 3338 | - if ( $data['recurring'] ) { |
|
| 3339 | - $recurring += $data['amount']; |
|
| 3340 | - } else { |
|
| 3341 | - $fee += $data['amount']; |
|
| 3342 | - } |
|
| 3338 | + if ( $data['recurring'] ) { |
|
| 3339 | + $recurring += $data['amount']; |
|
| 3340 | + } else { |
|
| 3341 | + $fee += $data['amount']; |
|
| 3342 | + } |
|
| 3343 | 3343 | |
| 3344 | - } |
|
| 3344 | + } |
|
| 3345 | 3345 | |
| 3346 | 3346 | if ( $this->is_renewal() ) { |
| 3347 | - $this->set_total_fees( $recurring ); |
|
| 3348 | - } else { |
|
| 3349 | - $this->set_total_fees( $fee ); |
|
| 3350 | - } |
|
| 3347 | + $this->set_total_fees( $recurring ); |
|
| 3348 | + } else { |
|
| 3349 | + $this->set_total_fees( $fee ); |
|
| 3350 | + } |
|
| 3351 | 3351 | |
| 3352 | - $this->totals['fee'] = array( |
|
| 3353 | - 'initial' => $fee, |
|
| 3354 | - 'recurring' => $recurring, |
|
| 3355 | - ); |
|
| 3352 | + $this->totals['fee'] = array( |
|
| 3353 | + 'initial' => $fee, |
|
| 3354 | + 'recurring' => $recurring, |
|
| 3355 | + ); |
|
| 3356 | 3356 | |
| 3357 | 3357 | $this->set_total_fees( $fee ); |
| 3358 | 3358 | return $this->is_renewal() ? $recurring : $fee; |
| 3359 | 3359 | } |
| 3360 | 3360 | |
| 3361 | 3361 | /** |
| 3362 | - * Recalculates the invoice total. |
|
| 3363 | - * |
|
| 3364 | - * @since 1.0.19 |
|
| 3362 | + * Recalculates the invoice total. |
|
| 3363 | + * |
|
| 3364 | + * @since 1.0.19 |
|
| 3365 | 3365 | * @return float The invoice total |
| 3366 | - */ |
|
| 3367 | - public function recalculate_total() { |
|
| 3366 | + */ |
|
| 3367 | + public function recalculate_total() { |
|
| 3368 | 3368 | $this->recalculate_subtotal(); |
| 3369 | 3369 | $this->recalculate_total_fees(); |
| 3370 | 3370 | $this->recalculate_total_discount(); |
| 3371 | 3371 | $this->recalculate_total_tax(); |
| 3372 | - return $this->get_total(); |
|
| 3373 | - } |
|
| 3372 | + return $this->get_total(); |
|
| 3373 | + } |
|
| 3374 | 3374 | |
| 3375 | - /** |
|
| 3376 | - * @deprecated |
|
| 3377 | - */ |
|
| 3375 | + /** |
|
| 3376 | + * @deprecated |
|
| 3377 | + */ |
|
| 3378 | 3378 | public function recalculate_totals( $temp = false ) { |
| 3379 | 3379 | $this->update_items( $temp ); |
| 3380 | 3380 | $this->save( true ); |
@@ -3438,9 +3438,9 @@ discard block |
||
| 3438 | 3438 | } |
| 3439 | 3439 | |
| 3440 | 3440 | return $note_id; |
| 3441 | - } |
|
| 3441 | + } |
|
| 3442 | 3442 | |
| 3443 | - /** |
|
| 3443 | + /** |
|
| 3444 | 3444 | * Generates a unique key for the invoice. |
| 3445 | 3445 | */ |
| 3446 | 3446 | public function generate_key( $string = '' ) { |
@@ -3461,106 +3461,106 @@ discard block |
||
| 3461 | 3461 | $number = $next_number; |
| 3462 | 3462 | } |
| 3463 | 3463 | |
| 3464 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3464 | + $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3465 | 3465 | |
| 3466 | - return $number; |
|
| 3467 | - } |
|
| 3466 | + return $number; |
|
| 3467 | + } |
|
| 3468 | 3468 | |
| 3469 | - /** |
|
| 3470 | - * Handle the status transition. |
|
| 3471 | - */ |
|
| 3472 | - protected function status_transition() { |
|
| 3473 | - $status_transition = $this->status_transition; |
|
| 3469 | + /** |
|
| 3470 | + * Handle the status transition. |
|
| 3471 | + */ |
|
| 3472 | + protected function status_transition() { |
|
| 3473 | + $status_transition = $this->status_transition; |
|
| 3474 | 3474 | |
| 3475 | - // Reset status transition variable. |
|
| 3476 | - $this->status_transition = false; |
|
| 3475 | + // Reset status transition variable. |
|
| 3476 | + $this->status_transition = false; |
|
| 3477 | 3477 | |
| 3478 | - if ( $status_transition ) { |
|
| 3479 | - try { |
|
| 3478 | + if ( $status_transition ) { |
|
| 3479 | + try { |
|
| 3480 | 3480 | |
| 3481 | - // Fire a hook for the status change. |
|
| 3482 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3481 | + // Fire a hook for the status change. |
|
| 3482 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3483 | 3483 | |
| 3484 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3485 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3484 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3485 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3486 | 3486 | |
| 3487 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3487 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3488 | 3488 | |
| 3489 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3490 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3489 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3490 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3491 | 3491 | |
| 3492 | - // Fire another hook. |
|
| 3493 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3494 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3492 | + // Fire another hook. |
|
| 3493 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3494 | + do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3495 | 3495 | |
| 3496 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3497 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3496 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3497 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3498 | 3498 | |
| 3499 | - // Note the transition occurred. |
|
| 3500 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3499 | + // Note the transition occurred. |
|
| 3500 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3501 | 3501 | |
| 3502 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3503 | - if ( |
|
| 3504 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed' ), true ) |
|
| 3505 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3506 | - ) { |
|
| 3507 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3508 | - } |
|
| 3509 | - } else { |
|
| 3510 | - /* translators: %s: new invoice status */ |
|
| 3511 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3502 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3503 | + if ( |
|
| 3504 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed' ), true ) |
|
| 3505 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3506 | + ) { |
|
| 3507 | + do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3508 | + } |
|
| 3509 | + } else { |
|
| 3510 | + /* translators: %s: new invoice status */ |
|
| 3511 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3512 | 3512 | |
| 3513 | - // Note the transition occurred. |
|
| 3514 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3513 | + // Note the transition occurred. |
|
| 3514 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3515 | 3515 | |
| 3516 | - } |
|
| 3517 | - } catch ( Exception $e ) { |
|
| 3518 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3519 | - } |
|
| 3520 | - } |
|
| 3521 | - } |
|
| 3516 | + } |
|
| 3517 | + } catch ( Exception $e ) { |
|
| 3518 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3519 | + } |
|
| 3520 | + } |
|
| 3521 | + } |
|
| 3522 | 3522 | |
| 3523 | - /** |
|
| 3524 | - * Updates an invoice status. |
|
| 3525 | - */ |
|
| 3526 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3523 | + /** |
|
| 3524 | + * Updates an invoice status. |
|
| 3525 | + */ |
|
| 3526 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3527 | 3527 | |
| 3528 | - // Fires before updating a status. |
|
| 3529 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3528 | + // Fires before updating a status. |
|
| 3529 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3530 | 3530 | |
| 3531 | - // Update the status. |
|
| 3532 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3531 | + // Update the status. |
|
| 3532 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3533 | 3533 | |
| 3534 | - // Save the order. |
|
| 3535 | - return $this->save(); |
|
| 3534 | + // Save the order. |
|
| 3535 | + return $this->save(); |
|
| 3536 | 3536 | |
| 3537 | - } |
|
| 3537 | + } |
|
| 3538 | 3538 | |
| 3539 | - /** |
|
| 3540 | - * @deprecated |
|
| 3541 | - */ |
|
| 3542 | - public function refresh_item_ids() { |
|
| 3539 | + /** |
|
| 3540 | + * @deprecated |
|
| 3541 | + */ |
|
| 3542 | + public function refresh_item_ids() { |
|
| 3543 | 3543 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
| 3544 | 3544 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3545 | - } |
|
| 3545 | + } |
|
| 3546 | 3546 | |
| 3547 | - /** |
|
| 3548 | - * @deprecated |
|
| 3549 | - */ |
|
| 3550 | - public function update_items( $temp = false ) { |
|
| 3547 | + /** |
|
| 3548 | + * @deprecated |
|
| 3549 | + */ |
|
| 3550 | + public function update_items( $temp = false ) { |
|
| 3551 | 3551 | |
| 3552 | - $this->set_items( $this->get_items() ); |
|
| 3552 | + $this->set_items( $this->get_items() ); |
|
| 3553 | 3553 | |
| 3554 | - if ( ! $temp ) { |
|
| 3555 | - $this->save(); |
|
| 3556 | - } |
|
| 3554 | + if ( ! $temp ) { |
|
| 3555 | + $this->save(); |
|
| 3556 | + } |
|
| 3557 | 3557 | |
| 3558 | 3558 | return $this; |
| 3559 | - } |
|
| 3559 | + } |
|
| 3560 | 3560 | |
| 3561 | - /** |
|
| 3562 | - * @deprecated |
|
| 3563 | - */ |
|
| 3561 | + /** |
|
| 3562 | + * @deprecated |
|
| 3563 | + */ |
|
| 3564 | 3564 | public function validate_discount() { |
| 3565 | 3565 | |
| 3566 | 3566 | $discount_code = $this->get_discount_code(); |
@@ -3576,25 +3576,25 @@ discard block |
||
| 3576 | 3576 | |
| 3577 | 3577 | } |
| 3578 | 3578 | |
| 3579 | - /** |
|
| 3580 | - * Refunds an invoice. |
|
| 3581 | - */ |
|
| 3579 | + /** |
|
| 3580 | + * Refunds an invoice. |
|
| 3581 | + */ |
|
| 3582 | 3582 | public function refund() { |
| 3583 | - $this->set_status( 'wpi-refunded' ); |
|
| 3583 | + $this->set_status( 'wpi-refunded' ); |
|
| 3584 | 3584 | $this->save(); |
| 3585 | 3585 | } |
| 3586 | 3586 | |
| 3587 | - /** |
|
| 3588 | - * Save data to the database. |
|
| 3589 | - * |
|
| 3590 | - * @since 1.0.19 |
|
| 3591 | - * @return int invoice ID |
|
| 3592 | - */ |
|
| 3593 | - public function save() { |
|
| 3594 | - $this->maybe_set_date_paid(); |
|
| 3595 | - parent::save(); |
|
| 3596 | - $this->status_transition(); |
|
| 3597 | - return $this->get_id(); |
|
| 3598 | - } |
|
| 3587 | + /** |
|
| 3588 | + * Save data to the database. |
|
| 3589 | + * |
|
| 3590 | + * @since 1.0.19 |
|
| 3591 | + * @return int invoice ID |
|
| 3592 | + */ |
|
| 3593 | + public function save() { |
|
| 3594 | + $this->maybe_set_date_paid(); |
|
| 3595 | + parent::save(); |
|
| 3596 | + $this->status_transition(); |
|
| 3597 | + return $this->get_id(); |
|
| 3598 | + } |
|
| 3599 | 3599 | |
| 3600 | 3600 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // MUST have WordPress. |
| 4 | -if ( !defined( 'WPINC' ) ) { |
|
| 5 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 4 | +if (!defined('WPINC')) { |
|
| 5 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -130,38 +130,38 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @param int/string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, number or object to read. |
| 132 | 132 | */ |
| 133 | - public function __construct( $invoice = false ) { |
|
| 133 | + public function __construct($invoice = false) { |
|
| 134 | 134 | |
| 135 | - parent::__construct( $invoice ); |
|
| 135 | + parent::__construct($invoice); |
|
| 136 | 136 | |
| 137 | - if ( is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 138 | - $this->set_id( $invoice ); |
|
| 139 | - } elseif ( $invoice instanceof self ) { |
|
| 140 | - $this->set_id( $invoice->get_id() ); |
|
| 141 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 142 | - $this->set_id( $invoice->ID ); |
|
| 143 | - } elseif ( is_array( $invoice ) ) { |
|
| 144 | - $this->set_props( $invoice ); |
|
| 137 | + if (is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
| 138 | + $this->set_id($invoice); |
|
| 139 | + } elseif ($invoice instanceof self) { |
|
| 140 | + $this->set_id($invoice->get_id()); |
|
| 141 | + } elseif (!empty($invoice->ID)) { |
|
| 142 | + $this->set_id($invoice->ID); |
|
| 143 | + } elseif (is_array($invoice)) { |
|
| 144 | + $this->set_props($invoice); |
|
| 145 | 145 | |
| 146 | - if ( isset( $invoice['ID'] ) ) { |
|
| 147 | - $this->set_id( $invoice['ID'] ); |
|
| 146 | + if (isset($invoice['ID'])) { |
|
| 147 | + $this->set_id($invoice['ID']); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_discount_id_by_code( $invoice, 'key' ) ) { |
|
| 151 | - $this->set_id( $invoice_id ); |
|
| 152 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_discount_id_by_code( $invoice, 'number' ) ) { |
|
| 153 | - $this->set_id( $invoice_id ); |
|
| 150 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_discount_id_by_code($invoice, 'key')) { |
|
| 151 | + $this->set_id($invoice_id); |
|
| 152 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_discount_id_by_code($invoice, 'number')) { |
|
| 153 | + $this->set_id($invoice_id); |
|
| 154 | 154 | } else { |
| 155 | - $this->set_object_read( true ); |
|
| 155 | + $this->set_object_read(true); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Load the datastore. |
| 159 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 159 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 160 | 160 | |
| 161 | - if ( $this->get_id() > 0 ) { |
|
| 162 | - $this->post = get_post( $this->get_id() ); |
|
| 161 | + if ($this->get_id() > 0) { |
|
| 162 | + $this->post = get_post($this->get_id()); |
|
| 163 | 163 | $this->ID = $this->get_id(); |
| 164 | - $this->data_store->read( $this ); |
|
| 164 | + $this->data_store->read($this); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | } |
@@ -175,38 +175,38 @@ discard block |
||
| 175 | 175 | * @since 1.0.15 |
| 176 | 176 | * @return int |
| 177 | 177 | */ |
| 178 | - public static function get_discount_id_by_code( $invoice_key_or_number, $field = 'key' ) { |
|
| 178 | + public static function get_discount_id_by_code($invoice_key_or_number, $field = 'key') { |
|
| 179 | 179 | global $wpdb; |
| 180 | 180 | |
| 181 | 181 | // Trim the code. |
| 182 | - $key = trim( $invoice_key_or_number ); |
|
| 182 | + $key = trim($invoice_key_or_number); |
|
| 183 | 183 | |
| 184 | 184 | // Valid fields. |
| 185 | - $fields = array( 'key', 'number' ); |
|
| 185 | + $fields = array('key', 'number'); |
|
| 186 | 186 | |
| 187 | 187 | // Ensure a value has been passed. |
| 188 | - if ( empty( $key ) || ! in_array( $field, $fields ) ) { |
|
| 188 | + if (empty($key) || !in_array($field, $fields)) { |
|
| 189 | 189 | return 0; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Maybe retrieve from the cache. |
| 193 | - $invoice_id = wp_cache_get( $key, 'getpaid_invoice_keys_' . $field ); |
|
| 194 | - if ( ! empty( $invoice_id ) ) { |
|
| 193 | + $invoice_id = wp_cache_get($key, 'getpaid_invoice_keys_' . $field); |
|
| 194 | + if (!empty($invoice_id)) { |
|
| 195 | 195 | return $invoice_id; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Fetch from the db. |
| 199 | 199 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 200 | 200 | $invoice_id = $wpdb->get_var( |
| 201 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE $field=%s LIMIT 1", $key ) |
|
| 201 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE $field=%s LIMIT 1", $key) |
|
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | - if ( empty( $invoice_id ) ) { |
|
| 204 | + if (empty($invoice_id)) { |
|
| 205 | 205 | return 0; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Update the cache with our data |
| 209 | - wp_cache_set( $key, $invoice_id, 'getpaid_invoice_keys_' . $field ); |
|
| 209 | + wp_cache_set($key, $invoice_id, 'getpaid_invoice_keys_' . $field); |
|
| 210 | 210 | |
| 211 | 211 | return $invoice_id; |
| 212 | 212 | } |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | /** |
| 215 | 215 | * Checks if an invoice key is set. |
| 216 | 216 | */ |
| 217 | - public function _isset( $key ) { |
|
| 218 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 217 | + public function _isset($key) { |
|
| 218 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /* |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | * @param string $context View or edit context. |
| 241 | 241 | * @return int |
| 242 | 242 | */ |
| 243 | - public function get_parent_id( $context = 'view' ) { |
|
| 244 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 243 | + public function get_parent_id($context = 'view') { |
|
| 244 | + return (int) $this->get_prop('parent_id', $context); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @return WPInv_Invoice |
| 252 | 252 | */ |
| 253 | 253 | public function get_parent_payment() { |
| 254 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 254 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | * @param string $context View or edit context. |
| 272 | 272 | * @return string |
| 273 | 273 | */ |
| 274 | - public function get_status( $context = 'view' ) { |
|
| 275 | - return $this->get_prop( 'status', $context ); |
|
| 274 | + public function get_status($context = 'view') { |
|
| 275 | + return $this->get_prop('status', $context); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -282,15 +282,15 @@ discard block |
||
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | 284 | public function get_status_nicename() { |
| 285 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 285 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
| 286 | 286 | |
| 287 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 287 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
| 288 | 288 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 291 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 292 | 292 | |
| 293 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status ); |
|
| 293 | + return apply_filters('wpinv_get_invoice_status_nicename', $status); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -300,27 +300,27 @@ discard block |
||
| 300 | 300 | * @param string $context View or edit context. |
| 301 | 301 | * @return string |
| 302 | 302 | */ |
| 303 | - public function get_version( $context = 'view' ) { |
|
| 304 | - return $this->get_prop( 'version', $context ); |
|
| 303 | + public function get_version($context = 'view') { |
|
| 304 | + return $this->get_prop('version', $context); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | 308 | * @deprecated |
| 309 | 309 | */ |
| 310 | - public function get_invoice_date( $formatted = true ) { |
|
| 310 | + public function get_invoice_date($formatted = true) { |
|
| 311 | 311 | $date_completed = $this->get_date_completed(); |
| 312 | 312 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 313 | 313 | |
| 314 | - if ( $invoice_date == '' ) { |
|
| 314 | + if ($invoice_date == '') { |
|
| 315 | 315 | $date_created = $this->get_date_created(); |
| 316 | 316 | $invoice_date = $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if ( $formatted && $invoice_date ) { |
|
| 320 | - $invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) ); |
|
| 319 | + if ($formatted && $invoice_date) { |
|
| 320 | + $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date)); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this ); |
|
| 323 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -330,8 +330,8 @@ discard block |
||
| 330 | 330 | * @param string $context View or edit context. |
| 331 | 331 | * @return string |
| 332 | 332 | */ |
| 333 | - public function get_date_created( $context = 'view' ) { |
|
| 334 | - return $this->get_prop( 'date_created', $context ); |
|
| 333 | + public function get_date_created($context = 'view') { |
|
| 334 | + return $this->get_prop('date_created', $context); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | * @param string $context View or edit context. |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | - public function get_created_date( $context = 'view' ) { |
|
| 345 | - return $this->get_date_created( $context ); |
|
| 344 | + public function get_created_date($context = 'view') { |
|
| 345 | + return $this->get_date_created($context); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -352,11 +352,11 @@ discard block |
||
| 352 | 352 | * @param string $context View or edit context. |
| 353 | 353 | * @return string |
| 354 | 354 | */ |
| 355 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 356 | - $date = $this->get_date_created( $context ); |
|
| 355 | + public function get_date_created_gmt($context = 'view') { |
|
| 356 | + $date = $this->get_date_created($context); |
|
| 357 | 357 | |
| 358 | - if ( $date ) { |
|
| 359 | - $date = get_gmt_from_date( $date ); |
|
| 358 | + if ($date) { |
|
| 359 | + $date = get_gmt_from_date($date); |
|
| 360 | 360 | } |
| 361 | 361 | return $date; |
| 362 | 362 | } |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | * @param string $context View or edit context. |
| 369 | 369 | * @return string |
| 370 | 370 | */ |
| 371 | - public function get_date_modified( $context = 'view' ) { |
|
| 372 | - return $this->get_prop( 'date_modified', $context ); |
|
| 371 | + public function get_date_modified($context = 'view') { |
|
| 372 | + return $this->get_prop('date_modified', $context); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -379,8 +379,8 @@ discard block |
||
| 379 | 379 | * @param string $context View or edit context. |
| 380 | 380 | * @return string |
| 381 | 381 | */ |
| 382 | - public function get_modified_date( $context = 'view' ) { |
|
| 383 | - return $this->get_date_modified( $context ); |
|
| 382 | + public function get_modified_date($context = 'view') { |
|
| 383 | + return $this->get_date_modified($context); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | * @param string $context View or edit context. |
| 391 | 391 | * @return string |
| 392 | 392 | */ |
| 393 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 394 | - $date = $this->get_date_modified( $context ); |
|
| 393 | + public function get_date_modified_gmt($context = 'view') { |
|
| 394 | + $date = $this->get_date_modified($context); |
|
| 395 | 395 | |
| 396 | - if ( $date ) { |
|
| 397 | - $date = get_gmt_from_date( $date ); |
|
| 396 | + if ($date) { |
|
| 397 | + $date = get_gmt_from_date($date); |
|
| 398 | 398 | } |
| 399 | 399 | return $date; |
| 400 | 400 | } |
@@ -406,8 +406,8 @@ discard block |
||
| 406 | 406 | * @param string $context View or edit context. |
| 407 | 407 | * @return string |
| 408 | 408 | */ |
| 409 | - public function get_due_date( $context = 'view' ) { |
|
| 410 | - return $this->get_prop( 'due_date', $context ); |
|
| 409 | + public function get_due_date($context = 'view') { |
|
| 410 | + return $this->get_prop('due_date', $context); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * @param string $context View or edit context. |
| 418 | 418 | * @return string |
| 419 | 419 | */ |
| 420 | - public function get_date_due( $context = 'view' ) { |
|
| 421 | - return $this->get_due_date( $context ); |
|
| 420 | + public function get_date_due($context = 'view') { |
|
| 421 | + return $this->get_due_date($context); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -428,11 +428,11 @@ discard block |
||
| 428 | 428 | * @param string $context View or edit context. |
| 429 | 429 | * @return string |
| 430 | 430 | */ |
| 431 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 432 | - $date = $this->get_due_date( $context ); |
|
| 431 | + public function get_due_date_gmt($context = 'view') { |
|
| 432 | + $date = $this->get_due_date($context); |
|
| 433 | 433 | |
| 434 | - if ( $date ) { |
|
| 435 | - $date = get_gmt_from_date( $date ); |
|
| 434 | + if ($date) { |
|
| 435 | + $date = get_gmt_from_date($date); |
|
| 436 | 436 | } |
| 437 | 437 | return $date; |
| 438 | 438 | } |
@@ -444,8 +444,8 @@ discard block |
||
| 444 | 444 | * @param string $context View or edit context. |
| 445 | 445 | * @return string |
| 446 | 446 | */ |
| 447 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 448 | - return $this->get_due_date_gmt( $context ); |
|
| 447 | + public function get_gmt_date_due($context = 'view') { |
|
| 448 | + return $this->get_due_date_gmt($context); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | * @param string $context View or edit context. |
| 456 | 456 | * @return string |
| 457 | 457 | */ |
| 458 | - public function get_completed_date( $context = 'view' ) { |
|
| 459 | - return $this->get_prop( 'completed_date', $context ); |
|
| 458 | + public function get_completed_date($context = 'view') { |
|
| 459 | + return $this->get_prop('completed_date', $context); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -466,8 +466,8 @@ discard block |
||
| 466 | 466 | * @param string $context View or edit context. |
| 467 | 467 | * @return string |
| 468 | 468 | */ |
| 469 | - public function get_date_completed( $context = 'view' ) { |
|
| 470 | - return $this->get_completed_date( $context ); |
|
| 469 | + public function get_date_completed($context = 'view') { |
|
| 470 | + return $this->get_completed_date($context); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
@@ -477,11 +477,11 @@ discard block |
||
| 477 | 477 | * @param string $context View or edit context. |
| 478 | 478 | * @return string |
| 479 | 479 | */ |
| 480 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 481 | - $date = $this->get_completed_date( $context ); |
|
| 480 | + public function get_completed_date_gmt($context = 'view') { |
|
| 481 | + $date = $this->get_completed_date($context); |
|
| 482 | 482 | |
| 483 | - if ( $date ) { |
|
| 484 | - $date = get_gmt_from_date( $date ); |
|
| 483 | + if ($date) { |
|
| 484 | + $date = get_gmt_from_date($date); |
|
| 485 | 485 | } |
| 486 | 486 | return $date; |
| 487 | 487 | } |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | * @param string $context View or edit context. |
| 494 | 494 | * @return string |
| 495 | 495 | */ |
| 496 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 497 | - return $this->get_completed_date_gmt( $context ); |
|
| 496 | + public function get_gmt_completed_date($context = 'view') { |
|
| 497 | + return $this->get_completed_date_gmt($context); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | * @param string $context View or edit context. |
| 505 | 505 | * @return string |
| 506 | 506 | */ |
| 507 | - public function get_number( $context = 'view' ) { |
|
| 508 | - $number = $this->get_prop( 'number', $context ); |
|
| 507 | + public function get_number($context = 'view') { |
|
| 508 | + $number = $this->get_prop('number', $context); |
|
| 509 | 509 | |
| 510 | - if ( empty( $number ) ) { |
|
| 510 | + if (empty($number)) { |
|
| 511 | 511 | $number = $this->generate_number(); |
| 512 | - $this->set_number( $number ); |
|
| 512 | + $this->set_number($number); |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | return $number; |
@@ -522,12 +522,12 @@ discard block |
||
| 522 | 522 | * @param string $context View or edit context. |
| 523 | 523 | * @return string |
| 524 | 524 | */ |
| 525 | - public function get_key( $context = 'view' ) { |
|
| 526 | - $key = $this->get_prop( 'key', $context ); |
|
| 525 | + public function get_key($context = 'view') { |
|
| 526 | + $key = $this->get_prop('key', $context); |
|
| 527 | 527 | |
| 528 | - if ( empty( $key ) ) { |
|
| 529 | - $key = $this->generate_key( $this->post_type ); |
|
| 530 | - $this->set_key( $key ); |
|
| 528 | + if (empty($key)) { |
|
| 529 | + $key = $this->generate_key($this->post_type); |
|
| 530 | + $this->set_key($key); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | return $key; |
@@ -540,23 +540,23 @@ discard block |
||
| 540 | 540 | * @param string $context View or edit context. |
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | - public function get_type( $context = 'view' ) { |
|
| 544 | - return $this->get_prop( 'type', $context ); |
|
| 543 | + public function get_type($context = 'view') { |
|
| 544 | + return $this->get_prop('type', $context); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
| 548 | 548 | * @deprecated |
| 549 | 549 | */ |
| 550 | - public function get_invoice_quote_type( $post_id ) { |
|
| 551 | - if ( empty( $post_id ) ) { |
|
| 550 | + public function get_invoice_quote_type($post_id) { |
|
| 551 | + if (empty($post_id)) { |
|
| 552 | 552 | return ''; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - $type = get_post_type( $post_id ); |
|
| 555 | + $type = get_post_type($post_id); |
|
| 556 | 556 | |
| 557 | - if ( 'wpi_invoice' === $type ) { |
|
| 557 | + if ('wpi_invoice' === $type) { |
|
| 558 | 558 | $post_type = __('Invoice', 'invoicing'); |
| 559 | - } else{ |
|
| 559 | + } else { |
|
| 560 | 560 | $post_type = __('Quote', 'invoicing'); |
| 561 | 561 | } |
| 562 | 562 | |
@@ -570,8 +570,8 @@ discard block |
||
| 570 | 570 | * @param string $context View or edit context. |
| 571 | 571 | * @return string |
| 572 | 572 | */ |
| 573 | - public function get_post_type( $context = 'view' ) { |
|
| 574 | - return $this->get_prop( 'post_type', $context ); |
|
| 573 | + public function get_post_type($context = 'view') { |
|
| 574 | + return $this->get_prop('post_type', $context); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | * @param string $context View or edit context. |
| 582 | 582 | * @return string |
| 583 | 583 | */ |
| 584 | - public function get_mode( $context = 'view' ) { |
|
| 585 | - return $this->get_prop( 'mode', $context ); |
|
| 584 | + public function get_mode($context = 'view') { |
|
| 585 | + return $this->get_prop('mode', $context); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -592,12 +592,12 @@ discard block |
||
| 592 | 592 | * @param string $context View or edit context. |
| 593 | 593 | * @return string |
| 594 | 594 | */ |
| 595 | - public function get_path( $context = 'view' ) { |
|
| 596 | - $path = $this->get_prop( 'path', $context ); |
|
| 595 | + public function get_path($context = 'view') { |
|
| 596 | + $path = $this->get_prop('path', $context); |
|
| 597 | 597 | |
| 598 | - if ( empty( $path ) ) { |
|
| 599 | - $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type ); |
|
| 600 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
| 598 | + if (empty($path)) { |
|
| 599 | + $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type); |
|
| 600 | + $path = sanitize_title($prefix . $this->get_id()); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | return $path; |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | * @param string $context View or edit context. |
| 611 | 611 | * @return string |
| 612 | 612 | */ |
| 613 | - public function get_name( $context = 'view' ) { |
|
| 614 | - $name = $this->get_prop( 'title', $context ); |
|
| 613 | + public function get_name($context = 'view') { |
|
| 614 | + $name = $this->get_prop('title', $context); |
|
| 615 | 615 | |
| 616 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 616 | + return empty($name) ? $this->get_number($context) : $name; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | * @param string $context View or edit context. |
| 624 | 624 | * @return string |
| 625 | 625 | */ |
| 626 | - public function get_title( $context = 'view' ) { |
|
| 627 | - return $this->get_name( $context ); |
|
| 626 | + public function get_title($context = 'view') { |
|
| 627 | + return $this->get_name($context); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -634,8 +634,8 @@ discard block |
||
| 634 | 634 | * @param string $context View or edit context. |
| 635 | 635 | * @return string |
| 636 | 636 | */ |
| 637 | - public function get_description( $context = 'view' ) { |
|
| 638 | - return $this->get_prop( 'description', $context ); |
|
| 637 | + public function get_description($context = 'view') { |
|
| 638 | + return $this->get_prop('description', $context); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
@@ -645,8 +645,8 @@ discard block |
||
| 645 | 645 | * @param string $context View or edit context. |
| 646 | 646 | * @return string |
| 647 | 647 | */ |
| 648 | - public function get_excerpt( $context = 'view' ) { |
|
| 649 | - return $this->get_description( $context ); |
|
| 648 | + public function get_excerpt($context = 'view') { |
|
| 649 | + return $this->get_description($context); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
@@ -656,8 +656,8 @@ discard block |
||
| 656 | 656 | * @param string $context View or edit context. |
| 657 | 657 | * @return string |
| 658 | 658 | */ |
| 659 | - public function get_summary( $context = 'view' ) { |
|
| 660 | - return $this->get_description( $context ); |
|
| 659 | + public function get_summary($context = 'view') { |
|
| 660 | + return $this->get_description($context); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /** |
@@ -667,25 +667,25 @@ discard block |
||
| 667 | 667 | * @param string $context View or edit context. |
| 668 | 668 | * @return array |
| 669 | 669 | */ |
| 670 | - public function get_user_info( $context = 'view' ) { |
|
| 670 | + public function get_user_info($context = 'view') { |
|
| 671 | 671 | |
| 672 | 672 | $user_info = array( |
| 673 | - 'user_id' => $this->get_user_id( $context ), |
|
| 674 | - 'email' => $this->get_email( $context ), |
|
| 675 | - 'first_name' => $this->get_first_name( $context ), |
|
| 676 | - 'last_name' => $this->get_last_name( $context ), |
|
| 677 | - 'address' => $this->get_address( $context ), |
|
| 678 | - 'phone' => $this->get_phone( $context ), |
|
| 679 | - 'city' => $this->get_city( $context ), |
|
| 680 | - 'country' => $this->get_country( $context ), |
|
| 681 | - 'state' => $this->get_state( $context ), |
|
| 682 | - 'zip' => $this->get_zip( $context ), |
|
| 683 | - 'company' => $this->get_company( $context ), |
|
| 684 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 685 | - 'discount' => $this->get_discount_code( $context ), |
|
| 673 | + 'user_id' => $this->get_user_id($context), |
|
| 674 | + 'email' => $this->get_email($context), |
|
| 675 | + 'first_name' => $this->get_first_name($context), |
|
| 676 | + 'last_name' => $this->get_last_name($context), |
|
| 677 | + 'address' => $this->get_address($context), |
|
| 678 | + 'phone' => $this->get_phone($context), |
|
| 679 | + 'city' => $this->get_city($context), |
|
| 680 | + 'country' => $this->get_country($context), |
|
| 681 | + 'state' => $this->get_state($context), |
|
| 682 | + 'zip' => $this->get_zip($context), |
|
| 683 | + 'company' => $this->get_company($context), |
|
| 684 | + 'vat_number' => $this->get_vat_number($context), |
|
| 685 | + 'discount' => $this->get_discount_code($context), |
|
| 686 | 686 | ); |
| 687 | 687 | |
| 688 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 688 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 689 | 689 | |
| 690 | 690 | } |
| 691 | 691 | |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | * @param string $context View or edit context. |
| 697 | 697 | * @return int |
| 698 | 698 | */ |
| 699 | - public function get_author( $context = 'view' ) { |
|
| 700 | - return (int) $this->get_prop( 'author', $context ); |
|
| 699 | + public function get_author($context = 'view') { |
|
| 700 | + return (int) $this->get_prop('author', $context); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -707,8 +707,8 @@ discard block |
||
| 707 | 707 | * @param string $context View or edit context. |
| 708 | 708 | * @return int |
| 709 | 709 | */ |
| 710 | - public function get_user_id( $context = 'view' ) { |
|
| 711 | - return $this->get_author( $context ); |
|
| 710 | + public function get_user_id($context = 'view') { |
|
| 711 | + return $this->get_author($context); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -718,8 +718,8 @@ discard block |
||
| 718 | 718 | * @param string $context View or edit context. |
| 719 | 719 | * @return int |
| 720 | 720 | */ |
| 721 | - public function get_customer_id( $context = 'view' ) { |
|
| 722 | - return $this->get_author( $context ); |
|
| 721 | + public function get_customer_id($context = 'view') { |
|
| 722 | + return $this->get_author($context); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
@@ -729,8 +729,8 @@ discard block |
||
| 729 | 729 | * @param string $context View or edit context. |
| 730 | 730 | * @return string |
| 731 | 731 | */ |
| 732 | - public function get_ip( $context = 'view' ) { |
|
| 733 | - return $this->get_prop( 'user_ip', $context ); |
|
| 732 | + public function get_ip($context = 'view') { |
|
| 733 | + return $this->get_prop('user_ip', $context); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | /** |
@@ -740,8 +740,8 @@ discard block |
||
| 740 | 740 | * @param string $context View or edit context. |
| 741 | 741 | * @return string |
| 742 | 742 | */ |
| 743 | - public function get_user_ip( $context = 'view' ) { |
|
| 744 | - return $this->get_ip( $context ); |
|
| 743 | + public function get_user_ip($context = 'view') { |
|
| 744 | + return $this->get_ip($context); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | * @param string $context View or edit context. |
| 752 | 752 | * @return string |
| 753 | 753 | */ |
| 754 | - public function get_customer_ip( $context = 'view' ) { |
|
| 755 | - return $this->get_ip( $context ); |
|
| 754 | + public function get_customer_ip($context = 'view') { |
|
| 755 | + return $this->get_ip($context); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | /** |
@@ -762,8 +762,8 @@ discard block |
||
| 762 | 762 | * @param string $context View or edit context. |
| 763 | 763 | * @return string |
| 764 | 764 | */ |
| 765 | - public function get_first_name( $context = 'view' ) { |
|
| 766 | - return $this->get_prop( 'first_name', $context ); |
|
| 765 | + public function get_first_name($context = 'view') { |
|
| 766 | + return $this->get_prop('first_name', $context); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /** |
@@ -773,8 +773,8 @@ discard block |
||
| 773 | 773 | * @param string $context View or edit context. |
| 774 | 774 | * @return int |
| 775 | 775 | */ |
| 776 | - public function get_user_first_name( $context = 'view' ) { |
|
| 777 | - return $this->get_first_name( $context ); |
|
| 776 | + public function get_user_first_name($context = 'view') { |
|
| 777 | + return $this->get_first_name($context); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | /** |
@@ -784,8 +784,8 @@ discard block |
||
| 784 | 784 | * @param string $context View or edit context. |
| 785 | 785 | * @return int |
| 786 | 786 | */ |
| 787 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 788 | - return $this->get_first_name( $context ); |
|
| 787 | + public function get_customer_first_name($context = 'view') { |
|
| 788 | + return $this->get_first_name($context); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | /** |
@@ -795,8 +795,8 @@ discard block |
||
| 795 | 795 | * @param string $context View or edit context. |
| 796 | 796 | * @return string |
| 797 | 797 | */ |
| 798 | - public function get_last_name( $context = 'view' ) { |
|
| 799 | - return $this->get_prop( 'last_name', $context ); |
|
| 798 | + public function get_last_name($context = 'view') { |
|
| 799 | + return $this->get_prop('last_name', $context); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | /** |
@@ -806,8 +806,8 @@ discard block |
||
| 806 | 806 | * @param string $context View or edit context. |
| 807 | 807 | * @return int |
| 808 | 808 | */ |
| 809 | - public function get_user_last_name( $context = 'view' ) { |
|
| 810 | - return $this->get_last_name( $context ); |
|
| 809 | + public function get_user_last_name($context = 'view') { |
|
| 810 | + return $this->get_last_name($context); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -817,8 +817,8 @@ discard block |
||
| 817 | 817 | * @param string $context View or edit context. |
| 818 | 818 | * @return int |
| 819 | 819 | */ |
| 820 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 821 | - return $this->get_last_name( $context ); |
|
| 820 | + public function get_customer_last_name($context = 'view') { |
|
| 821 | + return $this->get_last_name($context); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -828,8 +828,8 @@ discard block |
||
| 828 | 828 | * @param string $context View or edit context. |
| 829 | 829 | * @return string |
| 830 | 830 | */ |
| 831 | - public function get_full_name( $context = 'view' ) { |
|
| 832 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 831 | + public function get_full_name($context = 'view') { |
|
| 832 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -839,8 +839,8 @@ discard block |
||
| 839 | 839 | * @param string $context View or edit context. |
| 840 | 840 | * @return int |
| 841 | 841 | */ |
| 842 | - public function get_user_full_name( $context = 'view' ) { |
|
| 843 | - return $this->get_full_name( $context ); |
|
| 842 | + public function get_user_full_name($context = 'view') { |
|
| 843 | + return $this->get_full_name($context); |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | /** |
@@ -850,8 +850,8 @@ discard block |
||
| 850 | 850 | * @param string $context View or edit context. |
| 851 | 851 | * @return int |
| 852 | 852 | */ |
| 853 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 854 | - return $this->get_full_name( $context ); |
|
| 853 | + public function get_customer_full_name($context = 'view') { |
|
| 854 | + return $this->get_full_name($context); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -861,8 +861,8 @@ discard block |
||
| 861 | 861 | * @param string $context View or edit context. |
| 862 | 862 | * @return string |
| 863 | 863 | */ |
| 864 | - public function get_phone( $context = 'view' ) { |
|
| 865 | - return $this->get_prop( 'phone', $context ); |
|
| 864 | + public function get_phone($context = 'view') { |
|
| 865 | + return $this->get_prop('phone', $context); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | /** |
@@ -872,8 +872,8 @@ discard block |
||
| 872 | 872 | * @param string $context View or edit context. |
| 873 | 873 | * @return int |
| 874 | 874 | */ |
| 875 | - public function get_phone_number( $context = 'view' ) { |
|
| 876 | - return $this->get_phone( $context ); |
|
| 875 | + public function get_phone_number($context = 'view') { |
|
| 876 | + return $this->get_phone($context); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | /** |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | * @param string $context View or edit context. |
| 884 | 884 | * @return int |
| 885 | 885 | */ |
| 886 | - public function get_user_phone( $context = 'view' ) { |
|
| 887 | - return $this->get_phone( $context ); |
|
| 886 | + public function get_user_phone($context = 'view') { |
|
| 887 | + return $this->get_phone($context); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
@@ -894,8 +894,8 @@ discard block |
||
| 894 | 894 | * @param string $context View or edit context. |
| 895 | 895 | * @return int |
| 896 | 896 | */ |
| 897 | - public function get_customer_phone( $context = 'view' ) { |
|
| 898 | - return $this->get_phone( $context ); |
|
| 897 | + public function get_customer_phone($context = 'view') { |
|
| 898 | + return $this->get_phone($context); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | /** |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | * @param string $context View or edit context. |
| 906 | 906 | * @return string |
| 907 | 907 | */ |
| 908 | - public function get_email( $context = 'view' ) { |
|
| 909 | - return $this->get_prop( 'email', $context ); |
|
| 908 | + public function get_email($context = 'view') { |
|
| 909 | + return $this->get_prop('email', $context); |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
@@ -916,8 +916,8 @@ discard block |
||
| 916 | 916 | * @param string $context View or edit context. |
| 917 | 917 | * @return string |
| 918 | 918 | */ |
| 919 | - public function get_email_address( $context = 'view' ) { |
|
| 920 | - return $this->get_email( $context ); |
|
| 919 | + public function get_email_address($context = 'view') { |
|
| 920 | + return $this->get_email($context); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -927,8 +927,8 @@ discard block |
||
| 927 | 927 | * @param string $context View or edit context. |
| 928 | 928 | * @return int |
| 929 | 929 | */ |
| 930 | - public function get_user_email( $context = 'view' ) { |
|
| 931 | - return $this->get_email( $context ); |
|
| 930 | + public function get_user_email($context = 'view') { |
|
| 931 | + return $this->get_email($context); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
@@ -938,8 +938,8 @@ discard block |
||
| 938 | 938 | * @param string $context View or edit context. |
| 939 | 939 | * @return int |
| 940 | 940 | */ |
| 941 | - public function get_customer_email( $context = 'view' ) { |
|
| 942 | - return $this->get_email( $context ); |
|
| 941 | + public function get_customer_email($context = 'view') { |
|
| 942 | + return $this->get_email($context); |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | /** |
@@ -949,9 +949,9 @@ discard block |
||
| 949 | 949 | * @param string $context View or edit context. |
| 950 | 950 | * @return string |
| 951 | 951 | */ |
| 952 | - public function get_country( $context = 'view' ) { |
|
| 953 | - $country = $this->get_prop( 'country', $context ); |
|
| 954 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 952 | + public function get_country($context = 'view') { |
|
| 953 | + $country = $this->get_prop('country', $context); |
|
| 954 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | /** |
@@ -961,8 +961,8 @@ discard block |
||
| 961 | 961 | * @param string $context View or edit context. |
| 962 | 962 | * @return int |
| 963 | 963 | */ |
| 964 | - public function get_user_country( $context = 'view' ) { |
|
| 965 | - return $this->get_country( $context ); |
|
| 964 | + public function get_user_country($context = 'view') { |
|
| 965 | + return $this->get_country($context); |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | /** |
@@ -972,8 +972,8 @@ discard block |
||
| 972 | 972 | * @param string $context View or edit context. |
| 973 | 973 | * @return int |
| 974 | 974 | */ |
| 975 | - public function get_customer_country( $context = 'view' ) { |
|
| 976 | - return $this->get_country( $context ); |
|
| 975 | + public function get_customer_country($context = 'view') { |
|
| 976 | + return $this->get_country($context); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -983,9 +983,9 @@ discard block |
||
| 983 | 983 | * @param string $context View or edit context. |
| 984 | 984 | * @return string |
| 985 | 985 | */ |
| 986 | - public function get_state( $context = 'view' ) { |
|
| 987 | - $state = $this->get_prop( 'state', $context ); |
|
| 988 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 986 | + public function get_state($context = 'view') { |
|
| 987 | + $state = $this->get_prop('state', $context); |
|
| 988 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /** |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | * @param string $context View or edit context. |
| 996 | 996 | * @return int |
| 997 | 997 | */ |
| 998 | - public function get_user_state( $context = 'view' ) { |
|
| 999 | - return $this->get_state( $context ); |
|
| 998 | + public function get_user_state($context = 'view') { |
|
| 999 | + return $this->get_state($context); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1006,8 +1006,8 @@ discard block |
||
| 1006 | 1006 | * @param string $context View or edit context. |
| 1007 | 1007 | * @return int |
| 1008 | 1008 | */ |
| 1009 | - public function get_customer_state( $context = 'view' ) { |
|
| 1010 | - return $this->get_state( $context ); |
|
| 1009 | + public function get_customer_state($context = 'view') { |
|
| 1010 | + return $this->get_state($context); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
@@ -1017,8 +1017,8 @@ discard block |
||
| 1017 | 1017 | * @param string $context View or edit context. |
| 1018 | 1018 | * @return string |
| 1019 | 1019 | */ |
| 1020 | - public function get_city( $context = 'view' ) { |
|
| 1021 | - return $this->get_prop( 'city', $context ); |
|
| 1020 | + public function get_city($context = 'view') { |
|
| 1021 | + return $this->get_prop('city', $context); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | /** |
@@ -1028,8 +1028,8 @@ discard block |
||
| 1028 | 1028 | * @param string $context View or edit context. |
| 1029 | 1029 | * @return string |
| 1030 | 1030 | */ |
| 1031 | - public function get_user_city( $context = 'view' ) { |
|
| 1032 | - return $this->get_city( $context ); |
|
| 1031 | + public function get_user_city($context = 'view') { |
|
| 1032 | + return $this->get_city($context); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | /** |
@@ -1039,8 +1039,8 @@ discard block |
||
| 1039 | 1039 | * @param string $context View or edit context. |
| 1040 | 1040 | * @return string |
| 1041 | 1041 | */ |
| 1042 | - public function get_customer_city( $context = 'view' ) { |
|
| 1043 | - return $this->get_city( $context ); |
|
| 1042 | + public function get_customer_city($context = 'view') { |
|
| 1043 | + return $this->get_city($context); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
@@ -1050,8 +1050,8 @@ discard block |
||
| 1050 | 1050 | * @param string $context View or edit context. |
| 1051 | 1051 | * @return string |
| 1052 | 1052 | */ |
| 1053 | - public function get_zip( $context = 'view' ) { |
|
| 1054 | - return $this->get_prop( 'zip', $context ); |
|
| 1053 | + public function get_zip($context = 'view') { |
|
| 1054 | + return $this->get_prop('zip', $context); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | /** |
@@ -1061,8 +1061,8 @@ discard block |
||
| 1061 | 1061 | * @param string $context View or edit context. |
| 1062 | 1062 | * @return string |
| 1063 | 1063 | */ |
| 1064 | - public function get_user_zip( $context = 'view' ) { |
|
| 1065 | - return $this->get_zip( $context ); |
|
| 1064 | + public function get_user_zip($context = 'view') { |
|
| 1065 | + return $this->get_zip($context); |
|
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | /** |
@@ -1072,8 +1072,8 @@ discard block |
||
| 1072 | 1072 | * @param string $context View or edit context. |
| 1073 | 1073 | * @return string |
| 1074 | 1074 | */ |
| 1075 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1076 | - return $this->get_zip( $context ); |
|
| 1075 | + public function get_customer_zip($context = 'view') { |
|
| 1076 | + return $this->get_zip($context); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | /** |
@@ -1083,8 +1083,8 @@ discard block |
||
| 1083 | 1083 | * @param string $context View or edit context. |
| 1084 | 1084 | * @return string |
| 1085 | 1085 | */ |
| 1086 | - public function get_company( $context = 'view' ) { |
|
| 1087 | - return $this->get_prop( 'company', $context ); |
|
| 1086 | + public function get_company($context = 'view') { |
|
| 1087 | + return $this->get_prop('company', $context); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
@@ -1094,8 +1094,8 @@ discard block |
||
| 1094 | 1094 | * @param string $context View or edit context. |
| 1095 | 1095 | * @return string |
| 1096 | 1096 | */ |
| 1097 | - public function get_user_company( $context = 'view' ) { |
|
| 1098 | - return $this->get_company( $context ); |
|
| 1097 | + public function get_user_company($context = 'view') { |
|
| 1098 | + return $this->get_company($context); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | /** |
@@ -1105,8 +1105,8 @@ discard block |
||
| 1105 | 1105 | * @param string $context View or edit context. |
| 1106 | 1106 | * @return string |
| 1107 | 1107 | */ |
| 1108 | - public function get_customer_company( $context = 'view' ) { |
|
| 1109 | - return $this->get_company( $context ); |
|
| 1108 | + public function get_customer_company($context = 'view') { |
|
| 1109 | + return $this->get_company($context); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | /** |
@@ -1116,8 +1116,8 @@ discard block |
||
| 1116 | 1116 | * @param string $context View or edit context. |
| 1117 | 1117 | * @return string |
| 1118 | 1118 | */ |
| 1119 | - public function get_vat_number( $context = 'view' ) { |
|
| 1120 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1119 | + public function get_vat_number($context = 'view') { |
|
| 1120 | + return $this->get_prop('vat_number', $context); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
@@ -1127,8 +1127,8 @@ discard block |
||
| 1127 | 1127 | * @param string $context View or edit context. |
| 1128 | 1128 | * @return string |
| 1129 | 1129 | */ |
| 1130 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1131 | - return $this->get_vat_number( $context ); |
|
| 1130 | + public function get_user_vat_number($context = 'view') { |
|
| 1131 | + return $this->get_vat_number($context); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | /** |
@@ -1138,8 +1138,8 @@ discard block |
||
| 1138 | 1138 | * @param string $context View or edit context. |
| 1139 | 1139 | * @return string |
| 1140 | 1140 | */ |
| 1141 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1142 | - return $this->get_vat_number( $context ); |
|
| 1141 | + public function get_customer_vat_number($context = 'view') { |
|
| 1142 | + return $this->get_vat_number($context); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
@@ -1149,8 +1149,8 @@ discard block |
||
| 1149 | 1149 | * @param string $context View or edit context. |
| 1150 | 1150 | * @return string |
| 1151 | 1151 | */ |
| 1152 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1153 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1152 | + public function get_vat_rate($context = 'view') { |
|
| 1153 | + return $this->get_prop('vat_rate', $context); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /** |
@@ -1160,8 +1160,8 @@ discard block |
||
| 1160 | 1160 | * @param string $context View or edit context. |
| 1161 | 1161 | * @return string |
| 1162 | 1162 | */ |
| 1163 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1164 | - return $this->get_vat_rate( $context ); |
|
| 1163 | + public function get_user_vat_rate($context = 'view') { |
|
| 1164 | + return $this->get_vat_rate($context); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | /** |
@@ -1171,8 +1171,8 @@ discard block |
||
| 1171 | 1171 | * @param string $context View or edit context. |
| 1172 | 1172 | * @return string |
| 1173 | 1173 | */ |
| 1174 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1175 | - return $this->get_vat_rate( $context ); |
|
| 1174 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1175 | + return $this->get_vat_rate($context); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /** |
@@ -1182,8 +1182,8 @@ discard block |
||
| 1182 | 1182 | * @param string $context View or edit context. |
| 1183 | 1183 | * @return string |
| 1184 | 1184 | */ |
| 1185 | - public function get_address( $context = 'view' ) { |
|
| 1186 | - return $this->get_prop( 'address', $context ); |
|
| 1185 | + public function get_address($context = 'view') { |
|
| 1186 | + return $this->get_prop('address', $context); |
|
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | 1189 | /** |
@@ -1193,8 +1193,8 @@ discard block |
||
| 1193 | 1193 | * @param string $context View or edit context. |
| 1194 | 1194 | * @return string |
| 1195 | 1195 | */ |
| 1196 | - public function get_user_address( $context = 'view' ) { |
|
| 1197 | - return $this->get_address( $context ); |
|
| 1196 | + public function get_user_address($context = 'view') { |
|
| 1197 | + return $this->get_address($context); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | /** |
@@ -1204,8 +1204,8 @@ discard block |
||
| 1204 | 1204 | * @param string $context View or edit context. |
| 1205 | 1205 | * @return string |
| 1206 | 1206 | */ |
| 1207 | - public function get_customer_address( $context = 'view' ) { |
|
| 1208 | - return $this->get_address( $context ); |
|
| 1207 | + public function get_customer_address($context = 'view') { |
|
| 1208 | + return $this->get_address($context); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | /** |
@@ -1215,8 +1215,8 @@ discard block |
||
| 1215 | 1215 | * @param string $context View or edit context. |
| 1216 | 1216 | * @return bool |
| 1217 | 1217 | */ |
| 1218 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1219 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1218 | + public function get_is_viewed($context = 'view') { |
|
| 1219 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | 1222 | /** |
@@ -1226,8 +1226,8 @@ discard block |
||
| 1226 | 1226 | * @param string $context View or edit context. |
| 1227 | 1227 | * @return bool |
| 1228 | 1228 | */ |
| 1229 | - public function get_email_cc( $context = 'view' ) { |
|
| 1230 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1229 | + public function get_email_cc($context = 'view') { |
|
| 1230 | + return $this->get_prop('email_cc', $context); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1237,8 +1237,8 @@ discard block |
||
| 1237 | 1237 | * @param string $context View or edit context. |
| 1238 | 1238 | * @return bool |
| 1239 | 1239 | */ |
| 1240 | - public function get_template( $context = 'view' ) { |
|
| 1241 | - return $this->get_prop( 'template', $context ); |
|
| 1240 | + public function get_template($context = 'view') { |
|
| 1241 | + return $this->get_prop('template', $context); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | /** |
@@ -1248,8 +1248,8 @@ discard block |
||
| 1248 | 1248 | * @param string $context View or edit context. |
| 1249 | 1249 | * @return bool |
| 1250 | 1250 | */ |
| 1251 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1252 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1251 | + public function get_address_confirmed($context = 'view') { |
|
| 1252 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | /** |
@@ -1259,8 +1259,8 @@ discard block |
||
| 1259 | 1259 | * @param string $context View or edit context. |
| 1260 | 1260 | * @return bool |
| 1261 | 1261 | */ |
| 1262 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1263 | - return $this->get_address_confirmed( $context ); |
|
| 1262 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1263 | + return $this->get_address_confirmed($context); |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | /** |
@@ -1270,8 +1270,8 @@ discard block |
||
| 1270 | 1270 | * @param string $context View or edit context. |
| 1271 | 1271 | * @return bool |
| 1272 | 1272 | */ |
| 1273 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1274 | - return $this->get_address_confirmed( $context ); |
|
| 1273 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1274 | + return $this->get_address_confirmed($context); |
|
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | 1277 | /** |
@@ -1281,12 +1281,12 @@ discard block |
||
| 1281 | 1281 | * @param string $context View or edit context. |
| 1282 | 1282 | * @return float |
| 1283 | 1283 | */ |
| 1284 | - public function get_subtotal( $context = 'view' ) { |
|
| 1285 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1284 | + public function get_subtotal($context = 'view') { |
|
| 1285 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1286 | 1286 | |
| 1287 | 1287 | // Backwards compatibility. |
| 1288 | - if ( is_bool( $context ) && $context ) { |
|
| 1289 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
| 1288 | + if (is_bool($context) && $context) { |
|
| 1289 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | return $subtotal; |
@@ -1299,8 +1299,8 @@ discard block |
||
| 1299 | 1299 | * @param string $context View or edit context. |
| 1300 | 1300 | * @return float |
| 1301 | 1301 | */ |
| 1302 | - public function get_total_discount( $context = 'view' ) { |
|
| 1303 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1302 | + public function get_total_discount($context = 'view') { |
|
| 1303 | + return (float) $this->get_prop('total_discount', $context); |
|
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | /** |
@@ -1310,18 +1310,18 @@ discard block |
||
| 1310 | 1310 | * @param string $context View or edit context. |
| 1311 | 1311 | * @return float |
| 1312 | 1312 | */ |
| 1313 | - public function get_total_tax( $context = 'view' ) { |
|
| 1314 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1313 | + public function get_total_tax($context = 'view') { |
|
| 1314 | + return (float) $this->get_prop('total_tax', $context); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
| 1318 | 1318 | * @deprecated |
| 1319 | 1319 | */ |
| 1320 | - public function get_final_tax( $currency = false ) { |
|
| 1320 | + public function get_final_tax($currency = false) { |
|
| 1321 | 1321 | $tax = $this->get_total_tax(); |
| 1322 | 1322 | |
| 1323 | - if ( $currency ) { |
|
| 1324 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1323 | + if ($currency) { |
|
| 1324 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | return $tax; |
@@ -1334,8 +1334,8 @@ discard block |
||
| 1334 | 1334 | * @param string $context View or edit context. |
| 1335 | 1335 | * @return float |
| 1336 | 1336 | */ |
| 1337 | - public function get_total_fees( $context = 'view' ) { |
|
| 1338 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1337 | + public function get_total_fees($context = 'view') { |
|
| 1338 | + return (float) $this->get_prop('total_fees', $context); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
@@ -1345,8 +1345,8 @@ discard block |
||
| 1345 | 1345 | * @param string $context View or edit context. |
| 1346 | 1346 | * @return float |
| 1347 | 1347 | */ |
| 1348 | - public function get_fees_total( $context = 'view' ) { |
|
| 1349 | - return $this->get_total_fees( $context ); |
|
| 1348 | + public function get_fees_total($context = 'view') { |
|
| 1349 | + return $this->get_total_fees($context); |
|
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | /** |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | */ |
| 1358 | 1358 | public function get_total() { |
| 1359 | 1359 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
| 1360 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1360 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | 1363 | /** |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | */ |
| 1370 | 1370 | public function get_initial_total() { |
| 1371 | 1371 | |
| 1372 | - if ( empty( $this->totals ) ) { |
|
| 1372 | + if (empty($this->totals)) { |
|
| 1373 | 1373 | $this->recalculate_total(); |
| 1374 | 1374 | } |
| 1375 | 1375 | |
@@ -1379,11 +1379,11 @@ discard block |
||
| 1379 | 1379 | $subtotal = $this->totals['subtotal']['initial']; |
| 1380 | 1380 | $total = $tax + $fee - $discount + $subtotal; |
| 1381 | 1381 | |
| 1382 | - if ( 0 > $total ) { |
|
| 1382 | + if (0 > $total) { |
|
| 1383 | 1383 | $total = 0; |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1386 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | /** |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | */ |
| 1396 | 1396 | public function get_recurring_total() { |
| 1397 | 1397 | |
| 1398 | - if ( empty( $this->totals ) ) { |
|
| 1398 | + if (empty($this->totals)) { |
|
| 1399 | 1399 | $this->recalculate_total(); |
| 1400 | 1400 | } |
| 1401 | 1401 | |
@@ -1405,11 +1405,11 @@ discard block |
||
| 1405 | 1405 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1406 | 1406 | $total = $tax + $fee - $discount + $subtotal; |
| 1407 | 1407 | |
| 1408 | - if ( 0 > $total ) { |
|
| 1408 | + if (0 > $total) { |
|
| 1409 | 1409 | $total = 0; |
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1412 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | /** |
@@ -1420,10 +1420,10 @@ discard block |
||
| 1420 | 1420 | * @param string $currency Whether to include the currency. |
| 1421 | 1421 | * @return float |
| 1422 | 1422 | */ |
| 1423 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1423 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1424 | 1424 | |
| 1425 | 1425 | // Maybe recalculate totals. |
| 1426 | - if ( empty( $this->totals ) ) { |
|
| 1426 | + if (empty($this->totals)) { |
|
| 1427 | 1427 | $this->recalculate_total(); |
| 1428 | 1428 | } |
| 1429 | 1429 | |
@@ -1443,8 +1443,8 @@ discard block |
||
| 1443 | 1443 | $currency |
| 1444 | 1444 | ); |
| 1445 | 1445 | |
| 1446 | - if ( isset( $data[$field] ) ) { |
|
| 1447 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1446 | + if (isset($data[$field])) { |
|
| 1447 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | 1450 | return $data; |
@@ -1457,8 +1457,8 @@ discard block |
||
| 1457 | 1457 | * @param string $context View or edit context. |
| 1458 | 1458 | * @return array |
| 1459 | 1459 | */ |
| 1460 | - public function get_fees( $context = 'view' ) { |
|
| 1461 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1460 | + public function get_fees($context = 'view') { |
|
| 1461 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | 1464 | /** |
@@ -1468,8 +1468,8 @@ discard block |
||
| 1468 | 1468 | * @param string $context View or edit context. |
| 1469 | 1469 | * @return array |
| 1470 | 1470 | */ |
| 1471 | - public function get_discounts( $context = 'view' ) { |
|
| 1472 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1471 | + public function get_discounts($context = 'view') { |
|
| 1472 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | /** |
@@ -1479,8 +1479,8 @@ discard block |
||
| 1479 | 1479 | * @param string $context View or edit context. |
| 1480 | 1480 | * @return array |
| 1481 | 1481 | */ |
| 1482 | - public function get_taxes( $context = 'view' ) { |
|
| 1483 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1482 | + public function get_taxes($context = 'view') { |
|
| 1483 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | 1486 | /** |
@@ -1490,8 +1490,8 @@ discard block |
||
| 1490 | 1490 | * @param string $context View or edit context. |
| 1491 | 1491 | * @return GetPaid_Form_Item[] |
| 1492 | 1492 | */ |
| 1493 | - public function get_items( $context = 'view' ) { |
|
| 1494 | - return $this->get_prop( 'items', $context ); |
|
| 1493 | + public function get_items($context = 'view') { |
|
| 1494 | + return $this->get_prop('items', $context); |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
@@ -1501,8 +1501,8 @@ discard block |
||
| 1501 | 1501 | * @param string $context View or edit context. |
| 1502 | 1502 | * @return int |
| 1503 | 1503 | */ |
| 1504 | - public function get_payment_form( $context = 'view' ) { |
|
| 1505 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1504 | + public function get_payment_form($context = 'view') { |
|
| 1505 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | /** |
@@ -1512,8 +1512,8 @@ discard block |
||
| 1512 | 1512 | * @param string $context View or edit context. |
| 1513 | 1513 | * @return string |
| 1514 | 1514 | */ |
| 1515 | - public function get_submission_id( $context = 'view' ) { |
|
| 1516 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1515 | + public function get_submission_id($context = 'view') { |
|
| 1516 | + return $this->get_prop('submission_id', $context); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | /** |
@@ -1523,8 +1523,8 @@ discard block |
||
| 1523 | 1523 | * @param string $context View or edit context. |
| 1524 | 1524 | * @return string |
| 1525 | 1525 | */ |
| 1526 | - public function get_discount_code( $context = 'view' ) { |
|
| 1527 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1526 | + public function get_discount_code($context = 'view') { |
|
| 1527 | + return $this->get_prop('discount_code', $context); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | /** |
@@ -1534,8 +1534,8 @@ discard block |
||
| 1534 | 1534 | * @param string $context View or edit context. |
| 1535 | 1535 | * @return string |
| 1536 | 1536 | */ |
| 1537 | - public function get_gateway( $context = 'view' ) { |
|
| 1538 | - return $this->get_prop( 'gateway', $context ); |
|
| 1537 | + public function get_gateway($context = 'view') { |
|
| 1538 | + return $this->get_prop('gateway', $context); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | /** |
@@ -1545,8 +1545,8 @@ discard block |
||
| 1545 | 1545 | * @return string |
| 1546 | 1546 | */ |
| 1547 | 1547 | public function get_gateway_title() { |
| 1548 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1549 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1548 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1549 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | /** |
@@ -1556,8 +1556,8 @@ discard block |
||
| 1556 | 1556 | * @param string $context View or edit context. |
| 1557 | 1557 | * @return string |
| 1558 | 1558 | */ |
| 1559 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1560 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1559 | + public function get_transaction_id($context = 'view') { |
|
| 1560 | + return $this->get_prop('transaction_id', $context); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | /** |
@@ -1567,9 +1567,9 @@ discard block |
||
| 1567 | 1567 | * @param string $context View or edit context. |
| 1568 | 1568 | * @return string |
| 1569 | 1569 | */ |
| 1570 | - public function get_currency( $context = 'view' ) { |
|
| 1571 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1572 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1570 | + public function get_currency($context = 'view') { |
|
| 1571 | + $currency = $this->get_prop('currency', $context); |
|
| 1572 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | /** |
@@ -1579,8 +1579,8 @@ discard block |
||
| 1579 | 1579 | * @param string $context View or edit context. |
| 1580 | 1580 | * @return bool |
| 1581 | 1581 | */ |
| 1582 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1583 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1582 | + public function get_disable_taxes($context = 'view') { |
|
| 1583 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | /** |
@@ -1590,12 +1590,12 @@ discard block |
||
| 1590 | 1590 | * @param string $context View or edit context. |
| 1591 | 1591 | * @return int |
| 1592 | 1592 | */ |
| 1593 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1594 | - $subscription_id = $this->get_prop( 'subscription_id', $context ); |
|
| 1593 | + public function get_subscription_id($context = 'view') { |
|
| 1594 | + $subscription_id = $this->get_prop('subscription_id', $context); |
|
| 1595 | 1595 | |
| 1596 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1596 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1597 | 1597 | $parent = $this->get_parent(); |
| 1598 | - return $parent->get_subscription_id( $context ); |
|
| 1598 | + return $parent->get_subscription_id($context); |
|
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | return $subscription_id; |
@@ -1608,20 +1608,20 @@ discard block |
||
| 1608 | 1608 | * @param string $context View or edit context. |
| 1609 | 1609 | * @return array |
| 1610 | 1610 | */ |
| 1611 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1611 | + public function get_payment_meta($context = 'view') { |
|
| 1612 | 1612 | |
| 1613 | 1613 | return array( |
| 1614 | - 'price' => $this->get_total( $context ), |
|
| 1615 | - 'date' => $this->get_date_created( $context ), |
|
| 1616 | - 'user_email' => $this->get_email( $context ), |
|
| 1617 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1618 | - 'currency' => $this->get_currency( $context ), |
|
| 1619 | - 'items' => $this->get_items( $context ), |
|
| 1620 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1614 | + 'price' => $this->get_total($context), |
|
| 1615 | + 'date' => $this->get_date_created($context), |
|
| 1616 | + 'user_email' => $this->get_email($context), |
|
| 1617 | + 'invoice_key' => $this->get_key($context), |
|
| 1618 | + 'currency' => $this->get_currency($context), |
|
| 1619 | + 'items' => $this->get_items($context), |
|
| 1620 | + 'user_info' => $this->get_user_info($context), |
|
| 1621 | 1621 | 'cart_details' => $this->get_cart_details(), |
| 1622 | - 'status' => $this->get_status( $context ), |
|
| 1623 | - 'fees' => $this->get_fees( $context ), |
|
| 1624 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1622 | + 'status' => $this->get_status($context), |
|
| 1623 | + 'fees' => $this->get_fees($context), |
|
| 1624 | + 'taxes' => $this->get_taxes($context), |
|
| 1625 | 1625 | ); |
| 1626 | 1626 | |
| 1627 | 1627 | } |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | $items = $this->get_items(); |
| 1637 | 1637 | $cart_details = array(); |
| 1638 | 1638 | |
| 1639 | - foreach ( $items as $item_id => $item ) { |
|
| 1639 | + foreach ($items as $item_id => $item) { |
|
| 1640 | 1640 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1641 | 1641 | } |
| 1642 | 1642 | |
@@ -1648,11 +1648,11 @@ discard block |
||
| 1648 | 1648 | * |
| 1649 | 1649 | * @return null|GetPaid_Form_Item |
| 1650 | 1650 | */ |
| 1651 | - public function get_recurring( $object = false ) { |
|
| 1651 | + public function get_recurring($object = false) { |
|
| 1652 | 1652 | |
| 1653 | 1653 | // Are we returning an object? |
| 1654 | - if ( $object ) { |
|
| 1655 | - return $this->get_item( $this->recurring_item ); |
|
| 1654 | + if ($object) { |
|
| 1655 | + return $this->get_item($this->recurring_item); |
|
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | 1658 | return $this->recurring_item; |
@@ -1667,15 +1667,15 @@ discard block |
||
| 1667 | 1667 | public function get_subscription_name() { |
| 1668 | 1668 | |
| 1669 | 1669 | // Retrieve the recurring name |
| 1670 | - $item = $this->get_recurring( true ); |
|
| 1670 | + $item = $this->get_recurring(true); |
|
| 1671 | 1671 | |
| 1672 | 1672 | // Abort if it does not exist. |
| 1673 | - if ( empty( $item ) ) { |
|
| 1673 | + if (empty($item)) { |
|
| 1674 | 1674 | return ''; |
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | 1677 | // Return the item name. |
| 1678 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1678 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | /** |
@@ -1685,9 +1685,9 @@ discard block |
||
| 1685 | 1685 | * @return string |
| 1686 | 1686 | */ |
| 1687 | 1687 | public function get_view_url() { |
| 1688 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1689 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1690 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1688 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1689 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1690 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | 1693 | /** |
@@ -1696,25 +1696,25 @@ discard block |
||
| 1696 | 1696 | * @since 1.0.19 |
| 1697 | 1697 | * @return string |
| 1698 | 1698 | */ |
| 1699 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1699 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1700 | 1700 | |
| 1701 | 1701 | // Retrieve the checkout url. |
| 1702 | 1702 | $pay_url = wpinv_get_checkout_uri(); |
| 1703 | 1703 | |
| 1704 | 1704 | // Maybe force ssl. |
| 1705 | - if ( is_ssl() ) { |
|
| 1706 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1705 | + if (is_ssl()) { |
|
| 1706 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | 1709 | // Add the invoice key. |
| 1710 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1710 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1711 | 1711 | |
| 1712 | 1712 | // (Maybe?) add a secret |
| 1713 | - if ( $secret ) { |
|
| 1714 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1713 | + if ($secret) { |
|
| 1714 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1717 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | 1720 | /** |
@@ -1727,8 +1727,8 @@ discard block |
||
| 1727 | 1727 | * @param string $context View or edit context. |
| 1728 | 1728 | * @return mixed Value of the given invoice property (if set). |
| 1729 | 1729 | */ |
| 1730 | - public function get( $key, $context = 'view' ) { |
|
| 1731 | - return $this->get_prop( $key, $context ); |
|
| 1730 | + public function get($key, $context = 'view') { |
|
| 1731 | + return $this->get_prop($key, $context); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | 1734 | /* |
@@ -1751,11 +1751,11 @@ discard block |
||
| 1751 | 1751 | * @param mixed $value new value. |
| 1752 | 1752 | * @return mixed Value of the given invoice property (if set). |
| 1753 | 1753 | */ |
| 1754 | - public function set( $key, $value ) { |
|
| 1754 | + public function set($key, $value) { |
|
| 1755 | 1755 | |
| 1756 | 1756 | $setter = "set_$key"; |
| 1757 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1758 | - $this->{$setter}( $value ); |
|
| 1757 | + if (is_callable(array($this, $setter))) { |
|
| 1758 | + $this->{$setter}($value); |
|
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | 1761 | } |
@@ -1769,35 +1769,35 @@ discard block |
||
| 1769 | 1769 | * @param bool $manual_update Is this a manual status change?. |
| 1770 | 1770 | * @return array details of change. |
| 1771 | 1771 | */ |
| 1772 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1772 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1773 | 1773 | $old_status = $this->get_status(); |
| 1774 | 1774 | |
| 1775 | - $this->set_prop( 'status', $new_status ); |
|
| 1775 | + $this->set_prop('status', $new_status); |
|
| 1776 | 1776 | |
| 1777 | 1777 | // If setting the status, ensure it's set to a valid status. |
| 1778 | - if ( true === $this->object_read ) { |
|
| 1778 | + if (true === $this->object_read) { |
|
| 1779 | 1779 | |
| 1780 | 1780 | // Only allow valid new status. |
| 1781 | - if ( ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
| 1781 | + if (!array_key_exists($new_status, wpinv_get_invoice_statuses(false, true))) { |
|
| 1782 | 1782 | $new_status = 'wpi-pending'; |
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | 1785 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1786 | - if ( $old_status && ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
| 1786 | + if ($old_status && !array_key_exists($new_status, wpinv_get_invoice_statuses(false, true))) { |
|
| 1787 | 1787 | $old_status = 'wpi-pending'; |
| 1788 | 1788 | } |
| 1789 | 1789 | } |
| 1790 | 1790 | |
| 1791 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1791 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 1792 | 1792 | $this->status_transition = array( |
| 1793 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1793 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1794 | 1794 | 'to' => $new_status, |
| 1795 | 1795 | 'note' => $note, |
| 1796 | 1796 | 'manual' => (bool) $manual_update, |
| 1797 | 1797 | ); |
| 1798 | 1798 | |
| 1799 | - if ( $manual_update ) { |
|
| 1800 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1799 | + if ($manual_update) { |
|
| 1800 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | 1803 | $this->maybe_set_date_paid(); |
@@ -1820,8 +1820,8 @@ discard block |
||
| 1820 | 1820 | */ |
| 1821 | 1821 | public function maybe_set_date_paid() { |
| 1822 | 1822 | |
| 1823 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1824 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1823 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 1824 | + $this->set_date_completed(current_time('mysql')); |
|
| 1825 | 1825 | } |
| 1826 | 1826 | } |
| 1827 | 1827 | |
@@ -1830,11 +1830,11 @@ discard block |
||
| 1830 | 1830 | * |
| 1831 | 1831 | * @since 1.0.19 |
| 1832 | 1832 | */ |
| 1833 | - public function set_parent_id( $value ) { |
|
| 1834 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1833 | + public function set_parent_id($value) { |
|
| 1834 | + if ($value && ($value === $this->get_id())) { |
|
| 1835 | 1835 | return; |
| 1836 | 1836 | } |
| 1837 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1837 | + $this->set_prop('parent_id', absint($value)); |
|
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | /** |
@@ -1842,8 +1842,8 @@ discard block |
||
| 1842 | 1842 | * |
| 1843 | 1843 | * @since 1.0.19 |
| 1844 | 1844 | */ |
| 1845 | - public function set_version( $value ) { |
|
| 1846 | - $this->set_prop( 'version', $value ); |
|
| 1845 | + public function set_version($value) { |
|
| 1846 | + $this->set_prop('version', $value); |
|
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | 1849 | /** |
@@ -1853,15 +1853,15 @@ discard block |
||
| 1853 | 1853 | * @param string $value Value to set. |
| 1854 | 1854 | * @return bool Whether or not the date was set. |
| 1855 | 1855 | */ |
| 1856 | - public function set_date_created( $value ) { |
|
| 1857 | - $date = strtotime( $value ); |
|
| 1856 | + public function set_date_created($value) { |
|
| 1857 | + $date = strtotime($value); |
|
| 1858 | 1858 | |
| 1859 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1860 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1859 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1860 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 1861 | 1861 | return true; |
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | - return $this->set_prop( 'date_created', '' ); |
|
| 1864 | + return $this->set_prop('date_created', ''); |
|
| 1865 | 1865 | |
| 1866 | 1866 | } |
| 1867 | 1867 | |
@@ -1872,15 +1872,15 @@ discard block |
||
| 1872 | 1872 | * @param string $value Value to set. |
| 1873 | 1873 | * @return bool Whether or not the date was set. |
| 1874 | 1874 | */ |
| 1875 | - public function set_due_date( $value ) { |
|
| 1876 | - $date = strtotime( $value ); |
|
| 1875 | + public function set_due_date($value) { |
|
| 1876 | + $date = strtotime($value); |
|
| 1877 | 1877 | |
| 1878 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1879 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1878 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1879 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 1880 | 1880 | return true; |
| 1881 | 1881 | } |
| 1882 | 1882 | |
| 1883 | - $this->set_prop( 'due_date', '' ); |
|
| 1883 | + $this->set_prop('due_date', ''); |
|
| 1884 | 1884 | return false; |
| 1885 | 1885 | |
| 1886 | 1886 | } |
@@ -1891,8 +1891,8 @@ discard block |
||
| 1891 | 1891 | * @since 1.0.19 |
| 1892 | 1892 | * @param string $value New name. |
| 1893 | 1893 | */ |
| 1894 | - public function set_date_due( $value ) { |
|
| 1895 | - $this->set_due_date( $value ); |
|
| 1894 | + public function set_date_due($value) { |
|
| 1895 | + $this->set_due_date($value); |
|
| 1896 | 1896 | } |
| 1897 | 1897 | |
| 1898 | 1898 | /** |
@@ -1902,15 +1902,15 @@ discard block |
||
| 1902 | 1902 | * @param string $value Value to set. |
| 1903 | 1903 | * @return bool Whether or not the date was set. |
| 1904 | 1904 | */ |
| 1905 | - public function set_completed_date( $value ) { |
|
| 1906 | - $date = strtotime( $value ); |
|
| 1905 | + public function set_completed_date($value) { |
|
| 1906 | + $date = strtotime($value); |
|
| 1907 | 1907 | |
| 1908 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1909 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1908 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1909 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 1910 | 1910 | return true; |
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | - $this->set_prop( 'completed_date', '' ); |
|
| 1913 | + $this->set_prop('completed_date', ''); |
|
| 1914 | 1914 | return false; |
| 1915 | 1915 | |
| 1916 | 1916 | } |
@@ -1921,8 +1921,8 @@ discard block |
||
| 1921 | 1921 | * @since 1.0.19 |
| 1922 | 1922 | * @param string $value New name. |
| 1923 | 1923 | */ |
| 1924 | - public function set_date_completed( $value ) { |
|
| 1925 | - $this->set_completed_date( $value ); |
|
| 1924 | + public function set_date_completed($value) { |
|
| 1925 | + $this->set_completed_date($value); |
|
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | 1928 | /** |
@@ -1932,15 +1932,15 @@ discard block |
||
| 1932 | 1932 | * @param string $value Value to set. |
| 1933 | 1933 | * @return bool Whether or not the date was set. |
| 1934 | 1934 | */ |
| 1935 | - public function set_date_modified( $value ) { |
|
| 1936 | - $date = strtotime( $value ); |
|
| 1935 | + public function set_date_modified($value) { |
|
| 1936 | + $date = strtotime($value); |
|
| 1937 | 1937 | |
| 1938 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1939 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1938 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1939 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 1940 | 1940 | return true; |
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | - $this->set_prop( 'date_modified', '' ); |
|
| 1943 | + $this->set_prop('date_modified', ''); |
|
| 1944 | 1944 | return false; |
| 1945 | 1945 | |
| 1946 | 1946 | } |
@@ -1951,9 +1951,9 @@ discard block |
||
| 1951 | 1951 | * @since 1.0.19 |
| 1952 | 1952 | * @param string $value New number. |
| 1953 | 1953 | */ |
| 1954 | - public function set_number( $value ) { |
|
| 1955 | - $number = sanitize_text_field( $value ); |
|
| 1956 | - $this->set_prop( 'number', $number ); |
|
| 1954 | + public function set_number($value) { |
|
| 1955 | + $number = sanitize_text_field($value); |
|
| 1956 | + $this->set_prop('number', $number); |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | /** |
@@ -1962,9 +1962,9 @@ discard block |
||
| 1962 | 1962 | * @since 1.0.19 |
| 1963 | 1963 | * @param string $value Type. |
| 1964 | 1964 | */ |
| 1965 | - public function set_type( $value ) { |
|
| 1966 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 1967 | - $this->set_prop( 'type', $type ); |
|
| 1965 | + public function set_type($value) { |
|
| 1966 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 1967 | + $this->set_prop('type', $type); |
|
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | 1970 | /** |
@@ -1973,10 +1973,10 @@ discard block |
||
| 1973 | 1973 | * @since 1.0.19 |
| 1974 | 1974 | * @param string $value Post type. |
| 1975 | 1975 | */ |
| 1976 | - public function set_post_type( $value ) { |
|
| 1977 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 1978 | - $this->set_type( $value ); |
|
| 1979 | - $this->set_prop( 'post_type', $value ); |
|
| 1976 | + public function set_post_type($value) { |
|
| 1977 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 1978 | + $this->set_type($value); |
|
| 1979 | + $this->set_prop('post_type', $value); |
|
| 1980 | 1980 | } |
| 1981 | 1981 | } |
| 1982 | 1982 | |
@@ -1986,9 +1986,9 @@ discard block |
||
| 1986 | 1986 | * @since 1.0.19 |
| 1987 | 1987 | * @param string $value New key. |
| 1988 | 1988 | */ |
| 1989 | - public function set_key( $value ) { |
|
| 1990 | - $key = sanitize_text_field( $value ); |
|
| 1991 | - $this->set_prop( 'key', $key ); |
|
| 1989 | + public function set_key($value) { |
|
| 1990 | + $key = sanitize_text_field($value); |
|
| 1991 | + $this->set_prop('key', $key); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | |
| 1994 | 1994 | /** |
@@ -1997,9 +1997,9 @@ discard block |
||
| 1997 | 1997 | * @since 1.0.19 |
| 1998 | 1998 | * @param string $value mode. |
| 1999 | 1999 | */ |
| 2000 | - public function set_mode( $value ) { |
|
| 2001 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2002 | - $this->set_prop( 'value', $value ); |
|
| 2000 | + public function set_mode($value) { |
|
| 2001 | + if (!in_array($value, array('live', 'test'))) { |
|
| 2002 | + $this->set_prop('value', $value); |
|
| 2003 | 2003 | } |
| 2004 | 2004 | } |
| 2005 | 2005 | |
@@ -2009,8 +2009,8 @@ discard block |
||
| 2009 | 2009 | * @since 1.0.19 |
| 2010 | 2010 | * @param string $value path. |
| 2011 | 2011 | */ |
| 2012 | - public function set_path( $value ) { |
|
| 2013 | - $this->set_prop( 'path', $value ); |
|
| 2012 | + public function set_path($value) { |
|
| 2013 | + $this->set_prop('path', $value); |
|
| 2014 | 2014 | } |
| 2015 | 2015 | |
| 2016 | 2016 | /** |
@@ -2019,9 +2019,9 @@ discard block |
||
| 2019 | 2019 | * @since 1.0.19 |
| 2020 | 2020 | * @param string $value New name. |
| 2021 | 2021 | */ |
| 2022 | - public function set_name( $value ) { |
|
| 2023 | - $name = sanitize_text_field( $value ); |
|
| 2024 | - $this->set_prop( 'name', $name ); |
|
| 2022 | + public function set_name($value) { |
|
| 2023 | + $name = sanitize_text_field($value); |
|
| 2024 | + $this->set_prop('name', $name); |
|
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | /** |
@@ -2030,8 +2030,8 @@ discard block |
||
| 2030 | 2030 | * @since 1.0.19 |
| 2031 | 2031 | * @param string $value New name. |
| 2032 | 2032 | */ |
| 2033 | - public function set_title( $value ) { |
|
| 2034 | - $this->set_name( $value ); |
|
| 2033 | + public function set_title($value) { |
|
| 2034 | + $this->set_name($value); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | /** |
@@ -2040,9 +2040,9 @@ discard block |
||
| 2040 | 2040 | * @since 1.0.19 |
| 2041 | 2041 | * @param string $value New description. |
| 2042 | 2042 | */ |
| 2043 | - public function set_description( $value ) { |
|
| 2044 | - $description = wp_kses_post( $value ); |
|
| 2045 | - return $this->set_prop( 'description', $description ); |
|
| 2043 | + public function set_description($value) { |
|
| 2044 | + $description = wp_kses_post($value); |
|
| 2045 | + return $this->set_prop('description', $description); |
|
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | 2048 | /** |
@@ -2051,8 +2051,8 @@ discard block |
||
| 2051 | 2051 | * @since 1.0.19 |
| 2052 | 2052 | * @param string $value New description. |
| 2053 | 2053 | */ |
| 2054 | - public function set_excerpt( $value ) { |
|
| 2055 | - $this->set_description( $value ); |
|
| 2054 | + public function set_excerpt($value) { |
|
| 2055 | + $this->set_description($value); |
|
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | /** |
@@ -2061,8 +2061,8 @@ discard block |
||
| 2061 | 2061 | * @since 1.0.19 |
| 2062 | 2062 | * @param string $value New description. |
| 2063 | 2063 | */ |
| 2064 | - public function set_summary( $value ) { |
|
| 2065 | - $this->set_description( $value ); |
|
| 2064 | + public function set_summary($value) { |
|
| 2065 | + $this->set_description($value); |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | /** |
@@ -2071,12 +2071,12 @@ discard block |
||
| 2071 | 2071 | * @since 1.0.19 |
| 2072 | 2072 | * @param int $value New author. |
| 2073 | 2073 | */ |
| 2074 | - public function set_author( $value ) { |
|
| 2075 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2074 | + public function set_author($value) { |
|
| 2075 | + $user = get_user_by('id', (int) $value); |
|
| 2076 | 2076 | |
| 2077 | - if ( $user && $user->ID ) { |
|
| 2078 | - $this->set_prop( 'author', $user->ID ); |
|
| 2079 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2077 | + if ($user && $user->ID) { |
|
| 2078 | + $this->set_prop('author', $user->ID); |
|
| 2079 | + $this->set_prop('email', $user->user_email); |
|
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | 2082 | } |
@@ -2087,8 +2087,8 @@ discard block |
||
| 2087 | 2087 | * @since 1.0.19 |
| 2088 | 2088 | * @param int $value New user id. |
| 2089 | 2089 | */ |
| 2090 | - public function set_user_id( $value ) { |
|
| 2091 | - $this->set_author( $value ); |
|
| 2090 | + public function set_user_id($value) { |
|
| 2091 | + $this->set_author($value); |
|
| 2092 | 2092 | } |
| 2093 | 2093 | |
| 2094 | 2094 | /** |
@@ -2097,8 +2097,8 @@ discard block |
||
| 2097 | 2097 | * @since 1.0.19 |
| 2098 | 2098 | * @param int $value New user id. |
| 2099 | 2099 | */ |
| 2100 | - public function set_customer_id( $value ) { |
|
| 2101 | - $this->set_author( $value ); |
|
| 2100 | + public function set_customer_id($value) { |
|
| 2101 | + $this->set_author($value); |
|
| 2102 | 2102 | } |
| 2103 | 2103 | |
| 2104 | 2104 | /** |
@@ -2107,8 +2107,8 @@ discard block |
||
| 2107 | 2107 | * @since 1.0.19 |
| 2108 | 2108 | * @param string $value ip address. |
| 2109 | 2109 | */ |
| 2110 | - public function set_ip( $value ) { |
|
| 2111 | - $this->set_prop( 'ip', $value ); |
|
| 2110 | + public function set_ip($value) { |
|
| 2111 | + $this->set_prop('ip', $value); |
|
| 2112 | 2112 | } |
| 2113 | 2113 | |
| 2114 | 2114 | /** |
@@ -2117,8 +2117,8 @@ discard block |
||
| 2117 | 2117 | * @since 1.0.19 |
| 2118 | 2118 | * @param string $value ip address. |
| 2119 | 2119 | */ |
| 2120 | - public function set_user_ip( $value ) { |
|
| 2121 | - $this->set_ip( $value ); |
|
| 2120 | + public function set_user_ip($value) { |
|
| 2121 | + $this->set_ip($value); |
|
| 2122 | 2122 | } |
| 2123 | 2123 | |
| 2124 | 2124 | /** |
@@ -2127,8 +2127,8 @@ discard block |
||
| 2127 | 2127 | * @since 1.0.19 |
| 2128 | 2128 | * @param string $value first name. |
| 2129 | 2129 | */ |
| 2130 | - public function set_first_name( $value ) { |
|
| 2131 | - $this->set_prop( 'first_name', $value ); |
|
| 2130 | + public function set_first_name($value) { |
|
| 2131 | + $this->set_prop('first_name', $value); |
|
| 2132 | 2132 | } |
| 2133 | 2133 | |
| 2134 | 2134 | /** |
@@ -2137,8 +2137,8 @@ discard block |
||
| 2137 | 2137 | * @since 1.0.19 |
| 2138 | 2138 | * @param string $value first name. |
| 2139 | 2139 | */ |
| 2140 | - public function set_user_first_name( $value ) { |
|
| 2141 | - $this->set_first_name( $value ); |
|
| 2140 | + public function set_user_first_name($value) { |
|
| 2141 | + $this->set_first_name($value); |
|
| 2142 | 2142 | } |
| 2143 | 2143 | |
| 2144 | 2144 | /** |
@@ -2147,8 +2147,8 @@ discard block |
||
| 2147 | 2147 | * @since 1.0.19 |
| 2148 | 2148 | * @param string $value first name. |
| 2149 | 2149 | */ |
| 2150 | - public function set_customer_first_name( $value ) { |
|
| 2151 | - $this->set_first_name( $value ); |
|
| 2150 | + public function set_customer_first_name($value) { |
|
| 2151 | + $this->set_first_name($value); |
|
| 2152 | 2152 | } |
| 2153 | 2153 | |
| 2154 | 2154 | /** |
@@ -2157,8 +2157,8 @@ discard block |
||
| 2157 | 2157 | * @since 1.0.19 |
| 2158 | 2158 | * @param string $value last name. |
| 2159 | 2159 | */ |
| 2160 | - public function set_last_name( $value ) { |
|
| 2161 | - $this->set_prop( 'last_name', $value ); |
|
| 2160 | + public function set_last_name($value) { |
|
| 2161 | + $this->set_prop('last_name', $value); |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | /** |
@@ -2167,8 +2167,8 @@ discard block |
||
| 2167 | 2167 | * @since 1.0.19 |
| 2168 | 2168 | * @param string $value last name. |
| 2169 | 2169 | */ |
| 2170 | - public function set_user_last_name( $value ) { |
|
| 2171 | - $this->set_last_name( $value ); |
|
| 2170 | + public function set_user_last_name($value) { |
|
| 2171 | + $this->set_last_name($value); |
|
| 2172 | 2172 | } |
| 2173 | 2173 | |
| 2174 | 2174 | /** |
@@ -2177,8 +2177,8 @@ discard block |
||
| 2177 | 2177 | * @since 1.0.19 |
| 2178 | 2178 | * @param string $value last name. |
| 2179 | 2179 | */ |
| 2180 | - public function set_customer_last_name( $value ) { |
|
| 2181 | - $this->set_last_name( $value ); |
|
| 2180 | + public function set_customer_last_name($value) { |
|
| 2181 | + $this->set_last_name($value); |
|
| 2182 | 2182 | } |
| 2183 | 2183 | |
| 2184 | 2184 | /** |
@@ -2187,8 +2187,8 @@ discard block |
||
| 2187 | 2187 | * @since 1.0.19 |
| 2188 | 2188 | * @param string $value phone. |
| 2189 | 2189 | */ |
| 2190 | - public function set_phone( $value ) { |
|
| 2191 | - $this->set_prop( 'phone', $value ); |
|
| 2190 | + public function set_phone($value) { |
|
| 2191 | + $this->set_prop('phone', $value); |
|
| 2192 | 2192 | } |
| 2193 | 2193 | |
| 2194 | 2194 | /** |
@@ -2197,8 +2197,8 @@ discard block |
||
| 2197 | 2197 | * @since 1.0.19 |
| 2198 | 2198 | * @param string $value phone. |
| 2199 | 2199 | */ |
| 2200 | - public function set_user_phone( $value ) { |
|
| 2201 | - $this->set_phone( $value ); |
|
| 2200 | + public function set_user_phone($value) { |
|
| 2201 | + $this->set_phone($value); |
|
| 2202 | 2202 | } |
| 2203 | 2203 | |
| 2204 | 2204 | /** |
@@ -2207,8 +2207,8 @@ discard block |
||
| 2207 | 2207 | * @since 1.0.19 |
| 2208 | 2208 | * @param string $value phone. |
| 2209 | 2209 | */ |
| 2210 | - public function set_customer_phone( $value ) { |
|
| 2211 | - $this->set_phone( $value ); |
|
| 2210 | + public function set_customer_phone($value) { |
|
| 2211 | + $this->set_phone($value); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | |
| 2214 | 2214 | /** |
@@ -2217,8 +2217,8 @@ discard block |
||
| 2217 | 2217 | * @since 1.0.19 |
| 2218 | 2218 | * @param string $value phone. |
| 2219 | 2219 | */ |
| 2220 | - public function set_phone_number( $value ) { |
|
| 2221 | - $this->set_phone( $value ); |
|
| 2220 | + public function set_phone_number($value) { |
|
| 2221 | + $this->set_phone($value); |
|
| 2222 | 2222 | } |
| 2223 | 2223 | |
| 2224 | 2224 | /** |
@@ -2227,8 +2227,8 @@ discard block |
||
| 2227 | 2227 | * @since 1.0.19 |
| 2228 | 2228 | * @param string $value email address. |
| 2229 | 2229 | */ |
| 2230 | - public function set_email( $value ) { |
|
| 2231 | - $this->set_prop( 'email', $value ); |
|
| 2230 | + public function set_email($value) { |
|
| 2231 | + $this->set_prop('email', $value); |
|
| 2232 | 2232 | } |
| 2233 | 2233 | |
| 2234 | 2234 | /** |
@@ -2237,8 +2237,8 @@ discard block |
||
| 2237 | 2237 | * @since 1.0.19 |
| 2238 | 2238 | * @param string $value email address. |
| 2239 | 2239 | */ |
| 2240 | - public function set_user_email( $value ) { |
|
| 2241 | - $this->set_email( $value ); |
|
| 2240 | + public function set_user_email($value) { |
|
| 2241 | + $this->set_email($value); |
|
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | 2244 | /** |
@@ -2247,8 +2247,8 @@ discard block |
||
| 2247 | 2247 | * @since 1.0.19 |
| 2248 | 2248 | * @param string $value email address. |
| 2249 | 2249 | */ |
| 2250 | - public function set_email_address( $value ) { |
|
| 2251 | - $this->set_email( $value ); |
|
| 2250 | + public function set_email_address($value) { |
|
| 2251 | + $this->set_email($value); |
|
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | /** |
@@ -2257,8 +2257,8 @@ discard block |
||
| 2257 | 2257 | * @since 1.0.19 |
| 2258 | 2258 | * @param string $value email address. |
| 2259 | 2259 | */ |
| 2260 | - public function set_customer_email( $value ) { |
|
| 2261 | - $this->set_email( $value ); |
|
| 2260 | + public function set_customer_email($value) { |
|
| 2261 | + $this->set_email($value); |
|
| 2262 | 2262 | } |
| 2263 | 2263 | |
| 2264 | 2264 | /** |
@@ -2267,8 +2267,8 @@ discard block |
||
| 2267 | 2267 | * @since 1.0.19 |
| 2268 | 2268 | * @param string $value country. |
| 2269 | 2269 | */ |
| 2270 | - public function set_country( $value ) { |
|
| 2271 | - $this->set_prop( 'country', $value ); |
|
| 2270 | + public function set_country($value) { |
|
| 2271 | + $this->set_prop('country', $value); |
|
| 2272 | 2272 | } |
| 2273 | 2273 | |
| 2274 | 2274 | /** |
@@ -2277,8 +2277,8 @@ discard block |
||
| 2277 | 2277 | * @since 1.0.19 |
| 2278 | 2278 | * @param string $value country. |
| 2279 | 2279 | */ |
| 2280 | - public function set_user_country( $value ) { |
|
| 2281 | - $this->set_country( $value ); |
|
| 2280 | + public function set_user_country($value) { |
|
| 2281 | + $this->set_country($value); |
|
| 2282 | 2282 | } |
| 2283 | 2283 | |
| 2284 | 2284 | /** |
@@ -2287,8 +2287,8 @@ discard block |
||
| 2287 | 2287 | * @since 1.0.19 |
| 2288 | 2288 | * @param string $value country. |
| 2289 | 2289 | */ |
| 2290 | - public function set_customer_country( $value ) { |
|
| 2291 | - $this->set_country( $value ); |
|
| 2290 | + public function set_customer_country($value) { |
|
| 2291 | + $this->set_country($value); |
|
| 2292 | 2292 | } |
| 2293 | 2293 | |
| 2294 | 2294 | /** |
@@ -2297,8 +2297,8 @@ discard block |
||
| 2297 | 2297 | * @since 1.0.19 |
| 2298 | 2298 | * @param string $value state. |
| 2299 | 2299 | */ |
| 2300 | - public function set_state( $value ) { |
|
| 2301 | - $this->set_prop( 'state', $value ); |
|
| 2300 | + public function set_state($value) { |
|
| 2301 | + $this->set_prop('state', $value); |
|
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | 2304 | /** |
@@ -2307,8 +2307,8 @@ discard block |
||
| 2307 | 2307 | * @since 1.0.19 |
| 2308 | 2308 | * @param string $value state. |
| 2309 | 2309 | */ |
| 2310 | - public function set_user_state( $value ) { |
|
| 2311 | - $this->set_state( $value ); |
|
| 2310 | + public function set_user_state($value) { |
|
| 2311 | + $this->set_state($value); |
|
| 2312 | 2312 | } |
| 2313 | 2313 | |
| 2314 | 2314 | /** |
@@ -2317,8 +2317,8 @@ discard block |
||
| 2317 | 2317 | * @since 1.0.19 |
| 2318 | 2318 | * @param string $value state. |
| 2319 | 2319 | */ |
| 2320 | - public function set_customer_state( $value ) { |
|
| 2321 | - $this->set_state( $value ); |
|
| 2320 | + public function set_customer_state($value) { |
|
| 2321 | + $this->set_state($value); |
|
| 2322 | 2322 | } |
| 2323 | 2323 | |
| 2324 | 2324 | /** |
@@ -2327,8 +2327,8 @@ discard block |
||
| 2327 | 2327 | * @since 1.0.19 |
| 2328 | 2328 | * @param string $value city. |
| 2329 | 2329 | */ |
| 2330 | - public function set_city( $value ) { |
|
| 2331 | - $this->set_prop( 'city', $value ); |
|
| 2330 | + public function set_city($value) { |
|
| 2331 | + $this->set_prop('city', $value); |
|
| 2332 | 2332 | } |
| 2333 | 2333 | |
| 2334 | 2334 | /** |
@@ -2337,8 +2337,8 @@ discard block |
||
| 2337 | 2337 | * @since 1.0.19 |
| 2338 | 2338 | * @param string $value city. |
| 2339 | 2339 | */ |
| 2340 | - public function set_user_city( $value ) { |
|
| 2341 | - $this->set_city( $value ); |
|
| 2340 | + public function set_user_city($value) { |
|
| 2341 | + $this->set_city($value); |
|
| 2342 | 2342 | } |
| 2343 | 2343 | |
| 2344 | 2344 | /** |
@@ -2347,8 +2347,8 @@ discard block |
||
| 2347 | 2347 | * @since 1.0.19 |
| 2348 | 2348 | * @param string $value city. |
| 2349 | 2349 | */ |
| 2350 | - public function set_customer_city( $value ) { |
|
| 2351 | - $this->set_city( $value ); |
|
| 2350 | + public function set_customer_city($value) { |
|
| 2351 | + $this->set_city($value); |
|
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | 2354 | /** |
@@ -2357,8 +2357,8 @@ discard block |
||
| 2357 | 2357 | * @since 1.0.19 |
| 2358 | 2358 | * @param string $value zip. |
| 2359 | 2359 | */ |
| 2360 | - public function set_zip( $value ) { |
|
| 2361 | - $this->set_prop( 'zip', $value ); |
|
| 2360 | + public function set_zip($value) { |
|
| 2361 | + $this->set_prop('zip', $value); |
|
| 2362 | 2362 | } |
| 2363 | 2363 | |
| 2364 | 2364 | /** |
@@ -2367,8 +2367,8 @@ discard block |
||
| 2367 | 2367 | * @since 1.0.19 |
| 2368 | 2368 | * @param string $value zip. |
| 2369 | 2369 | */ |
| 2370 | - public function set_user_zip( $value ) { |
|
| 2371 | - $this->set_zip( $value ); |
|
| 2370 | + public function set_user_zip($value) { |
|
| 2371 | + $this->set_zip($value); |
|
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | 2374 | /** |
@@ -2377,8 +2377,8 @@ discard block |
||
| 2377 | 2377 | * @since 1.0.19 |
| 2378 | 2378 | * @param string $value zip. |
| 2379 | 2379 | */ |
| 2380 | - public function set_customer_zip( $value ) { |
|
| 2381 | - $this->set_zip( $value ); |
|
| 2380 | + public function set_customer_zip($value) { |
|
| 2381 | + $this->set_zip($value); |
|
| 2382 | 2382 | } |
| 2383 | 2383 | |
| 2384 | 2384 | /** |
@@ -2387,8 +2387,8 @@ discard block |
||
| 2387 | 2387 | * @since 1.0.19 |
| 2388 | 2388 | * @param string $value company. |
| 2389 | 2389 | */ |
| 2390 | - public function set_company( $value ) { |
|
| 2391 | - $this->set_prop( 'company', $value ); |
|
| 2390 | + public function set_company($value) { |
|
| 2391 | + $this->set_prop('company', $value); |
|
| 2392 | 2392 | } |
| 2393 | 2393 | |
| 2394 | 2394 | /** |
@@ -2397,8 +2397,8 @@ discard block |
||
| 2397 | 2397 | * @since 1.0.19 |
| 2398 | 2398 | * @param string $value company. |
| 2399 | 2399 | */ |
| 2400 | - public function set_user_company( $value ) { |
|
| 2401 | - $this->set_company( $value ); |
|
| 2400 | + public function set_user_company($value) { |
|
| 2401 | + $this->set_company($value); |
|
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | 2404 | /** |
@@ -2407,8 +2407,8 @@ discard block |
||
| 2407 | 2407 | * @since 1.0.19 |
| 2408 | 2408 | * @param string $value company. |
| 2409 | 2409 | */ |
| 2410 | - public function set_customer_company( $value ) { |
|
| 2411 | - $this->set_company( $value ); |
|
| 2410 | + public function set_customer_company($value) { |
|
| 2411 | + $this->set_company($value); |
|
| 2412 | 2412 | } |
| 2413 | 2413 | |
| 2414 | 2414 | /** |
@@ -2417,8 +2417,8 @@ discard block |
||
| 2417 | 2417 | * @since 1.0.19 |
| 2418 | 2418 | * @param string $value var number. |
| 2419 | 2419 | */ |
| 2420 | - public function set_vat_number( $value ) { |
|
| 2421 | - $this->set_prop( 'vat_number', $value ); |
|
| 2420 | + public function set_vat_number($value) { |
|
| 2421 | + $this->set_prop('vat_number', $value); |
|
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | 2424 | /** |
@@ -2427,8 +2427,8 @@ discard block |
||
| 2427 | 2427 | * @since 1.0.19 |
| 2428 | 2428 | * @param string $value var number. |
| 2429 | 2429 | */ |
| 2430 | - public function set_user_vat_number( $value ) { |
|
| 2431 | - $this->set_vat_number( $value ); |
|
| 2430 | + public function set_user_vat_number($value) { |
|
| 2431 | + $this->set_vat_number($value); |
|
| 2432 | 2432 | } |
| 2433 | 2433 | |
| 2434 | 2434 | /** |
@@ -2437,8 +2437,8 @@ discard block |
||
| 2437 | 2437 | * @since 1.0.19 |
| 2438 | 2438 | * @param string $value var number. |
| 2439 | 2439 | */ |
| 2440 | - public function set_customer_vat_number( $value ) { |
|
| 2441 | - $this->set_vat_number( $value ); |
|
| 2440 | + public function set_customer_vat_number($value) { |
|
| 2441 | + $this->set_vat_number($value); |
|
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | 2444 | /** |
@@ -2447,8 +2447,8 @@ discard block |
||
| 2447 | 2447 | * @since 1.0.19 |
| 2448 | 2448 | * @param string $value var rate. |
| 2449 | 2449 | */ |
| 2450 | - public function set_vat_rate( $value ) { |
|
| 2451 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2450 | + public function set_vat_rate($value) { |
|
| 2451 | + $this->set_prop('vat_rate', $value); |
|
| 2452 | 2452 | } |
| 2453 | 2453 | |
| 2454 | 2454 | /** |
@@ -2457,8 +2457,8 @@ discard block |
||
| 2457 | 2457 | * @since 1.0.19 |
| 2458 | 2458 | * @param string $value var number. |
| 2459 | 2459 | */ |
| 2460 | - public function set_user_vat_rate( $value ) { |
|
| 2461 | - $this->set_vat_rate( $value ); |
|
| 2460 | + public function set_user_vat_rate($value) { |
|
| 2461 | + $this->set_vat_rate($value); |
|
| 2462 | 2462 | } |
| 2463 | 2463 | |
| 2464 | 2464 | /** |
@@ -2467,8 +2467,8 @@ discard block |
||
| 2467 | 2467 | * @since 1.0.19 |
| 2468 | 2468 | * @param string $value var number. |
| 2469 | 2469 | */ |
| 2470 | - public function set_customer_vat_rate( $value ) { |
|
| 2471 | - $this->set_vat_rate( $value ); |
|
| 2470 | + public function set_customer_vat_rate($value) { |
|
| 2471 | + $this->set_vat_rate($value); |
|
| 2472 | 2472 | } |
| 2473 | 2473 | |
| 2474 | 2474 | /** |
@@ -2477,8 +2477,8 @@ discard block |
||
| 2477 | 2477 | * @since 1.0.19 |
| 2478 | 2478 | * @param string $value address. |
| 2479 | 2479 | */ |
| 2480 | - public function set_address( $value ) { |
|
| 2481 | - $this->set_prop( 'address', $value ); |
|
| 2480 | + public function set_address($value) { |
|
| 2481 | + $this->set_prop('address', $value); |
|
| 2482 | 2482 | } |
| 2483 | 2483 | |
| 2484 | 2484 | /** |
@@ -2487,8 +2487,8 @@ discard block |
||
| 2487 | 2487 | * @since 1.0.19 |
| 2488 | 2488 | * @param string $value address. |
| 2489 | 2489 | */ |
| 2490 | - public function set_user_address( $value ) { |
|
| 2491 | - $this->set_address( $value ); |
|
| 2490 | + public function set_user_address($value) { |
|
| 2491 | + $this->set_address($value); |
|
| 2492 | 2492 | } |
| 2493 | 2493 | |
| 2494 | 2494 | /** |
@@ -2497,8 +2497,8 @@ discard block |
||
| 2497 | 2497 | * @since 1.0.19 |
| 2498 | 2498 | * @param string $value address. |
| 2499 | 2499 | */ |
| 2500 | - public function set_customer_address( $value ) { |
|
| 2501 | - $this->set_address( $value ); |
|
| 2500 | + public function set_customer_address($value) { |
|
| 2501 | + $this->set_address($value); |
|
| 2502 | 2502 | } |
| 2503 | 2503 | |
| 2504 | 2504 | /** |
@@ -2507,8 +2507,8 @@ discard block |
||
| 2507 | 2507 | * @since 1.0.19 |
| 2508 | 2508 | * @param int|bool $value confirmed. |
| 2509 | 2509 | */ |
| 2510 | - public function set_is_viewed( $value ) { |
|
| 2511 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2510 | + public function set_is_viewed($value) { |
|
| 2511 | + $this->set_prop('is_viewed', $value); |
|
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | 2514 | /** |
@@ -2517,8 +2517,8 @@ discard block |
||
| 2517 | 2517 | * @since 1.0.19 |
| 2518 | 2518 | * @param string $value email recipients. |
| 2519 | 2519 | */ |
| 2520 | - public function set_email_cc( $value ) { |
|
| 2521 | - $this->set_prop( 'email_cc', $value ); |
|
| 2520 | + public function set_email_cc($value) { |
|
| 2521 | + $this->set_prop('email_cc', $value); |
|
| 2522 | 2522 | } |
| 2523 | 2523 | |
| 2524 | 2524 | /** |
@@ -2527,9 +2527,9 @@ discard block |
||
| 2527 | 2527 | * @since 1.0.19 |
| 2528 | 2528 | * @param string $value email recipients. |
| 2529 | 2529 | */ |
| 2530 | - public function set_template( $value ) { |
|
| 2531 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2532 | - $this->set_prop( 'template', $value ); |
|
| 2530 | + public function set_template($value) { |
|
| 2531 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2532 | + $this->set_prop('template', $value); |
|
| 2533 | 2533 | } |
| 2534 | 2534 | } |
| 2535 | 2535 | |
@@ -2539,8 +2539,8 @@ discard block |
||
| 2539 | 2539 | * @since 1.0.19 |
| 2540 | 2540 | * @param int|bool $value confirmed. |
| 2541 | 2541 | */ |
| 2542 | - public function set_address_confirmed( $value ) { |
|
| 2543 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2542 | + public function set_address_confirmed($value) { |
|
| 2543 | + $this->set_prop('address_confirmed', $value); |
|
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | 2546 | /** |
@@ -2549,8 +2549,8 @@ discard block |
||
| 2549 | 2549 | * @since 1.0.19 |
| 2550 | 2550 | * @param int|bool $value confirmed. |
| 2551 | 2551 | */ |
| 2552 | - public function set_user_address_confirmed( $value ) { |
|
| 2553 | - $this->set_address_confirmed( $value ); |
|
| 2552 | + public function set_user_address_confirmed($value) { |
|
| 2553 | + $this->set_address_confirmed($value); |
|
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | 2556 | /** |
@@ -2559,8 +2559,8 @@ discard block |
||
| 2559 | 2559 | * @since 1.0.19 |
| 2560 | 2560 | * @param int|bool $value confirmed. |
| 2561 | 2561 | */ |
| 2562 | - public function set_customer_address_confirmed( $value ) { |
|
| 2563 | - $this->set_address_confirmed( $value ); |
|
| 2562 | + public function set_customer_address_confirmed($value) { |
|
| 2563 | + $this->set_address_confirmed($value); |
|
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | 2566 | /** |
@@ -2569,8 +2569,8 @@ discard block |
||
| 2569 | 2569 | * @since 1.0.19 |
| 2570 | 2570 | * @param float $value sub total. |
| 2571 | 2571 | */ |
| 2572 | - public function set_subtotal( $value ) { |
|
| 2573 | - $this->set_prop( 'subtotal', $value ); |
|
| 2572 | + public function set_subtotal($value) { |
|
| 2573 | + $this->set_prop('subtotal', $value); |
|
| 2574 | 2574 | } |
| 2575 | 2575 | |
| 2576 | 2576 | /** |
@@ -2579,8 +2579,8 @@ discard block |
||
| 2579 | 2579 | * @since 1.0.19 |
| 2580 | 2580 | * @param float $value discount total. |
| 2581 | 2581 | */ |
| 2582 | - public function set_total_discount( $value ) { |
|
| 2583 | - $this->set_prop( 'total_discount', $value ); |
|
| 2582 | + public function set_total_discount($value) { |
|
| 2583 | + $this->set_prop('total_discount', $value); |
|
| 2584 | 2584 | } |
| 2585 | 2585 | |
| 2586 | 2586 | /** |
@@ -2589,8 +2589,8 @@ discard block |
||
| 2589 | 2589 | * @since 1.0.19 |
| 2590 | 2590 | * @param float $value discount total. |
| 2591 | 2591 | */ |
| 2592 | - public function set_discount( $value ) { |
|
| 2593 | - $this->set_total_discount( $value ); |
|
| 2592 | + public function set_discount($value) { |
|
| 2593 | + $this->set_total_discount($value); |
|
| 2594 | 2594 | } |
| 2595 | 2595 | |
| 2596 | 2596 | /** |
@@ -2599,8 +2599,8 @@ discard block |
||
| 2599 | 2599 | * @since 1.0.19 |
| 2600 | 2600 | * @param float $value tax total. |
| 2601 | 2601 | */ |
| 2602 | - public function set_total_tax( $value ) { |
|
| 2603 | - $this->set_prop( 'total_tax', $value ); |
|
| 2602 | + public function set_total_tax($value) { |
|
| 2603 | + $this->set_prop('total_tax', $value); |
|
| 2604 | 2604 | } |
| 2605 | 2605 | |
| 2606 | 2606 | /** |
@@ -2609,8 +2609,8 @@ discard block |
||
| 2609 | 2609 | * @since 1.0.19 |
| 2610 | 2610 | * @param float $value tax total. |
| 2611 | 2611 | */ |
| 2612 | - public function set_tax_total( $value ) { |
|
| 2613 | - $this->set_total_tax( $value ); |
|
| 2612 | + public function set_tax_total($value) { |
|
| 2613 | + $this->set_total_tax($value); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | |
| 2616 | 2616 | /** |
@@ -2619,8 +2619,8 @@ discard block |
||
| 2619 | 2619 | * @since 1.0.19 |
| 2620 | 2620 | * @param float $value fees total. |
| 2621 | 2621 | */ |
| 2622 | - public function set_total_fees( $value ) { |
|
| 2623 | - $this->set_prop( 'total_fees', $value ); |
|
| 2622 | + public function set_total_fees($value) { |
|
| 2623 | + $this->set_prop('total_fees', $value); |
|
| 2624 | 2624 | } |
| 2625 | 2625 | |
| 2626 | 2626 | /** |
@@ -2629,8 +2629,8 @@ discard block |
||
| 2629 | 2629 | * @since 1.0.19 |
| 2630 | 2630 | * @param float $value fees total. |
| 2631 | 2631 | */ |
| 2632 | - public function set_fees_total( $value ) { |
|
| 2633 | - $this->set_total_fees( $value ); |
|
| 2632 | + public function set_fees_total($value) { |
|
| 2633 | + $this->set_total_fees($value); |
|
| 2634 | 2634 | } |
| 2635 | 2635 | |
| 2636 | 2636 | /** |
@@ -2639,18 +2639,18 @@ discard block |
||
| 2639 | 2639 | * @since 1.0.19 |
| 2640 | 2640 | * @param array $value fees. |
| 2641 | 2641 | */ |
| 2642 | - public function set_fees( $value ) { |
|
| 2642 | + public function set_fees($value) { |
|
| 2643 | 2643 | |
| 2644 | - $this->set_prop( 'fees', array() ); |
|
| 2644 | + $this->set_prop('fees', array()); |
|
| 2645 | 2645 | |
| 2646 | 2646 | // Ensure that we have an array. |
| 2647 | - if ( ! is_array( $value ) ) { |
|
| 2647 | + if (!is_array($value)) { |
|
| 2648 | 2648 | return; |
| 2649 | 2649 | } |
| 2650 | 2650 | |
| 2651 | - foreach ( $value as $name => $data ) { |
|
| 2652 | - if ( isset( $data['amount'] ) ) { |
|
| 2653 | - $this->add_fee( $name, $data['amount'], $data['recurring'] ); |
|
| 2651 | + foreach ($value as $name => $data) { |
|
| 2652 | + if (isset($data['amount'])) { |
|
| 2653 | + $this->add_fee($name, $data['amount'], $data['recurring']); |
|
| 2654 | 2654 | } |
| 2655 | 2655 | } |
| 2656 | 2656 | |
@@ -2662,8 +2662,8 @@ discard block |
||
| 2662 | 2662 | * @since 1.0.19 |
| 2663 | 2663 | * @param array $value taxes. |
| 2664 | 2664 | */ |
| 2665 | - public function set_taxes( $value ) { |
|
| 2666 | - $this->set_prop( 'taxes', $value ); |
|
| 2665 | + public function set_taxes($value) { |
|
| 2666 | + $this->set_prop('taxes', $value); |
|
| 2667 | 2667 | } |
| 2668 | 2668 | |
| 2669 | 2669 | /** |
@@ -2672,17 +2672,17 @@ discard block |
||
| 2672 | 2672 | * @since 1.0.19 |
| 2673 | 2673 | * @param array $value discounts. |
| 2674 | 2674 | */ |
| 2675 | - public function set_discounts( $value ) { |
|
| 2676 | - $this->set_prop( 'discounts', array() ); |
|
| 2675 | + public function set_discounts($value) { |
|
| 2676 | + $this->set_prop('discounts', array()); |
|
| 2677 | 2677 | |
| 2678 | 2678 | // Ensure that we have an array. |
| 2679 | - if ( ! is_array( $value ) ) { |
|
| 2679 | + if (!is_array($value)) { |
|
| 2680 | 2680 | return; |
| 2681 | 2681 | } |
| 2682 | 2682 | |
| 2683 | - foreach ( $value as $name => $data ) { |
|
| 2684 | - if ( isset( $data['amount'] ) ) { |
|
| 2685 | - $this->add_discount( $name, $data['amount'], $data['recurring'] ); |
|
| 2683 | + foreach ($value as $name => $data) { |
|
| 2684 | + if (isset($data['amount'])) { |
|
| 2685 | + $this->add_discount($name, $data['amount'], $data['recurring']); |
|
| 2686 | 2686 | } |
| 2687 | 2687 | } |
| 2688 | 2688 | } |
@@ -2693,18 +2693,18 @@ discard block |
||
| 2693 | 2693 | * @since 1.0.19 |
| 2694 | 2694 | * @param GetPaid_Form_Item[] $value items. |
| 2695 | 2695 | */ |
| 2696 | - public function set_items( $value ) { |
|
| 2696 | + public function set_items($value) { |
|
| 2697 | 2697 | |
| 2698 | 2698 | // Remove existing items. |
| 2699 | - $this->set_prop( 'items', array() ); |
|
| 2699 | + $this->set_prop('items', array()); |
|
| 2700 | 2700 | |
| 2701 | 2701 | // Ensure that we have an array. |
| 2702 | - if ( ! is_array( $value ) ) { |
|
| 2702 | + if (!is_array($value)) { |
|
| 2703 | 2703 | return; |
| 2704 | 2704 | } |
| 2705 | 2705 | |
| 2706 | - foreach ( $value as $item ) { |
|
| 2707 | - $this->add_item( $item ); |
|
| 2706 | + foreach ($value as $item) { |
|
| 2707 | + $this->add_item($item); |
|
| 2708 | 2708 | } |
| 2709 | 2709 | |
| 2710 | 2710 | } |
@@ -2715,8 +2715,8 @@ discard block |
||
| 2715 | 2715 | * @since 1.0.19 |
| 2716 | 2716 | * @param int $value payment form. |
| 2717 | 2717 | */ |
| 2718 | - public function set_payment_form( $value ) { |
|
| 2719 | - $this->set_prop( 'payment_form', $value ); |
|
| 2718 | + public function set_payment_form($value) { |
|
| 2719 | + $this->set_prop('payment_form', $value); |
|
| 2720 | 2720 | } |
| 2721 | 2721 | |
| 2722 | 2722 | /** |
@@ -2725,8 +2725,8 @@ discard block |
||
| 2725 | 2725 | * @since 1.0.19 |
| 2726 | 2726 | * @param string $value submission id. |
| 2727 | 2727 | */ |
| 2728 | - public function set_submission_id( $value ) { |
|
| 2729 | - $this->set_prop( 'submission_id', $value ); |
|
| 2728 | + public function set_submission_id($value) { |
|
| 2729 | + $this->set_prop('submission_id', $value); |
|
| 2730 | 2730 | } |
| 2731 | 2731 | |
| 2732 | 2732 | /** |
@@ -2735,8 +2735,8 @@ discard block |
||
| 2735 | 2735 | * @since 1.0.19 |
| 2736 | 2736 | * @param string $value discount code. |
| 2737 | 2737 | */ |
| 2738 | - public function set_discount_code( $value ) { |
|
| 2739 | - $this->set_prop( 'discount_code', $value ); |
|
| 2738 | + public function set_discount_code($value) { |
|
| 2739 | + $this->set_prop('discount_code', $value); |
|
| 2740 | 2740 | } |
| 2741 | 2741 | |
| 2742 | 2742 | /** |
@@ -2745,8 +2745,8 @@ discard block |
||
| 2745 | 2745 | * @since 1.0.19 |
| 2746 | 2746 | * @param string $value gateway. |
| 2747 | 2747 | */ |
| 2748 | - public function set_gateway( $value ) { |
|
| 2749 | - $this->set_prop( 'gateway', $value ); |
|
| 2748 | + public function set_gateway($value) { |
|
| 2749 | + $this->set_prop('gateway', $value); |
|
| 2750 | 2750 | } |
| 2751 | 2751 | |
| 2752 | 2752 | /** |
@@ -2755,8 +2755,8 @@ discard block |
||
| 2755 | 2755 | * @since 1.0.19 |
| 2756 | 2756 | * @param string $value transaction id. |
| 2757 | 2757 | */ |
| 2758 | - public function set_transaction_id( $value ) { |
|
| 2759 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2758 | + public function set_transaction_id($value) { |
|
| 2759 | + $this->set_prop('transaction_id', $value); |
|
| 2760 | 2760 | } |
| 2761 | 2761 | |
| 2762 | 2762 | /** |
@@ -2765,8 +2765,8 @@ discard block |
||
| 2765 | 2765 | * @since 1.0.19 |
| 2766 | 2766 | * @param string $value currency id. |
| 2767 | 2767 | */ |
| 2768 | - public function set_currency( $value ) { |
|
| 2769 | - $this->set_prop( 'currency', $value ); |
|
| 2768 | + public function set_currency($value) { |
|
| 2769 | + $this->set_prop('currency', $value); |
|
| 2770 | 2770 | } |
| 2771 | 2771 | |
| 2772 | 2772 | /** |
@@ -2775,8 +2775,8 @@ discard block |
||
| 2775 | 2775 | * @since 1.0.19 |
| 2776 | 2776 | * @param bool $value value. |
| 2777 | 2777 | */ |
| 2778 | - public function set_disable_taxes( $value ) { |
|
| 2779 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2778 | + public function set_disable_taxes($value) { |
|
| 2779 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2780 | 2780 | } |
| 2781 | 2781 | |
| 2782 | 2782 | /** |
@@ -2785,8 +2785,8 @@ discard block |
||
| 2785 | 2785 | * @since 1.0.19 |
| 2786 | 2786 | * @param string $value subscription id. |
| 2787 | 2787 | */ |
| 2788 | - public function set_subscription_id( $value ) { |
|
| 2789 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2788 | + public function set_subscription_id($value) { |
|
| 2789 | + $this->set_prop('subscription_id', $value); |
|
| 2790 | 2790 | } |
| 2791 | 2791 | |
| 2792 | 2792 | /* |
@@ -2803,21 +2803,21 @@ discard block |
||
| 2803 | 2803 | */ |
| 2804 | 2804 | public function is_parent() { |
| 2805 | 2805 | $parent = $this->get_parent_id(); |
| 2806 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 2806 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 2807 | 2807 | } |
| 2808 | 2808 | |
| 2809 | 2809 | /** |
| 2810 | 2810 | * Checks if this is a renewal invoice. |
| 2811 | 2811 | */ |
| 2812 | 2812 | public function is_renewal() { |
| 2813 | - return ! $this->is_parent(); |
|
| 2813 | + return !$this->is_parent(); |
|
| 2814 | 2814 | } |
| 2815 | 2815 | |
| 2816 | 2816 | /** |
| 2817 | 2817 | * Checks if this is a recurring invoice. |
| 2818 | 2818 | */ |
| 2819 | 2819 | public function is_recurring() { |
| 2820 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 2820 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 2821 | 2821 | } |
| 2822 | 2822 | |
| 2823 | 2823 | /** |
@@ -2835,72 +2835,72 @@ discard block |
||
| 2835 | 2835 | |
| 2836 | 2836 | $requires_vat = false; |
| 2837 | 2837 | |
| 2838 | - if ( $this->country ) { |
|
| 2838 | + if ($this->country) { |
|
| 2839 | 2839 | $wpi_country = $this->country; |
| 2840 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
| 2840 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
| 2841 | 2841 | } |
| 2842 | 2842 | |
| 2843 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
| 2843 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
| 2844 | 2844 | } |
| 2845 | 2845 | |
| 2846 | 2846 | /** |
| 2847 | 2847 | * Checks to see if the invoice requires payment. |
| 2848 | 2848 | */ |
| 2849 | 2849 | public function is_free() { |
| 2850 | - $is_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 2850 | + $is_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 2851 | 2851 | |
| 2852 | - if ( $is_free && $this->is_recurring() ) { |
|
| 2853 | - $is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 ); |
|
| 2852 | + if ($is_free && $this->is_recurring()) { |
|
| 2853 | + $is_free = !((float) wpinv_round_amount($this->get_recurring_total()) > 0); |
|
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2856 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2857 | 2857 | } |
| 2858 | 2858 | |
| 2859 | 2859 | /** |
| 2860 | 2860 | * Checks if the invoice is paid. |
| 2861 | 2861 | */ |
| 2862 | 2862 | public function is_paid() { |
| 2863 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 2864 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 2863 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 2864 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 2865 | 2865 | } |
| 2866 | 2866 | |
| 2867 | 2867 | /** |
| 2868 | 2868 | * Checks if the invoice needs payment. |
| 2869 | 2869 | */ |
| 2870 | 2870 | public function needs_payment() { |
| 2871 | - $needs_payment = ! $this->is_paid() && ! $this->is_free(); |
|
| 2872 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 2871 | + $needs_payment = !$this->is_paid() && !$this->is_free(); |
|
| 2872 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | /** |
| 2876 | 2876 | * Checks if the invoice is refunded. |
| 2877 | 2877 | */ |
| 2878 | 2878 | public function is_refunded() { |
| 2879 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 2880 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 2879 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 2880 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 2881 | 2881 | } |
| 2882 | 2882 | |
| 2883 | 2883 | /** |
| 2884 | 2884 | * Checks if the invoice is draft. |
| 2885 | 2885 | */ |
| 2886 | 2886 | public function is_draft() { |
| 2887 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 2887 | + return $this->has_status('draft, auto-draft'); |
|
| 2888 | 2888 | } |
| 2889 | 2889 | |
| 2890 | 2890 | /** |
| 2891 | 2891 | * Checks if the invoice has a given status. |
| 2892 | 2892 | */ |
| 2893 | - public function has_status( $status ) { |
|
| 2894 | - $status = wpinv_parse_list( $status ); |
|
| 2895 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 2893 | + public function has_status($status) { |
|
| 2894 | + $status = wpinv_parse_list($status); |
|
| 2895 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 2896 | 2896 | } |
| 2897 | 2897 | |
| 2898 | 2898 | /** |
| 2899 | 2899 | * Checks if the invoice is of a given type. |
| 2900 | 2900 | */ |
| 2901 | - public function is_type( $type ) { |
|
| 2902 | - $type = wpinv_parse_list( $type ); |
|
| 2903 | - return in_array( $this->get_type(), $type ); |
|
| 2901 | + public function is_type($type) { |
|
| 2902 | + $type = wpinv_parse_list($type); |
|
| 2903 | + return in_array($this->get_type(), $type); |
|
| 2904 | 2904 | } |
| 2905 | 2905 | |
| 2906 | 2906 | /** |
@@ -2909,7 +2909,7 @@ discard block |
||
| 2909 | 2909 | * @since 1.0.15 |
| 2910 | 2910 | */ |
| 2911 | 2911 | public function is_quote() { |
| 2912 | - return $this->has_status( 'wpi_quote' ); |
|
| 2912 | + return $this->has_status('wpi_quote'); |
|
| 2913 | 2913 | } |
| 2914 | 2914 | |
| 2915 | 2915 | /** |
@@ -2932,8 +2932,8 @@ discard block |
||
| 2932 | 2932 | * |
| 2933 | 2933 | */ |
| 2934 | 2934 | public function is_initial_free() { |
| 2935 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 2936 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 2935 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 2936 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 2937 | 2937 | } |
| 2938 | 2938 | |
| 2939 | 2939 | /** |
@@ -2943,11 +2943,11 @@ discard block |
||
| 2943 | 2943 | public function item_has_free_trial() { |
| 2944 | 2944 | |
| 2945 | 2945 | // Ensure we have a recurring item. |
| 2946 | - if ( ! $this->is_recurring() ) { |
|
| 2946 | + if (!$this->is_recurring()) { |
|
| 2947 | 2947 | return false; |
| 2948 | 2948 | } |
| 2949 | 2949 | |
| 2950 | - $item = new WPInv_Item( $this->recurring_item ); |
|
| 2950 | + $item = new WPInv_Item($this->recurring_item); |
|
| 2951 | 2951 | return $item->has_free_trial(); |
| 2952 | 2952 | } |
| 2953 | 2953 | |
@@ -2955,7 +2955,7 @@ discard block |
||
| 2955 | 2955 | * Check if the free trial is a result of a discount. |
| 2956 | 2956 | */ |
| 2957 | 2957 | public function is_free_trial_from_discount() { |
| 2958 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 2958 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 2959 | 2959 | } |
| 2960 | 2960 | |
| 2961 | 2961 | /** |
@@ -2964,17 +2964,17 @@ discard block |
||
| 2964 | 2964 | public function discount_first_payment_only() { |
| 2965 | 2965 | |
| 2966 | 2966 | $discount_code = $this->get_discount_code(); |
| 2967 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
| 2967 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
| 2968 | 2968 | return true; |
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 2971 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 2972 | 2972 | |
| 2973 | - if ( ! $discount || ! $discount->exists() ) { |
|
| 2973 | + if (!$discount || !$discount->exists()) { |
|
| 2974 | 2974 | return true; |
| 2975 | 2975 | } |
| 2976 | 2976 | |
| 2977 | - return ! $discount->get_is_recurring(); |
|
| 2977 | + return !$discount->get_is_recurring(); |
|
| 2978 | 2978 | } |
| 2979 | 2979 | |
| 2980 | 2980 | /* |
@@ -2992,18 +2992,18 @@ discard block |
||
| 2992 | 2992 | * @param GetPaid_Form_Item $item |
| 2993 | 2993 | * @return WP_Error|Bool |
| 2994 | 2994 | */ |
| 2995 | - public function add_item( $item ) { |
|
| 2995 | + public function add_item($item) { |
|
| 2996 | 2996 | |
| 2997 | 2997 | // Make sure that it is available for purchase. |
| 2998 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 2999 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 2998 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 2999 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3000 | 3000 | } |
| 3001 | 3001 | |
| 3002 | 3002 | // Do we have a recurring item? |
| 3003 | - if ( $item->is_recurring() ) { |
|
| 3003 | + if ($item->is_recurring()) { |
|
| 3004 | 3004 | |
| 3005 | 3005 | // An invoice can only contain one recurring item. |
| 3006 | - if ( ! empty( $this->recurring_item ) ) { |
|
| 3006 | + if (!empty($this->recurring_item)) { |
|
| 3007 | 3007 | return false; |
| 3008 | 3008 | } |
| 3009 | 3009 | |
@@ -3015,9 +3015,9 @@ discard block |
||
| 3015 | 3015 | |
| 3016 | 3016 | // Retrieve all items. |
| 3017 | 3017 | $items = $this->get_items(); |
| 3018 | - $items[ $item->get_id() ] = $item; |
|
| 3018 | + $items[$item->get_id()] = $item; |
|
| 3019 | 3019 | |
| 3020 | - $this->set_prop( 'items', $items ); |
|
| 3020 | + $this->set_prop('items', $items); |
|
| 3021 | 3021 | return true; |
| 3022 | 3022 | } |
| 3023 | 3023 | |
@@ -3026,9 +3026,9 @@ discard block |
||
| 3026 | 3026 | * |
| 3027 | 3027 | * @since 1.0.19 |
| 3028 | 3028 | */ |
| 3029 | - public function get_item( $item_id ) { |
|
| 3029 | + public function get_item($item_id) { |
|
| 3030 | 3030 | $items = $this->get_items(); |
| 3031 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3031 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
| 3032 | 3032 | } |
| 3033 | 3033 | |
| 3034 | 3034 | /** |
@@ -3036,16 +3036,16 @@ discard block |
||
| 3036 | 3036 | * |
| 3037 | 3037 | * @since 1.0.19 |
| 3038 | 3038 | */ |
| 3039 | - public function remove_item( $item_id ) { |
|
| 3039 | + public function remove_item($item_id) { |
|
| 3040 | 3040 | $items = $this->get_items(); |
| 3041 | 3041 | |
| 3042 | - if ( $item_id == $this->recurring_item ) { |
|
| 3042 | + if ($item_id == $this->recurring_item) { |
|
| 3043 | 3043 | $this->recurring_item = null; |
| 3044 | 3044 | } |
| 3045 | 3045 | |
| 3046 | - if ( isset( $items[ $item_id ] ) ) { |
|
| 3047 | - unset( $items[ $item_id ] ); |
|
| 3048 | - $this->set_prop( 'items', $items ); |
|
| 3046 | + if (isset($items[$item_id])) { |
|
| 3047 | + unset($items[$item_id]); |
|
| 3048 | + $this->set_prop('items', $items); |
|
| 3049 | 3049 | } |
| 3050 | 3050 | } |
| 3051 | 3051 | |
@@ -3056,27 +3056,27 @@ discard block |
||
| 3056 | 3056 | * @param float $value |
| 3057 | 3057 | * @return WP_Error|Bool |
| 3058 | 3058 | */ |
| 3059 | - public function add_fee( $fee, $value, $recurring = false ) { |
|
| 3059 | + public function add_fee($fee, $value, $recurring = false) { |
|
| 3060 | 3060 | |
| 3061 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3061 | + $amount = wpinv_sanitize_amount($value); |
|
| 3062 | 3062 | $fees = $this->get_fees(); |
| 3063 | 3063 | |
| 3064 | - if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
|
| 3064 | + if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) { |
|
| 3065 | 3065 | |
| 3066 | - $amount = $fees[ $fee ]['amount'] += $amount; |
|
| 3067 | - $fees[ $fee ] = array( |
|
| 3066 | + $amount = $fees[$fee]['amount'] += $amount; |
|
| 3067 | + $fees[$fee] = array( |
|
| 3068 | 3068 | 'amount' => $amount, |
| 3069 | 3069 | 'recurring' => (bool) $recurring, |
| 3070 | 3070 | ); |
| 3071 | 3071 | |
| 3072 | 3072 | } else { |
| 3073 | - $fees[ $fee ] = array( |
|
| 3073 | + $fees[$fee] = array( |
|
| 3074 | 3074 | 'amount' => $amount, |
| 3075 | 3075 | 'recurring' => (bool) $recurring, |
| 3076 | 3076 | ); |
| 3077 | 3077 | } |
| 3078 | 3078 | |
| 3079 | - $this->set_prop( 'fees', $fee ); |
|
| 3079 | + $this->set_prop('fees', $fee); |
|
| 3080 | 3080 | |
| 3081 | 3081 | } |
| 3082 | 3082 | |
@@ -3085,9 +3085,9 @@ discard block |
||
| 3085 | 3085 | * |
| 3086 | 3086 | * @since 1.0.19 |
| 3087 | 3087 | */ |
| 3088 | - public function get_fee( $fee ) { |
|
| 3088 | + public function get_fee($fee) { |
|
| 3089 | 3089 | $fees = $this->get_fees(); |
| 3090 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3090 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3091 | 3091 | } |
| 3092 | 3092 | |
| 3093 | 3093 | /** |
@@ -3095,11 +3095,11 @@ discard block |
||
| 3095 | 3095 | * |
| 3096 | 3096 | * @since 1.0.19 |
| 3097 | 3097 | */ |
| 3098 | - public function remove_fee( $fee ) { |
|
| 3098 | + public function remove_fee($fee) { |
|
| 3099 | 3099 | $fees = $this->get_fees(); |
| 3100 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3101 | - unset( $fees[ $fee ] ); |
|
| 3102 | - $this->set_prop( 'fees', $fees ); |
|
| 3100 | + if (isset($fees[$fee])) { |
|
| 3101 | + unset($fees[$fee]); |
|
| 3102 | + $this->set_prop('fees', $fees); |
|
| 3103 | 3103 | } |
| 3104 | 3104 | } |
| 3105 | 3105 | |
@@ -3110,27 +3110,27 @@ discard block |
||
| 3110 | 3110 | * @param float $value |
| 3111 | 3111 | * @return WP_Error|Bool |
| 3112 | 3112 | */ |
| 3113 | - public function add_discount( $discount, $value, $recurring = false ) { |
|
| 3113 | + public function add_discount($discount, $value, $recurring = false) { |
|
| 3114 | 3114 | |
| 3115 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3115 | + $amount = wpinv_sanitize_amount($value); |
|
| 3116 | 3116 | $discounts = $this->get_discounts(); |
| 3117 | 3117 | |
| 3118 | - if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
|
| 3118 | + if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) { |
|
| 3119 | 3119 | |
| 3120 | - $amount = $discounts[ $discount ]['amount'] += $amount; |
|
| 3121 | - $discounts[ $discount ] = array( |
|
| 3120 | + $amount = $discounts[$discount]['amount'] += $amount; |
|
| 3121 | + $discounts[$discount] = array( |
|
| 3122 | 3122 | 'amount' => $amount, |
| 3123 | 3123 | 'recurring' => (bool) $recurring, |
| 3124 | 3124 | ); |
| 3125 | 3125 | |
| 3126 | 3126 | } else { |
| 3127 | - $discounts[ $discount ] = array( |
|
| 3127 | + $discounts[$discount] = array( |
|
| 3128 | 3128 | 'amount' => $amount, |
| 3129 | 3129 | 'recurring' => (bool) $recurring, |
| 3130 | 3130 | ); |
| 3131 | 3131 | } |
| 3132 | 3132 | |
| 3133 | - $this->set_prop( 'discounts', $discount ); |
|
| 3133 | + $this->set_prop('discounts', $discount); |
|
| 3134 | 3134 | |
| 3135 | 3135 | } |
| 3136 | 3136 | |
@@ -3139,15 +3139,15 @@ discard block |
||
| 3139 | 3139 | * |
| 3140 | 3140 | * @since 1.0.19 |
| 3141 | 3141 | */ |
| 3142 | - public function get_discount( $discount = false ) { |
|
| 3142 | + public function get_discount($discount = false) { |
|
| 3143 | 3143 | |
| 3144 | 3144 | // Backwards compatibilty. |
| 3145 | - if ( empty( $discount ) ) { |
|
| 3145 | + if (empty($discount)) { |
|
| 3146 | 3146 | return $this->get_total_discount(); |
| 3147 | 3147 | } |
| 3148 | 3148 | |
| 3149 | 3149 | $discounts = $this->get_discounts(); |
| 3150 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3150 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3151 | 3151 | } |
| 3152 | 3152 | |
| 3153 | 3153 | /** |
@@ -3155,11 +3155,11 @@ discard block |
||
| 3155 | 3155 | * |
| 3156 | 3156 | * @since 1.0.19 |
| 3157 | 3157 | */ |
| 3158 | - public function remove_discount( $discount ) { |
|
| 3158 | + public function remove_discount($discount) { |
|
| 3159 | 3159 | $discounts = $this->get_discounts(); |
| 3160 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3161 | - unset( $discounts[ $discount ] ); |
|
| 3162 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3160 | + if (isset($discounts[$discount])) { |
|
| 3161 | + unset($discounts[$discount]); |
|
| 3162 | + $this->set_prop('discounts', $discounts); |
|
| 3163 | 3163 | } |
| 3164 | 3164 | } |
| 3165 | 3165 | |
@@ -3169,31 +3169,31 @@ discard block |
||
| 3169 | 3169 | * @param string $tax |
| 3170 | 3170 | * @param float $value |
| 3171 | 3171 | */ |
| 3172 | - public function add_tax( $tax, $value, $recurring = true ) { |
|
| 3172 | + public function add_tax($tax, $value, $recurring = true) { |
|
| 3173 | 3173 | |
| 3174 | - if ( ! $this->is_taxable() ) { |
|
| 3174 | + if (!$this->is_taxable()) { |
|
| 3175 | 3175 | return; |
| 3176 | 3176 | } |
| 3177 | 3177 | |
| 3178 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3178 | + $amount = wpinv_sanitize_amount($value); |
|
| 3179 | 3179 | $taxes = $this->get_taxes(); |
| 3180 | 3180 | |
| 3181 | - if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
|
| 3181 | + if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) { |
|
| 3182 | 3182 | |
| 3183 | - $amount = $taxes[ $tax ]['amount'] += $amount; |
|
| 3184 | - $taxes[ $tax ] = array( |
|
| 3183 | + $amount = $taxes[$tax]['amount'] += $amount; |
|
| 3184 | + $taxes[$tax] = array( |
|
| 3185 | 3185 | 'amount' => $amount, |
| 3186 | 3186 | 'recurring' => (bool) $recurring, |
| 3187 | 3187 | ); |
| 3188 | 3188 | |
| 3189 | 3189 | } else { |
| 3190 | - $taxes[ $tax ] = array( |
|
| 3190 | + $taxes[$tax] = array( |
|
| 3191 | 3191 | 'amount' => $amount, |
| 3192 | 3192 | 'recurring' => (bool) $recurring, |
| 3193 | 3193 | ); |
| 3194 | 3194 | } |
| 3195 | 3195 | |
| 3196 | - $this->set_prop( 'taxes', $tax ); |
|
| 3196 | + $this->set_prop('taxes', $tax); |
|
| 3197 | 3197 | |
| 3198 | 3198 | } |
| 3199 | 3199 | |
@@ -3202,9 +3202,9 @@ discard block |
||
| 3202 | 3202 | * |
| 3203 | 3203 | * @since 1.0.19 |
| 3204 | 3204 | */ |
| 3205 | - public function get_tax( $tax ) { |
|
| 3205 | + public function get_tax($tax) { |
|
| 3206 | 3206 | $taxes = $this->get_taxes(); |
| 3207 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3207 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | /** |
@@ -3212,11 +3212,11 @@ discard block |
||
| 3212 | 3212 | * |
| 3213 | 3213 | * @since 1.0.19 |
| 3214 | 3214 | */ |
| 3215 | - public function remove_tax( $tax ) { |
|
| 3215 | + public function remove_tax($tax) { |
|
| 3216 | 3216 | $taxes = $this->get_discounts(); |
| 3217 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3218 | - unset( $taxes[ $tax ] ); |
|
| 3219 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3217 | + if (isset($taxes[$tax])) { |
|
| 3218 | + unset($taxes[$tax]); |
|
| 3219 | + $this->set_prop('taxes', $taxes); |
|
| 3220 | 3220 | } |
| 3221 | 3221 | } |
| 3222 | 3222 | |
@@ -3227,19 +3227,19 @@ discard block |
||
| 3227 | 3227 | * @return float The recalculated subtotal |
| 3228 | 3228 | */ |
| 3229 | 3229 | public function recalculate_subtotal() { |
| 3230 | - $items = $this->get_items(); |
|
| 3230 | + $items = $this->get_items(); |
|
| 3231 | 3231 | $subtotal = 0; |
| 3232 | 3232 | $recurring = 0; |
| 3233 | 3233 | |
| 3234 | - foreach ( $items as $item ) { |
|
| 3234 | + foreach ($items as $item) { |
|
| 3235 | 3235 | $subtotal += $item->get_sub_total(); |
| 3236 | 3236 | $recurring += $item->get_recurring_sub_total(); |
| 3237 | 3237 | } |
| 3238 | 3238 | |
| 3239 | - if ( $this->is_renewal() ) { |
|
| 3240 | - $this->set_subtotal( $recurring ); |
|
| 3239 | + if ($this->is_renewal()) { |
|
| 3240 | + $this->set_subtotal($recurring); |
|
| 3241 | 3241 | } else { |
| 3242 | - $this->set_subtotal( $subtotal ); |
|
| 3242 | + $this->set_subtotal($subtotal); |
|
| 3243 | 3243 | } |
| 3244 | 3244 | |
| 3245 | 3245 | $this->totals['subtotal'] = array( |
@@ -3261,9 +3261,9 @@ discard block |
||
| 3261 | 3261 | $discount = 0; |
| 3262 | 3262 | $recurring = 0; |
| 3263 | 3263 | |
| 3264 | - foreach ( $discounts as $data ) { |
|
| 3264 | + foreach ($discounts as $data) { |
|
| 3265 | 3265 | |
| 3266 | - if ( $data['recurring'] ) { |
|
| 3266 | + if ($data['recurring']) { |
|
| 3267 | 3267 | $recurring += $data['amount']; |
| 3268 | 3268 | } else { |
| 3269 | 3269 | $discount += $data['amount']; |
@@ -3271,10 +3271,10 @@ discard block |
||
| 3271 | 3271 | |
| 3272 | 3272 | } |
| 3273 | 3273 | |
| 3274 | - if ( $this->is_renewal() ) { |
|
| 3275 | - $this->set_total_discount( $recurring ); |
|
| 3274 | + if ($this->is_renewal()) { |
|
| 3275 | + $this->set_total_discount($recurring); |
|
| 3276 | 3276 | } else { |
| 3277 | - $this->set_total_discount( $discount ); |
|
| 3277 | + $this->set_total_discount($discount); |
|
| 3278 | 3278 | } |
| 3279 | 3279 | |
| 3280 | 3280 | $this->totals['discount'] = array( |
@@ -3293,13 +3293,13 @@ discard block |
||
| 3293 | 3293 | * @return float The recalculated tax |
| 3294 | 3294 | */ |
| 3295 | 3295 | public function recalculate_total_tax() { |
| 3296 | - $taxes = $this->get_taxes(); |
|
| 3296 | + $taxes = $this->get_taxes(); |
|
| 3297 | 3297 | $tax = 0; |
| 3298 | 3298 | $recurring = 0; |
| 3299 | 3299 | |
| 3300 | - foreach ( $taxes as $data ) { |
|
| 3300 | + foreach ($taxes as $data) { |
|
| 3301 | 3301 | |
| 3302 | - if ( $data['recurring'] ) { |
|
| 3302 | + if ($data['recurring']) { |
|
| 3303 | 3303 | $recurring += $data['amount']; |
| 3304 | 3304 | } else { |
| 3305 | 3305 | $tax += $data['amount']; |
@@ -3307,10 +3307,10 @@ discard block |
||
| 3307 | 3307 | |
| 3308 | 3308 | } |
| 3309 | 3309 | |
| 3310 | - if ( $this->is_renewal() ) { |
|
| 3311 | - $this->set_total_tax( $recurring ); |
|
| 3310 | + if ($this->is_renewal()) { |
|
| 3311 | + $this->set_total_tax($recurring); |
|
| 3312 | 3312 | } else { |
| 3313 | - $this->set_total_tax( $tax ); |
|
| 3313 | + $this->set_total_tax($tax); |
|
| 3314 | 3314 | } |
| 3315 | 3315 | |
| 3316 | 3316 | $this->totals['tax'] = array( |
@@ -3333,9 +3333,9 @@ discard block |
||
| 3333 | 3333 | $fee = 0; |
| 3334 | 3334 | $recurring = 0; |
| 3335 | 3335 | |
| 3336 | - foreach ( $fees as $data ) { |
|
| 3336 | + foreach ($fees as $data) { |
|
| 3337 | 3337 | |
| 3338 | - if ( $data['recurring'] ) { |
|
| 3338 | + if ($data['recurring']) { |
|
| 3339 | 3339 | $recurring += $data['amount']; |
| 3340 | 3340 | } else { |
| 3341 | 3341 | $fee += $data['amount']; |
@@ -3343,10 +3343,10 @@ discard block |
||
| 3343 | 3343 | |
| 3344 | 3344 | } |
| 3345 | 3345 | |
| 3346 | - if ( $this->is_renewal() ) { |
|
| 3347 | - $this->set_total_fees( $recurring ); |
|
| 3346 | + if ($this->is_renewal()) { |
|
| 3347 | + $this->set_total_fees($recurring); |
|
| 3348 | 3348 | } else { |
| 3349 | - $this->set_total_fees( $fee ); |
|
| 3349 | + $this->set_total_fees($fee); |
|
| 3350 | 3350 | } |
| 3351 | 3351 | |
| 3352 | 3352 | $this->totals['fee'] = array( |
@@ -3354,7 +3354,7 @@ discard block |
||
| 3354 | 3354 | 'recurring' => $recurring, |
| 3355 | 3355 | ); |
| 3356 | 3356 | |
| 3357 | - $this->set_total_fees( $fee ); |
|
| 3357 | + $this->set_total_fees($fee); |
|
| 3358 | 3358 | return $this->is_renewal() ? $recurring : $fee; |
| 3359 | 3359 | } |
| 3360 | 3360 | |
@@ -3375,9 +3375,9 @@ discard block |
||
| 3375 | 3375 | /** |
| 3376 | 3376 | * @deprecated |
| 3377 | 3377 | */ |
| 3378 | - public function recalculate_totals( $temp = false ) { |
|
| 3379 | - $this->update_items( $temp ); |
|
| 3380 | - $this->save( true ); |
|
| 3378 | + public function recalculate_totals($temp = false) { |
|
| 3379 | + $this->update_items($temp); |
|
| 3380 | + $this->save(true); |
|
| 3381 | 3381 | return $this; |
| 3382 | 3382 | } |
| 3383 | 3383 | |
@@ -3394,33 +3394,33 @@ discard block |
||
| 3394 | 3394 | * @param string $note The note being added. |
| 3395 | 3395 | * |
| 3396 | 3396 | */ |
| 3397 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3397 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3398 | 3398 | |
| 3399 | 3399 | // Bail if no note specified or this invoice is not yet saved. |
| 3400 | - if ( ! $note || $this->get_id() == 0 ) { |
|
| 3400 | + if (!$note || $this->get_id() == 0) { |
|
| 3401 | 3401 | return false; |
| 3402 | 3402 | } |
| 3403 | 3403 | |
| 3404 | - if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) { |
|
| 3405 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3404 | + if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) { |
|
| 3405 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3406 | 3406 | $comment_author = $user->display_name; |
| 3407 | 3407 | $comment_author_email = $user->user_email; |
| 3408 | 3408 | } else { |
| 3409 | 3409 | $comment_author = 'System'; |
| 3410 | 3410 | $comment_author_email = 'system@'; |
| 3411 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
| 3412 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
| 3411 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
| 3412 | + $comment_author_email = sanitize_email($comment_author_email); |
|
| 3413 | 3413 | } |
| 3414 | 3414 | |
| 3415 | - do_action( 'wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type ); |
|
| 3415 | + do_action('wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type); |
|
| 3416 | 3416 | |
| 3417 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 3417 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 3418 | 3418 | 'comment_post_ID' => $this->get_id(), |
| 3419 | 3419 | 'comment_content' => $note, |
| 3420 | 3420 | 'comment_agent' => 'GetPaid', |
| 3421 | 3421 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 3422 | - 'comment_date' => current_time( 'mysql' ), |
|
| 3423 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 3422 | + 'comment_date' => current_time('mysql'), |
|
| 3423 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 3424 | 3424 | 'comment_approved' => 1, |
| 3425 | 3425 | 'comment_parent' => 0, |
| 3426 | 3426 | 'comment_author' => $comment_author, |
@@ -3428,13 +3428,13 @@ discard block |
||
| 3428 | 3428 | 'comment_author_url' => '', |
| 3429 | 3429 | 'comment_author_email' => $comment_author_email, |
| 3430 | 3430 | 'comment_type' => 'wpinv_note' |
| 3431 | - ) ) ); |
|
| 3431 | + ))); |
|
| 3432 | 3432 | |
| 3433 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->get_id(), $note ); |
|
| 3433 | + do_action('wpinv_insert_payment_note', $note_id, $this->get_id(), $note); |
|
| 3434 | 3434 | |
| 3435 | - if ( $customer_type ) { |
|
| 3436 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 3437 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->get_id(), 'user_note' => $note ) ); |
|
| 3435 | + if ($customer_type) { |
|
| 3436 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
| 3437 | + do_action('wpinv_new_customer_note', array('invoice_id' => $this->get_id(), 'user_note' => $note)); |
|
| 3438 | 3438 | } |
| 3439 | 3439 | |
| 3440 | 3440 | return $note_id; |
@@ -3443,10 +3443,10 @@ discard block |
||
| 3443 | 3443 | /** |
| 3444 | 3444 | * Generates a unique key for the invoice. |
| 3445 | 3445 | */ |
| 3446 | - public function generate_key( $string = '' ) { |
|
| 3447 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3446 | + public function generate_key($string = '') { |
|
| 3447 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3448 | 3448 | return strtolower( |
| 3449 | - md5( $this->get_id() . $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3449 | + md5($this->get_id() . $string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3450 | 3450 | ); |
| 3451 | 3451 | } |
| 3452 | 3452 | |
@@ -3456,12 +3456,12 @@ discard block |
||
| 3456 | 3456 | public function generate_number() { |
| 3457 | 3457 | $number = $this->get_id(); |
| 3458 | 3458 | |
| 3459 | - if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) { |
|
| 3460 | - $next_number = wpinv_get_next_invoice_number( $this->post_type ); |
|
| 3459 | + if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) { |
|
| 3460 | + $next_number = wpinv_get_next_invoice_number($this->post_type); |
|
| 3461 | 3461 | $number = $next_number; |
| 3462 | 3462 | } |
| 3463 | 3463 | |
| 3464 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3464 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
| 3465 | 3465 | |
| 3466 | 3466 | return $number; |
| 3467 | 3467 | } |
@@ -3475,47 +3475,47 @@ discard block |
||
| 3475 | 3475 | // Reset status transition variable. |
| 3476 | 3476 | $this->status_transition = false; |
| 3477 | 3477 | |
| 3478 | - if ( $status_transition ) { |
|
| 3478 | + if ($status_transition) { |
|
| 3479 | 3479 | try { |
| 3480 | 3480 | |
| 3481 | 3481 | // Fire a hook for the status change. |
| 3482 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3482 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
| 3483 | 3483 | |
| 3484 | 3484 | // @deprecated this is deprecated and will be removed in the future. |
| 3485 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3485 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3486 | 3486 | |
| 3487 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3487 | + if (!empty($status_transition['from'])) { |
|
| 3488 | 3488 | |
| 3489 | 3489 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3490 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3490 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
| 3491 | 3491 | |
| 3492 | 3492 | // Fire another hook. |
| 3493 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3494 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3493 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
| 3494 | + do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this); |
|
| 3495 | 3495 | |
| 3496 | 3496 | // @deprecated this is deprecated and will be removed in the future. |
| 3497 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3497 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3498 | 3498 | |
| 3499 | 3499 | // Note the transition occurred. |
| 3500 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3500 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3501 | 3501 | |
| 3502 | 3502 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3503 | 3503 | if ( |
| 3504 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed' ), true ) |
|
| 3505 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3504 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed'), true) |
|
| 3505 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3506 | 3506 | ) { |
| 3507 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3507 | + do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition); |
|
| 3508 | 3508 | } |
| 3509 | 3509 | } else { |
| 3510 | 3510 | /* translators: %s: new invoice status */ |
| 3511 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3511 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
| 3512 | 3512 | |
| 3513 | 3513 | // Note the transition occurred. |
| 3514 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3514 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3515 | 3515 | |
| 3516 | 3516 | } |
| 3517 | - } catch ( Exception $e ) { |
|
| 3518 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3517 | + } catch (Exception $e) { |
|
| 3518 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3519 | 3519 | } |
| 3520 | 3520 | } |
| 3521 | 3521 | } |
@@ -3523,13 +3523,13 @@ discard block |
||
| 3523 | 3523 | /** |
| 3524 | 3524 | * Updates an invoice status. |
| 3525 | 3525 | */ |
| 3526 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3526 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3527 | 3527 | |
| 3528 | 3528 | // Fires before updating a status. |
| 3529 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3529 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3530 | 3530 | |
| 3531 | 3531 | // Update the status. |
| 3532 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3532 | + $this->set_status($new_status, $note, $manual); |
|
| 3533 | 3533 | |
| 3534 | 3534 | // Save the order. |
| 3535 | 3535 | return $this->save(); |
@@ -3540,18 +3540,18 @@ discard block |
||
| 3540 | 3540 | * @deprecated |
| 3541 | 3541 | */ |
| 3542 | 3542 | public function refresh_item_ids() { |
| 3543 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
| 3544 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3543 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
| 3544 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3545 | 3545 | } |
| 3546 | 3546 | |
| 3547 | 3547 | /** |
| 3548 | 3548 | * @deprecated |
| 3549 | 3549 | */ |
| 3550 | - public function update_items( $temp = false ) { |
|
| 3550 | + public function update_items($temp = false) { |
|
| 3551 | 3551 | |
| 3552 | - $this->set_items( $this->get_items() ); |
|
| 3552 | + $this->set_items($this->get_items()); |
|
| 3553 | 3553 | |
| 3554 | - if ( ! $temp ) { |
|
| 3554 | + if (!$temp) { |
|
| 3555 | 3555 | $this->save(); |
| 3556 | 3556 | } |
| 3557 | 3557 | |
@@ -3565,11 +3565,11 @@ discard block |
||
| 3565 | 3565 | |
| 3566 | 3566 | $discount_code = $this->get_discount_code(); |
| 3567 | 3567 | |
| 3568 | - if ( empty( $discount_code ) ) { |
|
| 3568 | + if (empty($discount_code)) { |
|
| 3569 | 3569 | return false; |
| 3570 | 3570 | } |
| 3571 | 3571 | |
| 3572 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3572 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3573 | 3573 | |
| 3574 | 3574 | // Ensure it is active. |
| 3575 | 3575 | return $discount->exists(); |
@@ -3580,7 +3580,7 @@ discard block |
||
| 3580 | 3580 | * Refunds an invoice. |
| 3581 | 3581 | */ |
| 3582 | 3582 | public function refund() { |
| 3583 | - $this->set_status( 'wpi-refunded' ); |
|
| 3583 | + $this->set_status('wpi-refunded'); |
|
| 3584 | 3584 | $this->save(); |
| 3585 | 3585 | } |
| 3586 | 3586 | |
@@ -7,8 +7,8 @@ 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 | /** |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function getpaid_get_invoice_post_types() { |
| 18 | 18 | $post_types = array( |
| 19 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
| 20 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
| 19 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
| 20 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
| 23 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Checks if this is an invocing post type. |
| 28 | 28 | */ |
| 29 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
| 30 | - return $post_type && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
| 29 | +function getpaid_is_invoice_post_type($post_type) { |
|
| 30 | + return $post_type && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | function wpinv_get_invoice_cart_id() { |
| 34 | 34 | $wpinv_checkout = wpinv_get_checkout_session(); |
| 35 | 35 | |
| 36 | - if ( !empty( $wpinv_checkout['invoice_id'] ) ) { |
|
| 36 | + if (!empty($wpinv_checkout['invoice_id'])) { |
|
| 37 | 37 | return $wpinv_checkout['invoice_id']; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -47,48 +47,48 @@ discard block |
||
| 47 | 47 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 48 | 48 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 49 | 49 | */ |
| 50 | -function wpinv_insert_invoice( $invoice_data = array(), $wp_error = false ) { |
|
| 51 | - if ( empty( $invoice_data ) ) { |
|
| 50 | +function wpinv_insert_invoice($invoice_data = array(), $wp_error = false) { |
|
| 51 | + if (empty($invoice_data)) { |
|
| 52 | 52 | return false; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( !( !empty( $invoice_data['cart_details'] ) && is_array( $invoice_data['cart_details'] ) ) ) { |
|
| 56 | - return $wp_error ? new WP_Error( 'wpinv_invalid_items', __( 'Invoice must have atleast one item.', 'invoicing' ) ) : 0; |
|
| 55 | + if (!(!empty($invoice_data['cart_details']) && is_array($invoice_data['cart_details']))) { |
|
| 56 | + return $wp_error ? new WP_Error('wpinv_invalid_items', __('Invoice must have atleast one item.', 'invoicing')) : 0; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // If no user id is provided, default to the current user id |
| 60 | - if ( empty( $invoice_data['user_id'] ) ) { |
|
| 60 | + if (empty($invoice_data['user_id'])) { |
|
| 61 | 61 | $invoice_data['user_id'] = get_current_user_id(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $invoice_data['invoice_id'] = !empty( $invoice_data['invoice_id'] ) ? (int)$invoice_data['invoice_id'] : 0; |
|
| 64 | + $invoice_data['invoice_id'] = !empty($invoice_data['invoice_id']) ? (int) $invoice_data['invoice_id'] : 0; |
|
| 65 | 65 | |
| 66 | - if ( empty( $invoice_data['status'] ) ) { |
|
| 66 | + if (empty($invoice_data['status'])) { |
|
| 67 | 67 | $invoice_data['status'] = 'wpi-pending'; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( empty( $invoice_data['post_type'] ) ) { |
|
| 70 | + if (empty($invoice_data['post_type'])) { |
|
| 71 | 71 | $invoice_data['post_type'] = 'wpi_invoice'; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( empty( $invoice_data['ip'] ) ) { |
|
| 74 | + if (empty($invoice_data['ip'])) { |
|
| 75 | 75 | $invoice_data['ip'] = wpinv_get_ip(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // default invoice args, note that status is checked for validity in wpinv_create_invoice() |
| 79 | 79 | $default_args = array( |
| 80 | - 'invoice_id' => (int)$invoice_data['invoice_id'], |
|
| 81 | - 'user_id' => (int)$invoice_data['user_id'], |
|
| 80 | + 'invoice_id' => (int) $invoice_data['invoice_id'], |
|
| 81 | + 'user_id' => (int) $invoice_data['user_id'], |
|
| 82 | 82 | 'status' => $invoice_data['status'], |
| 83 | 83 | 'post_type' => $invoice_data['post_type'], |
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | - $invoice = wpinv_create_invoice( $default_args, $invoice_data, true ); |
|
| 87 | - if ( is_wp_error( $invoice ) ) { |
|
| 86 | + $invoice = wpinv_create_invoice($default_args, $invoice_data, true); |
|
| 87 | + if (is_wp_error($invoice)) { |
|
| 88 | 88 | return $wp_error ? $invoice : 0; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if ( empty( $invoice_data['invoice_id'] ) ) { |
|
| 91 | + if (empty($invoice_data['invoice_id'])) { |
|
| 92 | 92 | //$invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -111,24 +111,24 @@ discard block |
||
| 111 | 111 | 'discount' => array(), |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - if ( $user_id = (int)$invoice->get_user_id() ) { |
|
| 115 | - if ( $user_address = wpinv_get_user_address( $user_id ) ) { |
|
| 116 | - $default_user_info = wp_parse_args( $user_address, $default_user_info ); |
|
| 114 | + if ($user_id = (int) $invoice->get_user_id()) { |
|
| 115 | + if ($user_address = wpinv_get_user_address($user_id)) { |
|
| 116 | + $default_user_info = wp_parse_args($user_address, $default_user_info); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( empty( $invoice_data['user_info'] ) ) { |
|
| 120 | + if (empty($invoice_data['user_info'])) { |
|
| 121 | 121 | $invoice_data['user_info'] = array(); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $user_info = wp_parse_args( $invoice_data['user_info'], $default_user_info ); |
|
| 124 | + $user_info = wp_parse_args($invoice_data['user_info'], $default_user_info); |
|
| 125 | 125 | |
| 126 | - if ( empty( $user_info['first_name'] ) ) { |
|
| 126 | + if (empty($user_info['first_name'])) { |
|
| 127 | 127 | $user_info['first_name'] = $default_user_info['first_name']; |
| 128 | 128 | $user_info['last_name'] = $default_user_info['last_name']; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( empty( $user_info['country'] ) ) { |
|
| 131 | + if (empty($user_info['country'])) { |
|
| 132 | 132 | $user_info['country'] = $default_user_info['country']; |
| 133 | 133 | $user_info['state'] = $default_user_info['state']; |
| 134 | 134 | $user_info['city'] = $default_user_info['city']; |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | $user_info['phone'] = $default_user_info['phone']; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( !empty( $user_info['discount'] ) && !is_array( $user_info['discount'] ) ) { |
|
| 141 | - $user_info['discount'] = (array)$user_info['discount']; |
|
| 140 | + if (!empty($user_info['discount']) && !is_array($user_info['discount'])) { |
|
| 141 | + $user_info['discount'] = (array) $user_info['discount']; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Payment details |
| 145 | 145 | $payment_details = array(); |
| 146 | - if ( !empty( $invoice_data['payment_details'] ) ) { |
|
| 146 | + if (!empty($invoice_data['payment_details'])) { |
|
| 147 | 147 | $default_payment_details = array( |
| 148 | 148 | 'gateway' => 'manual', |
| 149 | 149 | 'gateway_title' => '', |
@@ -151,56 +151,56 @@ discard block |
||
| 151 | 151 | 'transaction_id' => '', |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - $payment_details = wp_parse_args( $invoice_data['payment_details'], $default_payment_details ); |
|
| 154 | + $payment_details = wp_parse_args($invoice_data['payment_details'], $default_payment_details); |
|
| 155 | 155 | |
| 156 | - if ( empty( $payment_details['gateway'] ) ) { |
|
| 156 | + if (empty($payment_details['gateway'])) { |
|
| 157 | 157 | $payment_details['gateway'] = 'manual'; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if ( empty( $payment_details['currency'] ) ) { |
|
| 160 | + if (empty($payment_details['currency'])) { |
|
| 161 | 161 | $payment_details['currency'] = wpinv_get_default_country(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if ( empty( $payment_details['gateway_title'] ) ) { |
|
| 165 | - $payment_details['gateway_title'] = wpinv_get_gateway_checkout_label( $payment_details['gateway'] ); |
|
| 164 | + if (empty($payment_details['gateway_title'])) { |
|
| 165 | + $payment_details['gateway_title'] = wpinv_get_gateway_checkout_label($payment_details['gateway']); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $invoice->set( 'status', ( !empty( $invoice_data['status'] ) ? $invoice_data['status'] : 'wpi-pending' ) ); |
|
| 170 | - |
|
| 171 | - if ( !empty( $payment_details ) ) { |
|
| 172 | - $invoice->set( 'currency', $payment_details['currency'] ); |
|
| 173 | - $invoice->set( 'gateway', $payment_details['gateway'] ); |
|
| 174 | - $invoice->set( 'gateway_title', $payment_details['gateway_title'] ); |
|
| 175 | - $invoice->set( 'transaction_id', $payment_details['transaction_id'] ); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - $invoice->set( 'user_info', $user_info ); |
|
| 179 | - $invoice->set( 'first_name', $user_info['first_name'] ); |
|
| 180 | - $invoice->set( 'last_name', $user_info['last_name'] ); |
|
| 181 | - $invoice->set( 'address', $user_info['address'] ); |
|
| 182 | - $invoice->set( 'company', $user_info['company'] ); |
|
| 183 | - $invoice->set( 'vat_number', $user_info['vat_number'] ); |
|
| 184 | - $invoice->set( 'phone', $user_info['phone'] ); |
|
| 185 | - $invoice->set( 'city', $user_info['city'] ); |
|
| 186 | - $invoice->set( 'country', $user_info['country'] ); |
|
| 187 | - $invoice->set( 'state', $user_info['state'] ); |
|
| 188 | - $invoice->set( 'zip', $user_info['zip'] ); |
|
| 189 | - $invoice->set( 'discounts', $user_info['discount'] ); |
|
| 190 | - $invoice->set( 'ip', ( !empty( $invoice_data['ip'] ) ? $invoice_data['ip'] : wpinv_get_ip() ) ); |
|
| 191 | - $invoice->set( 'mode', ( wpinv_is_test_mode() ? 'test' : 'live' ) ); |
|
| 192 | - $invoice->set( 'parent_invoice', ( !empty( $invoice_data['parent'] ) ? absint( $invoice_data['parent'] ) : '' ) ); |
|
| 193 | - |
|
| 194 | - if ( !empty( $invoice_data['cart_details'] ) && is_array( $invoice_data['cart_details'] ) ) { |
|
| 195 | - foreach ( $invoice_data['cart_details'] as $key => $item ) { |
|
| 196 | - $item_id = !empty( $item['id'] ) ? $item['id'] : 0; |
|
| 197 | - $quantity = !empty( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 198 | - $name = !empty( $item['name'] ) ? $item['name'] : ''; |
|
| 199 | - $item_price = isset( $item['item_price'] ) ? $item['item_price'] : ''; |
|
| 169 | + $invoice->set('status', (!empty($invoice_data['status']) ? $invoice_data['status'] : 'wpi-pending')); |
|
| 170 | + |
|
| 171 | + if (!empty($payment_details)) { |
|
| 172 | + $invoice->set('currency', $payment_details['currency']); |
|
| 173 | + $invoice->set('gateway', $payment_details['gateway']); |
|
| 174 | + $invoice->set('gateway_title', $payment_details['gateway_title']); |
|
| 175 | + $invoice->set('transaction_id', $payment_details['transaction_id']); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + $invoice->set('user_info', $user_info); |
|
| 179 | + $invoice->set('first_name', $user_info['first_name']); |
|
| 180 | + $invoice->set('last_name', $user_info['last_name']); |
|
| 181 | + $invoice->set('address', $user_info['address']); |
|
| 182 | + $invoice->set('company', $user_info['company']); |
|
| 183 | + $invoice->set('vat_number', $user_info['vat_number']); |
|
| 184 | + $invoice->set('phone', $user_info['phone']); |
|
| 185 | + $invoice->set('city', $user_info['city']); |
|
| 186 | + $invoice->set('country', $user_info['country']); |
|
| 187 | + $invoice->set('state', $user_info['state']); |
|
| 188 | + $invoice->set('zip', $user_info['zip']); |
|
| 189 | + $invoice->set('discounts', $user_info['discount']); |
|
| 190 | + $invoice->set('ip', (!empty($invoice_data['ip']) ? $invoice_data['ip'] : wpinv_get_ip())); |
|
| 191 | + $invoice->set('mode', (wpinv_is_test_mode() ? 'test' : 'live')); |
|
| 192 | + $invoice->set('parent_invoice', (!empty($invoice_data['parent']) ? absint($invoice_data['parent']) : '')); |
|
| 193 | + |
|
| 194 | + if (!empty($invoice_data['cart_details']) && is_array($invoice_data['cart_details'])) { |
|
| 195 | + foreach ($invoice_data['cart_details'] as $key => $item) { |
|
| 196 | + $item_id = !empty($item['id']) ? $item['id'] : 0; |
|
| 197 | + $quantity = !empty($item['quantity']) ? $item['quantity'] : 1; |
|
| 198 | + $name = !empty($item['name']) ? $item['name'] : ''; |
|
| 199 | + $item_price = isset($item['item_price']) ? $item['item_price'] : ''; |
|
| 200 | 200 | |
| 201 | - $post_item = new WPInv_Item( $item_id ); |
|
| 202 | - if ( !empty( $post_item ) ) { |
|
| 203 | - $name = !empty( $name ) ? $name : $post_item->get_name(); |
|
| 201 | + $post_item = new WPInv_Item($item_id); |
|
| 202 | + if (!empty($post_item)) { |
|
| 203 | + $name = !empty($name) ? $name : $post_item->get_name(); |
|
| 204 | 204 | $item_price = $item_price !== '' ? $item_price : $post_item->get_price(); |
| 205 | 205 | } else { |
| 206 | 206 | continue; |
@@ -210,266 +210,266 @@ discard block |
||
| 210 | 210 | 'name' => $name, |
| 211 | 211 | 'quantity' => $quantity, |
| 212 | 212 | 'item_price' => $item_price, |
| 213 | - 'custom_price' => isset( $item['custom_price'] ) ? $item['custom_price'] : '', |
|
| 214 | - 'tax' => !empty( $item['tax'] ) ? $item['tax'] : 0.00, |
|
| 215 | - 'discount' => isset( $item['discount'] ) ? $item['discount'] : 0, |
|
| 216 | - 'meta' => isset( $item['meta'] ) ? $item['meta'] : array(), |
|
| 217 | - 'fees' => isset( $item['fees'] ) ? $item['fees'] : array(), |
|
| 213 | + 'custom_price' => isset($item['custom_price']) ? $item['custom_price'] : '', |
|
| 214 | + 'tax' => !empty($item['tax']) ? $item['tax'] : 0.00, |
|
| 215 | + 'discount' => isset($item['discount']) ? $item['discount'] : 0, |
|
| 216 | + 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
|
| 217 | + 'fees' => isset($item['fees']) ? $item['fees'] : array(), |
|
| 218 | 218 | ); |
| 219 | 219 | |
| 220 | - $invoice->add_item( $item_id, $args ); |
|
| 220 | + $invoice->add_item($item_id, $args); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $invoice->increase_tax( wpinv_get_cart_fee_tax() ); |
|
| 224 | + $invoice->increase_tax(wpinv_get_cart_fee_tax()); |
|
| 225 | 225 | |
| 226 | - if ( isset( $invoice_data['post_date'] ) ) { |
|
| 227 | - $invoice->set( 'date', $invoice_data['post_date'] ); |
|
| 226 | + if (isset($invoice_data['post_date'])) { |
|
| 227 | + $invoice->set('date', $invoice_data['post_date']); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Invoice due date |
| 231 | - if ( isset( $invoice_data['due_date'] ) ) { |
|
| 232 | - $invoice->set( 'due_date', $invoice_data['due_date'] ); |
|
| 231 | + if (isset($invoice_data['due_date'])) { |
|
| 232 | + $invoice->set('due_date', $invoice_data['due_date']); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $invoice->save(); |
| 236 | 236 | |
| 237 | 237 | // Add notes |
| 238 | - if ( !empty( $invoice_data['private_note'] ) ) { |
|
| 239 | - $invoice->add_note( $invoice_data['private_note'] ); |
|
| 238 | + if (!empty($invoice_data['private_note'])) { |
|
| 239 | + $invoice->add_note($invoice_data['private_note']); |
|
| 240 | 240 | } |
| 241 | - if ( !empty( $invoice_data['user_note'] ) ) { |
|
| 242 | - $invoice->add_note( $invoice_data['user_note'], true ); |
|
| 241 | + if (!empty($invoice_data['user_note'])) { |
|
| 242 | + $invoice->add_note($invoice_data['user_note'], true); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( $invoice->is_quote() ) { |
|
| 245 | + if ($invoice->is_quote()) { |
|
| 246 | 246 | |
| 247 | - if ( isset( $invoice_data['valid_until'] ) ) { |
|
| 248 | - update_post_meta( $invoice->ID, 'wpinv_quote_valid_until', $invoice_data['valid_until'] ); |
|
| 247 | + if (isset($invoice_data['valid_until'])) { |
|
| 248 | + update_post_meta($invoice->ID, 'wpinv_quote_valid_until', $invoice_data['valid_until']); |
|
| 249 | 249 | } |
| 250 | 250 | return $invoice; |
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - do_action( 'wpinv_insert_invoice', $invoice->ID, $invoice_data ); |
|
| 254 | + do_action('wpinv_insert_invoice', $invoice->ID, $invoice_data); |
|
| 255 | 255 | |
| 256 | - if ( ! empty( $invoice->ID ) ) { |
|
| 256 | + if (!empty($invoice->ID)) { |
|
| 257 | 257 | global $wpi_userID, $wpinv_ip_address_country; |
| 258 | 258 | |
| 259 | - if ( isset( $invoice_data['created_via'] ) ) { |
|
| 260 | - update_post_meta( $invoice->ID, 'wpinv_created_via', $invoice_data['created_via'] ); |
|
| 259 | + if (isset($invoice_data['created_via'])) { |
|
| 260 | + update_post_meta($invoice->ID, 'wpinv_created_via', $invoice_data['created_via']); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $checkout_session = wpinv_get_checkout_session(); |
| 264 | 264 | |
| 265 | 265 | $data_session = array(); |
| 266 | 266 | $data_session['invoice_id'] = $invoice->ID; |
| 267 | - $data_session['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 267 | + $data_session['cart_discounts'] = $invoice->get_discounts(true); |
|
| 268 | 268 | |
| 269 | - wpinv_set_checkout_session( $data_session ); |
|
| 269 | + wpinv_set_checkout_session($data_session); |
|
| 270 | 270 | |
| 271 | - $wpi_userID = (int)$invoice->get_user_id(); |
|
| 271 | + $wpi_userID = (int) $invoice->get_user_id(); |
|
| 272 | 272 | |
| 273 | - $_POST['country'] = !empty( $invoice->country ) ? $invoice->country : wpinv_get_default_country(); |
|
| 273 | + $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
|
| 274 | 274 | $_POST['state'] = $invoice->state; |
| 275 | 275 | |
| 276 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 277 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 276 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 277 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 278 | 278 | |
| 279 | 279 | $wpinv_ip_address_country = $invoice->country; |
| 280 | 280 | |
| 281 | - $invoice = $invoice->recalculate_totals( true ); |
|
| 281 | + $invoice = $invoice->recalculate_totals(true); |
|
| 282 | 282 | |
| 283 | - wpinv_set_checkout_session( $checkout_session ); |
|
| 283 | + wpinv_set_checkout_session($checkout_session); |
|
| 284 | 284 | |
| 285 | 285 | return $invoice; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( $wp_error ) { |
|
| 289 | - if ( is_wp_error( $invoice ) ) { |
|
| 288 | + if ($wp_error) { |
|
| 289 | + if (is_wp_error($invoice)) { |
|
| 290 | 290 | return $invoice; |
| 291 | 291 | } else { |
| 292 | - return new WP_Error( 'wpinv_insert_invoice_error', __( 'Error in insert invoice.', 'invoicing' ) ); |
|
| 292 | + return new WP_Error('wpinv_insert_invoice_error', __('Error in insert invoice.', 'invoicing')); |
|
| 293 | 293 | } |
| 294 | 294 | } else { |
| 295 | 295 | return 0; |
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | -function wpinv_update_invoice( $invoice_data = array(), $wp_error = false ) { |
|
| 300 | - $invoice_ID = !empty( $invoice_data['ID'] ) ? absint( $invoice_data['ID'] ) : NULL; |
|
| 299 | +function wpinv_update_invoice($invoice_data = array(), $wp_error = false) { |
|
| 300 | + $invoice_ID = !empty($invoice_data['ID']) ? absint($invoice_data['ID']) : NULL; |
|
| 301 | 301 | |
| 302 | - if ( !$invoice_ID ) { |
|
| 303 | - if ( $wp_error ) { |
|
| 304 | - return new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ); |
|
| 302 | + if (!$invoice_ID) { |
|
| 303 | + if ($wp_error) { |
|
| 304 | + return new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')); |
|
| 305 | 305 | } |
| 306 | 306 | return 0; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $invoice = wpinv_get_invoice( $invoice_ID ); |
|
| 309 | + $invoice = wpinv_get_invoice($invoice_ID); |
|
| 310 | 310 | |
| 311 | - $recurring_item = $invoice->is_recurring() ? $invoice->get_recurring( true ) : NULL; |
|
| 311 | + $recurring_item = $invoice->is_recurring() ? $invoice->get_recurring(true) : NULL; |
|
| 312 | 312 | |
| 313 | - if ( empty( $invoice->ID ) ) { |
|
| 314 | - if ( $wp_error ) { |
|
| 315 | - return new WP_Error( 'invalid_invoice', __( 'Invalid invoice.', 'invoicing' ) ); |
|
| 313 | + if (empty($invoice->ID)) { |
|
| 314 | + if ($wp_error) { |
|
| 315 | + return new WP_Error('invalid_invoice', __('Invalid invoice.', 'invoicing')); |
|
| 316 | 316 | } |
| 317 | 317 | return 0; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( ! $invoice->has_status( array( 'wpi-pending' ) ) && ! $invoice->is_quote() ) { |
|
| 321 | - if ( $wp_error ) { |
|
| 322 | - return new WP_Error( 'invalid_invoice_status', __( 'Only invoice with pending payment is allowed to update.', 'invoicing' ) ); |
|
| 320 | + if (!$invoice->has_status(array('wpi-pending')) && !$invoice->is_quote()) { |
|
| 321 | + if ($wp_error) { |
|
| 322 | + return new WP_Error('invalid_invoice_status', __('Only invoice with pending payment is allowed to update.', 'invoicing')); |
|
| 323 | 323 | } |
| 324 | 324 | return 0; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // Invoice status |
| 328 | - if ( !empty( $invoice_data['status'] ) ) { |
|
| 329 | - $invoice->set( 'status', $invoice_data['status'] ); |
|
| 328 | + if (!empty($invoice_data['status'])) { |
|
| 329 | + $invoice->set('status', $invoice_data['status']); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Invoice date |
| 333 | - if ( !empty( $invoice_data['post_date'] ) ) { |
|
| 334 | - $invoice->set( 'date', $invoice_data['post_date'] ); |
|
| 333 | + if (!empty($invoice_data['post_date'])) { |
|
| 334 | + $invoice->set('date', $invoice_data['post_date']); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // Invoice due date |
| 338 | - if ( isset( $invoice_data['due_date'] ) ) { |
|
| 339 | - $invoice->set( 'due_date', $invoice_data['due_date'] ); |
|
| 338 | + if (isset($invoice_data['due_date'])) { |
|
| 339 | + $invoice->set('due_date', $invoice_data['due_date']); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | // Invoice IP address |
| 343 | - if ( !empty( $invoice_data['ip'] ) ) { |
|
| 344 | - $invoice->set( 'ip', $invoice_data['ip'] ); |
|
| 343 | + if (!empty($invoice_data['ip'])) { |
|
| 344 | + $invoice->set('ip', $invoice_data['ip']); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // User info |
| 348 | - if ( !empty( $invoice_data['user_info'] ) && is_array( $invoice_data['user_info'] ) ) { |
|
| 349 | - $user_info = wp_parse_args( $invoice_data['user_info'], $invoice->user_info ); |
|
| 348 | + if (!empty($invoice_data['user_info']) && is_array($invoice_data['user_info'])) { |
|
| 349 | + $user_info = wp_parse_args($invoice_data['user_info'], $invoice->user_info); |
|
| 350 | 350 | |
| 351 | - if ( $discounts = $invoice->get_discounts() ) { |
|
| 351 | + if ($discounts = $invoice->get_discounts()) { |
|
| 352 | 352 | $set_discount = $discounts; |
| 353 | 353 | } else { |
| 354 | 354 | $set_discount = ''; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // Manage discount |
| 358 | - if ( !empty( $invoice_data['user_info']['discount'] ) ) { |
|
| 358 | + if (!empty($invoice_data['user_info']['discount'])) { |
|
| 359 | 359 | // Remove discount |
| 360 | - if ( $invoice_data['user_info']['discount'] == 'none' ) { |
|
| 360 | + if ($invoice_data['user_info']['discount'] == 'none') { |
|
| 361 | 361 | $set_discount = ''; |
| 362 | 362 | } else { |
| 363 | 363 | $set_discount = $invoice_data['user_info']['discount']; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - $invoice->set( 'discounts', $set_discount ); |
|
| 366 | + $invoice->set('discounts', $set_discount); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | $user_info['discount'] = $set_discount; |
| 370 | 370 | |
| 371 | - $invoice->set( 'user_info', $user_info ); |
|
| 371 | + $invoice->set('user_info', $user_info); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( !empty( $invoice_data['cart_details'] ) && is_array( $invoice_data['cart_details'] ) && $cart_details = $invoice_data['cart_details'] ) { |
|
| 375 | - $remove_items = !empty( $cart_details['remove_items'] ) && is_array( $cart_details['remove_items'] ) ? $cart_details['remove_items'] : array(); |
|
| 374 | + if (!empty($invoice_data['cart_details']) && is_array($invoice_data['cart_details']) && $cart_details = $invoice_data['cart_details']) { |
|
| 375 | + $remove_items = !empty($cart_details['remove_items']) && is_array($cart_details['remove_items']) ? $cart_details['remove_items'] : array(); |
|
| 376 | 376 | |
| 377 | - if ( !empty( $remove_items[0]['id'] ) ) { |
|
| 378 | - foreach ( $remove_items as $item ) { |
|
| 379 | - $item_id = !empty( $item['id'] ) ? $item['id'] : 0; |
|
| 380 | - $quantity = !empty( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 381 | - if ( empty( $item_id ) ) { |
|
| 377 | + if (!empty($remove_items[0]['id'])) { |
|
| 378 | + foreach ($remove_items as $item) { |
|
| 379 | + $item_id = !empty($item['id']) ? $item['id'] : 0; |
|
| 380 | + $quantity = !empty($item['quantity']) ? $item['quantity'] : 1; |
|
| 381 | + if (empty($item_id)) { |
|
| 382 | 382 | continue; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - foreach ( $invoice->cart_details as $cart_index => $cart_item ) { |
|
| 386 | - if ( $item_id == $cart_item['id'] ) { |
|
| 385 | + foreach ($invoice->cart_details as $cart_index => $cart_item) { |
|
| 386 | + if ($item_id == $cart_item['id']) { |
|
| 387 | 387 | $args = array( |
| 388 | 388 | 'id' => $item_id, |
| 389 | 389 | 'quantity' => $quantity, |
| 390 | 390 | 'cart_index' => $cart_index |
| 391 | 391 | ); |
| 392 | 392 | |
| 393 | - $invoice->remove_item( $item_id, $args ); |
|
| 393 | + $invoice->remove_item($item_id, $args); |
|
| 394 | 394 | break; |
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - $add_items = !empty( $cart_details['add_items'] ) && is_array( $cart_details['add_items'] ) ? $cart_details['add_items'] : array(); |
|
| 400 | + $add_items = !empty($cart_details['add_items']) && is_array($cart_details['add_items']) ? $cart_details['add_items'] : array(); |
|
| 401 | 401 | |
| 402 | - if ( !empty( $add_items[0]['id'] ) ) { |
|
| 403 | - foreach ( $add_items as $item ) { |
|
| 404 | - $item_id = !empty( $item['id'] ) ? $item['id'] : 0; |
|
| 405 | - $post_item = new WPInv_Item( $item_id ); |
|
| 406 | - if ( empty( $post_item ) ) { |
|
| 402 | + if (!empty($add_items[0]['id'])) { |
|
| 403 | + foreach ($add_items as $item) { |
|
| 404 | + $item_id = !empty($item['id']) ? $item['id'] : 0; |
|
| 405 | + $post_item = new WPInv_Item($item_id); |
|
| 406 | + if (empty($post_item)) { |
|
| 407 | 407 | continue; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | $valid_item = true; |
| 411 | - if ( !empty( $recurring_item ) ) { |
|
| 412 | - if ( $recurring_item->ID != $item_id ) { |
|
| 411 | + if (!empty($recurring_item)) { |
|
| 412 | + if ($recurring_item->ID != $item_id) { |
|
| 413 | 413 | $valid_item = false; |
| 414 | 414 | } |
| 415 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
| 415 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
| 416 | 416 | $valid_item = false; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( !$valid_item ) { |
|
| 420 | - if ( $wp_error ) { |
|
| 421 | - return new WP_Error( 'invalid_invoice_item', __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ) ); |
|
| 419 | + if (!$valid_item) { |
|
| 420 | + if ($wp_error) { |
|
| 421 | + return new WP_Error('invalid_invoice_item', __('You can not add item because recurring item must be paid individually!', 'invoicing')); |
|
| 422 | 422 | } |
| 423 | 423 | return 0; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - $quantity = !empty( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 427 | - $name = !empty( $item['name'] ) ? $item['name'] : $post_item->get_name(); |
|
| 428 | - $item_price = isset( $item['item_price'] ) ? $item['item_price'] : $post_item->get_price(); |
|
| 426 | + $quantity = !empty($item['quantity']) ? $item['quantity'] : 1; |
|
| 427 | + $name = !empty($item['name']) ? $item['name'] : $post_item->get_name(); |
|
| 428 | + $item_price = isset($item['item_price']) ? $item['item_price'] : $post_item->get_price(); |
|
| 429 | 429 | |
| 430 | 430 | $args = array( |
| 431 | 431 | 'name' => $name, |
| 432 | 432 | 'quantity' => $quantity, |
| 433 | 433 | 'item_price' => $item_price, |
| 434 | - 'custom_price' => isset( $item['custom_price'] ) ? $item['custom_price'] : '', |
|
| 435 | - 'tax' => !empty( $item['tax'] ) ? $item['tax'] : 0, |
|
| 436 | - 'discount' => isset( $item['discount'] ) ? $item['discount'] : 0, |
|
| 437 | - 'meta' => isset( $item['meta'] ) ? $item['meta'] : array(), |
|
| 438 | - 'fees' => isset( $item['fees'] ) ? $item['fees'] : array(), |
|
| 434 | + 'custom_price' => isset($item['custom_price']) ? $item['custom_price'] : '', |
|
| 435 | + 'tax' => !empty($item['tax']) ? $item['tax'] : 0, |
|
| 436 | + 'discount' => isset($item['discount']) ? $item['discount'] : 0, |
|
| 437 | + 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
|
| 438 | + 'fees' => isset($item['fees']) ? $item['fees'] : array(), |
|
| 439 | 439 | ); |
| 440 | 440 | |
| 441 | - $invoice->add_item( $item_id, $args ); |
|
| 441 | + $invoice->add_item($item_id, $args); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | // Payment details |
| 447 | - if ( !empty( $invoice_data['payment_details'] ) && $payment_details = $invoice_data['payment_details'] ) { |
|
| 448 | - if ( !empty( $payment_details['gateway'] ) ) { |
|
| 449 | - $invoice->set( 'gateway', $payment_details['gateway'] ); |
|
| 447 | + if (!empty($invoice_data['payment_details']) && $payment_details = $invoice_data['payment_details']) { |
|
| 448 | + if (!empty($payment_details['gateway'])) { |
|
| 449 | + $invoice->set('gateway', $payment_details['gateway']); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if ( !empty( $payment_details['transaction_id'] ) ) { |
|
| 453 | - $invoice->set( 'transaction_id', $payment_details['transaction_id'] ); |
|
| 452 | + if (!empty($payment_details['transaction_id'])) { |
|
| 453 | + $invoice->set('transaction_id', $payment_details['transaction_id']); |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - do_action( 'wpinv_pre_update_invoice', $invoice->ID, $invoice_data ); |
|
| 457 | + do_action('wpinv_pre_update_invoice', $invoice->ID, $invoice_data); |
|
| 458 | 458 | |
| 459 | 459 | // Parent invoice |
| 460 | - if ( !empty( $invoice_data['parent'] ) ) { |
|
| 461 | - $invoice->set( 'parent_invoice', $invoice_data['parent'] ); |
|
| 460 | + if (!empty($invoice_data['parent'])) { |
|
| 461 | + $invoice->set('parent_invoice', $invoice_data['parent']); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Save invoice data. |
| 465 | 465 | $invoice->save(); |
| 466 | 466 | |
| 467 | - if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) { |
|
| 468 | - if ( $wp_error ) { |
|
| 469 | - if ( is_wp_error( $invoice ) ) { |
|
| 467 | + if (empty($invoice->ID) || is_wp_error($invoice)) { |
|
| 468 | + if ($wp_error) { |
|
| 469 | + if (is_wp_error($invoice)) { |
|
| 470 | 470 | return $invoice; |
| 471 | 471 | } else { |
| 472 | - return new WP_Error( 'wpinv_update_invoice_error', __( 'Error in update invoice.', 'invoicing' ) ); |
|
| 472 | + return new WP_Error('wpinv_update_invoice_error', __('Error in update invoice.', 'invoicing')); |
|
| 473 | 473 | } |
| 474 | 474 | } else { |
| 475 | 475 | return 0; |
@@ -477,19 +477,19 @@ discard block |
||
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | // Add private note |
| 480 | - if ( !empty( $invoice_data['private_note'] ) ) { |
|
| 481 | - $invoice->add_note( $invoice_data['private_note'] ); |
|
| 480 | + if (!empty($invoice_data['private_note'])) { |
|
| 481 | + $invoice->add_note($invoice_data['private_note']); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | // Add user note |
| 485 | - if ( !empty( $invoice_data['user_note'] ) ) { |
|
| 486 | - $invoice->add_note( $invoice_data['user_note'], true ); |
|
| 485 | + if (!empty($invoice_data['user_note'])) { |
|
| 486 | + $invoice->add_note($invoice_data['user_note'], true); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if ( $invoice->is_quote() ) { |
|
| 489 | + if ($invoice->is_quote()) { |
|
| 490 | 490 | |
| 491 | - if ( isset( $invoice_data['valid_until'] ) ) { |
|
| 492 | - update_post_meta( $invoice->ID, 'wpinv_quote_valid_until', $invoice_data['valid_until'] ); |
|
| 491 | + if (isset($invoice_data['valid_until'])) { |
|
| 492 | + update_post_meta($invoice->ID, 'wpinv_quote_valid_until', $invoice_data['valid_until']); |
|
| 493 | 493 | } |
| 494 | 494 | return $invoice; |
| 495 | 495 | |
@@ -501,466 +501,466 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | $data_session = array(); |
| 503 | 503 | $data_session['invoice_id'] = $invoice->ID; |
| 504 | - $data_session['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 504 | + $data_session['cart_discounts'] = $invoice->get_discounts(true); |
|
| 505 | 505 | |
| 506 | - wpinv_set_checkout_session( $data_session ); |
|
| 506 | + wpinv_set_checkout_session($data_session); |
|
| 507 | 507 | |
| 508 | - $wpi_userID = (int)$invoice->get_user_id(); |
|
| 508 | + $wpi_userID = (int) $invoice->get_user_id(); |
|
| 509 | 509 | |
| 510 | - $_POST['country'] = !empty( $invoice->country ) ? $invoice->country : wpinv_get_default_country(); |
|
| 510 | + $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
|
| 511 | 511 | $_POST['state'] = $invoice->state; |
| 512 | 512 | |
| 513 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 514 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 513 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 514 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 515 | 515 | |
| 516 | 516 | $wpinv_ip_address_country = $invoice->country; |
| 517 | 517 | |
| 518 | - $invoice = $invoice->recalculate_totals( true ); |
|
| 518 | + $invoice = $invoice->recalculate_totals(true); |
|
| 519 | 519 | |
| 520 | - do_action( 'wpinv_post_update_invoice', $invoice->ID, $invoice_data ); |
|
| 520 | + do_action('wpinv_post_update_invoice', $invoice->ID, $invoice_data); |
|
| 521 | 521 | |
| 522 | - wpinv_set_checkout_session( $checkout_session ); |
|
| 522 | + wpinv_set_checkout_session($checkout_session); |
|
| 523 | 523 | |
| 524 | 524 | return $invoice; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | -function wpinv_get_invoice( $invoice_id = 0, $cart = false ) { |
|
| 528 | - if ( $cart && empty( $invoice_id ) ) { |
|
| 529 | - $invoice_id = (int)wpinv_get_invoice_cart_id(); |
|
| 527 | +function wpinv_get_invoice($invoice_id = 0, $cart = false) { |
|
| 528 | + if ($cart && empty($invoice_id)) { |
|
| 529 | + $invoice_id = (int) wpinv_get_invoice_cart_id(); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 532 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 533 | 533 | |
| 534 | - if ( $invoice->get_id() != 0 ) { |
|
| 534 | + if ($invoice->get_id() != 0) { |
|
| 535 | 535 | return $invoice; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | return NULL; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | -function wpinv_get_invoice_cart( $invoice_id = 0 ) { |
|
| 542 | - return wpinv_get_invoice( $invoice_id, true ); |
|
| 541 | +function wpinv_get_invoice_cart($invoice_id = 0) { |
|
| 542 | + return wpinv_get_invoice($invoice_id, true); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | -function wpinv_get_invoice_description( $invoice_id = 0 ) { |
|
| 546 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 545 | +function wpinv_get_invoice_description($invoice_id = 0) { |
|
| 546 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 547 | 547 | return $invoice->get_description(); |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | -function wpinv_get_invoice_currency_code( $invoice_id = 0 ) { |
|
| 551 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 550 | +function wpinv_get_invoice_currency_code($invoice_id = 0) { |
|
| 551 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 552 | 552 | return $invoice->get_currency(); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | -function wpinv_get_payment_user_email( $invoice_id ) { |
|
| 556 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 555 | +function wpinv_get_payment_user_email($invoice_id) { |
|
| 556 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 557 | 557 | return $invoice->get_email(); |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | -function wpinv_get_user_id( $invoice_id ) { |
|
| 561 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 560 | +function wpinv_get_user_id($invoice_id) { |
|
| 561 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 562 | 562 | return $invoice->get_user_id(); |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | -function wpinv_get_invoice_status( $invoice_id, $return_label = false ) { |
|
| 566 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 565 | +function wpinv_get_invoice_status($invoice_id, $return_label = false) { |
|
| 566 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 567 | 567 | |
| 568 | - return $invoice->get_status( $return_label ); |
|
| 568 | + return $invoice->get_status($return_label); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | -function wpinv_get_payment_gateway( $invoice_id, $return_label = false ) { |
|
| 572 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 571 | +function wpinv_get_payment_gateway($invoice_id, $return_label = false) { |
|
| 572 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 573 | 573 | |
| 574 | - return $invoice->get_gateway( $return_label ); |
|
| 574 | + return $invoice->get_gateway($return_label); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | -function wpinv_get_payment_gateway_name( $invoice_id ) { |
|
| 578 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 577 | +function wpinv_get_payment_gateway_name($invoice_id) { |
|
| 578 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 579 | 579 | |
| 580 | 580 | return $invoice->get_gateway_title(); |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | -function wpinv_get_payment_transaction_id( $invoice_id ) { |
|
| 584 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 583 | +function wpinv_get_payment_transaction_id($invoice_id) { |
|
| 584 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 585 | 585 | |
| 586 | 586 | return $invoice->get_transaction_id(); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | -function wpinv_get_id_by_transaction_id( $key ) { |
|
| 589 | +function wpinv_get_id_by_transaction_id($key) { |
|
| 590 | 590 | global $wpdb; |
| 591 | 591 | |
| 592 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 592 | + $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
| 593 | 593 | |
| 594 | - if ( $invoice_id != NULL ) |
|
| 594 | + if ($invoice_id != NULL) |
|
| 595 | 595 | return $invoice_id; |
| 596 | 596 | |
| 597 | 597 | return 0; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
| 601 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 600 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
| 601 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 602 | 602 | |
| 603 | - return $invoice->get_meta( $meta_key, $single ); |
|
| 603 | + return $invoice->get_meta($meta_key, $single); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 607 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 606 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 607 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 608 | 608 | |
| 609 | - return $invoice->update_meta( $meta_key, $meta_value, $prev_value ); |
|
| 609 | + return $invoice->update_meta($meta_key, $meta_value, $prev_value); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | -function wpinv_get_items( $invoice_id = 0 ) { |
|
| 613 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 612 | +function wpinv_get_items($invoice_id = 0) { |
|
| 613 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 614 | 614 | |
| 615 | 615 | $items = $invoice->get_items(); |
| 616 | 616 | $invoice_currency = $invoice->get_currency(); |
| 617 | 617 | |
| 618 | - if ( !empty( $items ) && is_array( $items ) ) { |
|
| 619 | - foreach ( $items as $key => $item ) { |
|
| 618 | + if (!empty($items) && is_array($items)) { |
|
| 619 | + foreach ($items as $key => $item) { |
|
| 620 | 620 | $items[$key]['currency'] = $invoice_currency; |
| 621 | 621 | |
| 622 | - if ( !isset( $item['subtotal'] ) ) { |
|
| 622 | + if (!isset($item['subtotal'])) { |
|
| 623 | 623 | $items[$key]['subtotal'] = $items[$key]['amount'] * 1; |
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - return apply_filters( 'wpinv_get_items', $items, $invoice_id ); |
|
| 628 | + return apply_filters('wpinv_get_items', $items, $invoice_id); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | -function wpinv_get_fees( $invoice_id = 0 ) { |
|
| 632 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 631 | +function wpinv_get_fees($invoice_id = 0) { |
|
| 632 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 633 | 633 | $fees = $invoice->get_fees(); |
| 634 | 634 | |
| 635 | - return apply_filters( 'wpinv_get_fees', $fees, $invoice_id ); |
|
| 635 | + return apply_filters('wpinv_get_fees', $fees, $invoice_id); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | -function wpinv_get_invoice_ip( $invoice_id ) { |
|
| 639 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 638 | +function wpinv_get_invoice_ip($invoice_id) { |
|
| 639 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 640 | 640 | return $invoice->get_ip(); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | -function wpinv_get_invoice_user_info( $invoice_id ) { |
|
| 644 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 643 | +function wpinv_get_invoice_user_info($invoice_id) { |
|
| 644 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 645 | 645 | return $invoice->get_user_info(); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | -function wpinv_subtotal( $invoice_id = 0, $currency = false ) { |
|
| 649 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 648 | +function wpinv_subtotal($invoice_id = 0, $currency = false) { |
|
| 649 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 650 | 650 | |
| 651 | - return $invoice->get_subtotal( $currency ); |
|
| 651 | + return $invoice->get_subtotal($currency); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | -function wpinv_tax( $invoice_id = 0, $currency = false ) { |
|
| 655 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 654 | +function wpinv_tax($invoice_id = 0, $currency = false) { |
|
| 655 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 656 | 656 | |
| 657 | - return $invoice->get_tax( $currency ); |
|
| 657 | + return $invoice->get_tax($currency); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | -function wpinv_discount( $invoice_id = 0, $currency = false, $dash = false ) { |
|
| 661 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 660 | +function wpinv_discount($invoice_id = 0, $currency = false, $dash = false) { |
|
| 661 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 662 | 662 | |
| 663 | - return $invoice->get_discount( $currency, $dash ); |
|
| 663 | + return $invoice->get_discount($currency, $dash); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | -function wpinv_discount_code( $invoice_id = 0 ) { |
|
| 667 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 666 | +function wpinv_discount_code($invoice_id = 0) { |
|
| 667 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 668 | 668 | |
| 669 | 669 | return $invoice->get_discount_code(); |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | -function wpinv_payment_total( $invoice_id = 0, $currency = false ) { |
|
| 673 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 672 | +function wpinv_payment_total($invoice_id = 0, $currency = false) { |
|
| 673 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 674 | 674 | |
| 675 | - return $invoice->get_total( $currency ); |
|
| 675 | + return $invoice->get_total($currency); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | -function wpinv_get_date_created( $invoice_id = 0, $format = '' ) { |
|
| 679 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 678 | +function wpinv_get_date_created($invoice_id = 0, $format = '') { |
|
| 679 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 680 | 680 | |
| 681 | - $format = !empty( $format ) ? $format : get_option( 'date_format' ); |
|
| 681 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
| 682 | 682 | $date_created = $invoice->get_created_date(); |
| 683 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
| 683 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_created)) : ''; |
|
| 684 | 684 | |
| 685 | 685 | return $date_created; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | -function wpinv_get_invoice_date( $invoice_id = 0, $format = '', $default = true ) { |
|
| 689 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 688 | +function wpinv_get_invoice_date($invoice_id = 0, $format = '', $default = true) { |
|
| 689 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 690 | 690 | |
| 691 | - $format = !empty( $format ) ? $format : get_option( 'date_format' ); |
|
| 691 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
| 692 | 692 | $date_completed = $invoice->get_completed_date(); |
| 693 | - $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_completed ) ) : ''; |
|
| 694 | - if ( $invoice_date == '' && $default ) { |
|
| 695 | - $invoice_date = wpinv_get_date_created( $invoice_id, $format ); |
|
| 693 | + $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_completed)) : ''; |
|
| 694 | + if ($invoice_date == '' && $default) { |
|
| 695 | + $invoice_date = wpinv_get_date_created($invoice_id, $format); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | return $invoice_date; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | -function wpinv_get_invoice_vat_number( $invoice_id = 0 ) { |
|
| 702 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 701 | +function wpinv_get_invoice_vat_number($invoice_id = 0) { |
|
| 702 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 703 | 703 | |
| 704 | 704 | return $invoice->get_vat_number(); |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | -function wpinv_insert_payment_note( $invoice_id = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
| 708 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 707 | +function wpinv_insert_payment_note($invoice_id = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
| 708 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 709 | 709 | |
| 710 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
| 710 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | -function wpinv_get_invoice_notes( $invoice_id = 0, $type = '' ) { |
|
| 713 | +function wpinv_get_invoice_notes($invoice_id = 0, $type = '') { |
|
| 714 | 714 | global $invoicing; |
| 715 | 715 | |
| 716 | - if ( empty( $invoice_id ) ) { |
|
| 716 | + if (empty($invoice_id)) { |
|
| 717 | 717 | return NULL; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - $notes = $invoicing->notes->get_invoice_notes( $invoice_id, $type ); |
|
| 720 | + $notes = $invoicing->notes->get_invoice_notes($invoice_id, $type); |
|
| 721 | 721 | |
| 722 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice_id, $type ); |
|
| 722 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice_id, $type); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | -function wpinv_get_payment_key( $invoice_id = 0 ) { |
|
| 726 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 725 | +function wpinv_get_payment_key($invoice_id = 0) { |
|
| 726 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 727 | 727 | return $invoice->get_key(); |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | -function wpinv_get_invoice_number( $invoice_id = 0 ) { |
|
| 731 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 730 | +function wpinv_get_invoice_number($invoice_id = 0) { |
|
| 731 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 732 | 732 | return $invoice->get_number(); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | -function wpinv_get_cart_discountable_subtotal( $code_id ) { |
|
| 735 | +function wpinv_get_cart_discountable_subtotal($code_id) { |
|
| 736 | 736 | $cart_items = wpinv_get_cart_content_details(); |
| 737 | 737 | $items = array(); |
| 738 | 738 | |
| 739 | - $excluded_items = wpinv_get_discount_excluded_items( $code_id ); |
|
| 739 | + $excluded_items = wpinv_get_discount_excluded_items($code_id); |
|
| 740 | 740 | |
| 741 | - if( $cart_items ) { |
|
| 741 | + if ($cart_items) { |
|
| 742 | 742 | |
| 743 | - foreach( $cart_items as $item ) { |
|
| 743 | + foreach ($cart_items as $item) { |
|
| 744 | 744 | |
| 745 | - if( ! in_array( $item['id'], $excluded_items ) ) { |
|
| 746 | - $items[] = $item; |
|
| 745 | + if (!in_array($item['id'], $excluded_items)) { |
|
| 746 | + $items[] = $item; |
|
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - $subtotal = wpinv_get_cart_items_subtotal( $items ); |
|
| 751 | + $subtotal = wpinv_get_cart_items_subtotal($items); |
|
| 752 | 752 | |
| 753 | - return apply_filters( 'wpinv_get_cart_discountable_subtotal', $subtotal ); |
|
| 753 | + return apply_filters('wpinv_get_cart_discountable_subtotal', $subtotal); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | -function wpinv_get_cart_items_subtotal( $items ) { |
|
| 756 | +function wpinv_get_cart_items_subtotal($items) { |
|
| 757 | 757 | $subtotal = 0.00; |
| 758 | 758 | |
| 759 | - if ( is_array( $items ) && ! empty( $items ) ) { |
|
| 760 | - $prices = wp_list_pluck( $items, 'subtotal' ); |
|
| 759 | + if (is_array($items) && !empty($items)) { |
|
| 760 | + $prices = wp_list_pluck($items, 'subtotal'); |
|
| 761 | 761 | |
| 762 | - if( is_array( $prices ) ) { |
|
| 763 | - $subtotal = array_sum( $prices ); |
|
| 762 | + if (is_array($prices)) { |
|
| 763 | + $subtotal = array_sum($prices); |
|
| 764 | 764 | } else { |
| 765 | 765 | $subtotal = 0.00; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - if( $subtotal < 0 ) { |
|
| 768 | + if ($subtotal < 0) { |
|
| 769 | 769 | $subtotal = 0.00; |
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | - return apply_filters( 'wpinv_get_cart_items_subtotal', $subtotal ); |
|
| 773 | + return apply_filters('wpinv_get_cart_items_subtotal', $subtotal); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | -function wpinv_get_cart_subtotal( $items = array() ) { |
|
| 777 | - $items = !empty( $items ) ? $items : wpinv_get_cart_content_details(); |
|
| 778 | - $subtotal = wpinv_get_cart_items_subtotal( $items ); |
|
| 776 | +function wpinv_get_cart_subtotal($items = array()) { |
|
| 777 | + $items = !empty($items) ? $items : wpinv_get_cart_content_details(); |
|
| 778 | + $subtotal = wpinv_get_cart_items_subtotal($items); |
|
| 779 | 779 | |
| 780 | - return apply_filters( 'wpinv_get_cart_subtotal', $subtotal ); |
|
| 780 | + return apply_filters('wpinv_get_cart_subtotal', $subtotal); |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | -function wpinv_cart_subtotal( $items = array(), $currency = '' ) { |
|
| 783 | +function wpinv_cart_subtotal($items = array(), $currency = '') { |
|
| 784 | 784 | |
| 785 | - if( empty( $currency ) ) { |
|
| 785 | + if (empty($currency)) { |
|
| 786 | 786 | $currency = wpinv_get_currency(); |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - $price = wpinv_price( wpinv_format_amount( wpinv_get_cart_subtotal( $items ) ), $currency ); |
|
| 789 | + $price = wpinv_price(wpinv_format_amount(wpinv_get_cart_subtotal($items)), $currency); |
|
| 790 | 790 | |
| 791 | 791 | return $price; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | -function wpinv_get_cart_total( $items = array(), $discounts = false, $invoice = array() ) { |
|
| 795 | - $subtotal = (float)wpinv_get_cart_subtotal( $items ); |
|
| 796 | - $discounts = (float)wpinv_get_cart_discounted_amount( $items ); |
|
| 797 | - $cart_tax = (float)wpinv_get_cart_tax( $items, $invoice ); |
|
| 798 | - $fees = (float)wpinv_get_cart_fee_total(); |
|
| 799 | - if ( !empty( $invoice ) && $invoice->is_free_trial() ) { |
|
| 794 | +function wpinv_get_cart_total($items = array(), $discounts = false, $invoice = array()) { |
|
| 795 | + $subtotal = (float) wpinv_get_cart_subtotal($items); |
|
| 796 | + $discounts = (float) wpinv_get_cart_discounted_amount($items); |
|
| 797 | + $cart_tax = (float) wpinv_get_cart_tax($items, $invoice); |
|
| 798 | + $fees = (float) wpinv_get_cart_fee_total(); |
|
| 799 | + if (!empty($invoice) && $invoice->is_free_trial()) { |
|
| 800 | 800 | $total = 0; |
| 801 | 801 | } else { |
| 802 | - $total = $subtotal - $discounts + $cart_tax + $fees; |
|
| 802 | + $total = $subtotal - $discounts + $cart_tax + $fees; |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - if ( $total < 0 ) { |
|
| 805 | + if ($total < 0) { |
|
| 806 | 806 | $total = 0.00; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - $total = (float)apply_filters( 'wpinv_get_cart_total', $total, $items ); |
|
| 809 | + $total = (float) apply_filters('wpinv_get_cart_total', $total, $items); |
|
| 810 | 810 | |
| 811 | - return wpinv_sanitize_amount( $total ); |
|
| 811 | + return wpinv_sanitize_amount($total); |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | -function wpinv_cart_total( $cart_items = array(), $echo = true, $invoice = array() ) { |
|
| 814 | +function wpinv_cart_total($cart_items = array(), $echo = true, $invoice = array()) { |
|
| 815 | 815 | global $cart_total; |
| 816 | - $total = wpinv_price( wpinv_format_amount( wpinv_get_cart_total( $cart_items, NULL, $invoice ) ), $invoice->get_currency() ); |
|
| 817 | - $total = apply_filters( 'wpinv_cart_total', $total, $cart_items, $invoice ); |
|
| 816 | + $total = wpinv_price(wpinv_format_amount(wpinv_get_cart_total($cart_items, NULL, $invoice)), $invoice->get_currency()); |
|
| 817 | + $total = apply_filters('wpinv_cart_total', $total, $cart_items, $invoice); |
|
| 818 | 818 | |
| 819 | 819 | $cart_total = $total; |
| 820 | 820 | |
| 821 | - if ( !$echo ) { |
|
| 821 | + if (!$echo) { |
|
| 822 | 822 | return $total; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | echo $total; |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | -function wpinv_get_cart_tax( $items = array(), $invoice = 0 ) { |
|
| 828 | +function wpinv_get_cart_tax($items = array(), $invoice = 0) { |
|
| 829 | 829 | |
| 830 | - if ( ! empty( $invoice ) && ! $invoice->is_taxable() ) { |
|
| 830 | + if (!empty($invoice) && !$invoice->is_taxable()) { |
|
| 831 | 831 | return 0; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | $cart_tax = 0; |
| 835 | - $items = !empty( $items ) ? $items : wpinv_get_cart_content_details(); |
|
| 835 | + $items = !empty($items) ? $items : wpinv_get_cart_content_details(); |
|
| 836 | 836 | |
| 837 | - if ( $items ) { |
|
| 838 | - $taxes = wp_list_pluck( $items, 'tax' ); |
|
| 837 | + if ($items) { |
|
| 838 | + $taxes = wp_list_pluck($items, 'tax'); |
|
| 839 | 839 | |
| 840 | - if( is_array( $taxes ) ) { |
|
| 841 | - $cart_tax = array_sum( $taxes ); |
|
| 840 | + if (is_array($taxes)) { |
|
| 841 | + $cart_tax = array_sum($taxes); |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | $cart_tax += wpinv_get_cart_fee_tax(); |
| 846 | 846 | |
| 847 | - return apply_filters( 'wpinv_get_cart_tax', wpinv_sanitize_amount( $cart_tax ) ); |
|
| 847 | + return apply_filters('wpinv_get_cart_tax', wpinv_sanitize_amount($cart_tax)); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | -function wpinv_cart_tax( $items = array(), $echo = false, $currency = '', $invoice = 0 ) { |
|
| 850 | +function wpinv_cart_tax($items = array(), $echo = false, $currency = '', $invoice = 0) { |
|
| 851 | 851 | |
| 852 | - if ( ! empty( $invoice && ! $invoice->is_taxable() ) ) { |
|
| 853 | - echo wpinv_price( wpinv_format_amount( 0 ), $currency ); |
|
| 852 | + if (!empty($invoice && !$invoice->is_taxable())) { |
|
| 853 | + echo wpinv_price(wpinv_format_amount(0), $currency); |
|
| 854 | 854 | return; |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - $cart_tax = wpinv_get_cart_tax( $items, $invoice ); |
|
| 858 | - $cart_tax = wpinv_price( wpinv_format_amount( $cart_tax ), $currency ); |
|
| 857 | + $cart_tax = wpinv_get_cart_tax($items, $invoice); |
|
| 858 | + $cart_tax = wpinv_price(wpinv_format_amount($cart_tax), $currency); |
|
| 859 | 859 | |
| 860 | - $tax = apply_filters( 'wpinv_cart_tax', $cart_tax, $items ); |
|
| 860 | + $tax = apply_filters('wpinv_cart_tax', $cart_tax, $items); |
|
| 861 | 861 | |
| 862 | - if ( !$echo ) { |
|
| 862 | + if (!$echo) { |
|
| 863 | 863 | return $tax; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | echo $tax; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | -function wpinv_get_cart_discount_code( $items = array() ) { |
|
| 869 | +function wpinv_get_cart_discount_code($items = array()) { |
|
| 870 | 870 | $invoice = wpinv_get_invoice_cart(); |
| 871 | - $cart_discount_code = !empty( $invoice ) ? $invoice->get_discount_code() : ''; |
|
| 871 | + $cart_discount_code = !empty($invoice) ? $invoice->get_discount_code() : ''; |
|
| 872 | 872 | |
| 873 | - return apply_filters( 'wpinv_get_cart_discount_code', $cart_discount_code ); |
|
| 873 | + return apply_filters('wpinv_get_cart_discount_code', $cart_discount_code); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | -function wpinv_cart_discount_code( $items = array(), $echo = false ) { |
|
| 877 | - $cart_discount_code = wpinv_get_cart_discount_code( $items ); |
|
| 876 | +function wpinv_cart_discount_code($items = array(), $echo = false) { |
|
| 877 | + $cart_discount_code = wpinv_get_cart_discount_code($items); |
|
| 878 | 878 | |
| 879 | - if ( $cart_discount_code != '' ) { |
|
| 879 | + if ($cart_discount_code != '') { |
|
| 880 | 880 | $cart_discount_code = ' (' . $cart_discount_code . ')'; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - $discount_code = apply_filters( 'wpinv_cart_discount_code', $cart_discount_code, $items ); |
|
| 883 | + $discount_code = apply_filters('wpinv_cart_discount_code', $cart_discount_code, $items); |
|
| 884 | 884 | |
| 885 | - if ( !$echo ) { |
|
| 885 | + if (!$echo) { |
|
| 886 | 886 | return $discount_code; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | echo $discount_code; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | -function wpinv_get_cart_discount( $items = array() ) { |
|
| 892 | +function wpinv_get_cart_discount($items = array()) { |
|
| 893 | 893 | $invoice = wpinv_get_invoice_cart(); |
| 894 | - $cart_discount = !empty( $invoice ) ? $invoice->get_discount() : 0; |
|
| 894 | + $cart_discount = !empty($invoice) ? $invoice->get_discount() : 0; |
|
| 895 | 895 | |
| 896 | - return apply_filters( 'wpinv_get_cart_discount', wpinv_sanitize_amount( $cart_discount ), $items ); |
|
| 896 | + return apply_filters('wpinv_get_cart_discount', wpinv_sanitize_amount($cart_discount), $items); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | -function wpinv_cart_discount( $items = array(), $echo = false ) { |
|
| 900 | - $cart_discount = wpinv_get_cart_discount( $items ); |
|
| 901 | - $cart_discount = wpinv_price( wpinv_format_amount( $cart_discount ) ); |
|
| 899 | +function wpinv_cart_discount($items = array(), $echo = false) { |
|
| 900 | + $cart_discount = wpinv_get_cart_discount($items); |
|
| 901 | + $cart_discount = wpinv_price(wpinv_format_amount($cart_discount)); |
|
| 902 | 902 | |
| 903 | - $discount = apply_filters( 'wpinv_cart_discount', $cart_discount, $items ); |
|
| 903 | + $discount = apply_filters('wpinv_cart_discount', $cart_discount, $items); |
|
| 904 | 904 | |
| 905 | - if ( !$echo ) { |
|
| 905 | + if (!$echo) { |
|
| 906 | 906 | return $discount; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | echo $discount; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | -function wpinv_get_cart_fees( $type = 'all', $item_id = 0 ) { |
|
| 913 | - $item = new WPInv_Item( $item_id ); |
|
| 912 | +function wpinv_get_cart_fees($type = 'all', $item_id = 0) { |
|
| 913 | + $item = new WPInv_Item($item_id); |
|
| 914 | 914 | |
| 915 | - return $item->get_fees( $type, $item_id ); |
|
| 915 | + return $item->get_fees($type, $item_id); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | function wpinv_get_cart_fee_total() { |
| 919 | - $total = 0; |
|
| 919 | + $total = 0; |
|
| 920 | 920 | $fees = wpinv_get_cart_fees(); |
| 921 | 921 | |
| 922 | - if ( $fees ) { |
|
| 923 | - foreach ( $fees as $fee_id => $fee ) { |
|
| 922 | + if ($fees) { |
|
| 923 | + foreach ($fees as $fee_id => $fee) { |
|
| 924 | 924 | $total += $fee['amount']; |
| 925 | 925 | } |
| 926 | 926 | } |
| 927 | 927 | |
| 928 | - return apply_filters( 'wpinv_get_cart_fee_total', $total ); |
|
| 928 | + return apply_filters('wpinv_get_cart_fee_total', $total); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | function wpinv_get_cart_fee_tax() { |
| 932 | 932 | $tax = 0; |
| 933 | 933 | $fees = wpinv_get_cart_fees(); |
| 934 | 934 | |
| 935 | - if ( $fees ) { |
|
| 936 | - foreach ( $fees as $fee_id => $fee ) { |
|
| 937 | - if( ! empty( $fee['no_tax'] ) ) { |
|
| 935 | + if ($fees) { |
|
| 936 | + foreach ($fees as $fee_id => $fee) { |
|
| 937 | + if (!empty($fee['no_tax'])) { |
|
| 938 | 938 | continue; |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | - $tax += wpinv_calculate_tax( $fee['amount'] ); |
|
| 941 | + $tax += wpinv_calculate_tax($fee['amount']); |
|
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - return apply_filters( 'wpinv_get_cart_fee_tax', $tax ); |
|
| 945 | + return apply_filters('wpinv_get_cart_fee_tax', $tax); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | function wpinv_cart_has_recurring_item() { |
| 949 | 949 | $cart_items = wpinv_get_cart_contents(); |
| 950 | 950 | |
| 951 | - if ( empty( $cart_items ) ) { |
|
| 951 | + if (empty($cart_items)) { |
|
| 952 | 952 | return false; |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | 955 | $has_subscription = false; |
| 956 | - foreach( $cart_items as $cart_item ) { |
|
| 957 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
| 956 | + foreach ($cart_items as $cart_item) { |
|
| 957 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
| 958 | 958 | $has_subscription = true; |
| 959 | 959 | break; |
| 960 | 960 | } |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - return apply_filters( 'wpinv_cart_has_recurring_item', $has_subscription, $cart_items ); |
|
| 963 | + return apply_filters('wpinv_cart_has_recurring_item', $has_subscription, $cart_items); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | function wpinv_cart_has_free_trial() { |
@@ -968,100 +968,100 @@ discard block |
||
| 968 | 968 | |
| 969 | 969 | $free_trial = false; |
| 970 | 970 | |
| 971 | - if ( !empty( $invoice ) && $invoice->is_free_trial() ) { |
|
| 971 | + if (!empty($invoice) && $invoice->is_free_trial()) { |
|
| 972 | 972 | $free_trial = true; |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - return apply_filters( 'wpinv_cart_has_free_trial', $free_trial, $invoice ); |
|
| 975 | + return apply_filters('wpinv_cart_has_free_trial', $free_trial, $invoice); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | function wpinv_get_cart_contents() { |
| 979 | 979 | $cart_details = wpinv_get_cart_details(); |
| 980 | 980 | |
| 981 | - return apply_filters( 'wpinv_get_cart_contents', $cart_details ); |
|
| 981 | + return apply_filters('wpinv_get_cart_contents', $cart_details); |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | function wpinv_get_cart_content_details() { |
| 985 | 985 | global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpinv_is_last_cart_item, $wpinv_flat_discount_total; |
| 986 | 986 | $cart_items = wpinv_get_cart_contents(); |
| 987 | 987 | |
| 988 | - if ( empty( $cart_items ) ) { |
|
| 988 | + if (empty($cart_items)) { |
|
| 989 | 989 | return false; |
| 990 | 990 | } |
| 991 | 991 | $invoice = wpinv_get_invoice_cart(); |
| 992 | - if ( empty( $invoice ) ) { |
|
| 992 | + if (empty($invoice)) { |
|
| 993 | 993 | return false; |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | $details = array(); |
| 997 | - $length = count( $cart_items ) - 1; |
|
| 997 | + $length = count($cart_items) - 1; |
|
| 998 | 998 | |
| 999 | - if ( empty( $_POST['country'] ) ) { |
|
| 999 | + if (empty($_POST['country'])) { |
|
| 1000 | 1000 | $_POST['country'] = $invoice->country; |
| 1001 | 1001 | } |
| 1002 | - if ( !isset( $_POST['state'] ) ) { |
|
| 1002 | + if (!isset($_POST['state'])) { |
|
| 1003 | 1003 | $_POST['state'] = $invoice->state; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - foreach( $cart_items as $key => $item ) { |
|
| 1007 | - $item_id = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : ''; |
|
| 1008 | - if ( empty( $item_id ) ) { |
|
| 1006 | + foreach ($cart_items as $key => $item) { |
|
| 1007 | + $item_id = isset($item['id']) ? sanitize_text_field($item['id']) : ''; |
|
| 1008 | + if (empty($item_id)) { |
|
| 1009 | 1009 | continue; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | $wpi_current_id = $invoice->ID; |
| 1013 | 1013 | $wpi_item_id = $item_id; |
| 1014 | 1014 | |
| 1015 | - if ( isset( $item['custom_price'] ) && $item['custom_price'] !== '' ) { |
|
| 1015 | + if (isset($item['custom_price']) && $item['custom_price'] !== '') { |
|
| 1016 | 1016 | $item_price = $item['custom_price']; |
| 1017 | 1017 | } else { |
| 1018 | - if ( isset( $item['item_price'] ) && $item['item_price'] !== '' && $item['item_price'] !== false ) { |
|
| 1018 | + if (isset($item['item_price']) && $item['item_price'] !== '' && $item['item_price'] !== false) { |
|
| 1019 | 1019 | $item_price = $item['item_price']; |
| 1020 | 1020 | } else { |
| 1021 | - $item_price = wpinv_get_item_price( $item_id ); |
|
| 1021 | + $item_price = wpinv_get_item_price($item_id); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| 1024 | - $discount = wpinv_get_cart_item_discount_amount( $item ); |
|
| 1025 | - $discount = apply_filters( 'wpinv_get_cart_content_details_item_discount_amount', $discount, $item ); |
|
| 1026 | - $quantity = wpinv_get_cart_item_quantity( $item ); |
|
| 1027 | - $fees = wpinv_get_cart_fees( 'fee', $item_id ); |
|
| 1024 | + $discount = wpinv_get_cart_item_discount_amount($item); |
|
| 1025 | + $discount = apply_filters('wpinv_get_cart_content_details_item_discount_amount', $discount, $item); |
|
| 1026 | + $quantity = wpinv_get_cart_item_quantity($item); |
|
| 1027 | + $fees = wpinv_get_cart_fees('fee', $item_id); |
|
| 1028 | 1028 | |
| 1029 | 1029 | $subtotal = $item_price * $quantity; |
| 1030 | - $tax_rate = wpinv_get_tax_rate( $_POST['country'], $_POST['state'], $wpi_item_id ); |
|
| 1031 | - $tax_class = $wpinv_euvat->get_item_class( $item_id ); |
|
| 1032 | - $tax = wpinv_get_cart_item_tax( $item_id, $subtotal - $discount ); |
|
| 1030 | + $tax_rate = wpinv_get_tax_rate($_POST['country'], $_POST['state'], $wpi_item_id); |
|
| 1031 | + $tax_class = $wpinv_euvat->get_item_class($item_id); |
|
| 1032 | + $tax = wpinv_get_cart_item_tax($item_id, $subtotal - $discount); |
|
| 1033 | 1033 | |
| 1034 | - if ( ! $invoice->is_taxable() ) { |
|
| 1034 | + if (!$invoice->is_taxable()) { |
|
| 1035 | 1035 | $tax = 0; |
| 1036 | 1036 | } |
| 1037 | - if ( wpinv_prices_include_tax() ) { |
|
| 1038 | - $subtotal -= wpinv_round_amount( $tax ); |
|
| 1037 | + if (wpinv_prices_include_tax()) { |
|
| 1038 | + $subtotal -= wpinv_round_amount($tax); |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | - $total = $subtotal - $discount + $tax; |
|
| 1041 | + $total = $subtotal - $discount + $tax; |
|
| 1042 | 1042 | |
| 1043 | 1043 | // Do not allow totals to go negatve |
| 1044 | - if( $total < 0 ) { |
|
| 1044 | + if ($total < 0) { |
|
| 1045 | 1045 | $total = 0; |
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - $details[ $key ] = array( |
|
| 1048 | + $details[$key] = array( |
|
| 1049 | 1049 | 'id' => $item_id, |
| 1050 | - 'name' => !empty($item['name']) ? $item['name'] : get_the_title( $item_id ), |
|
| 1051 | - 'item_price' => wpinv_round_amount( $item_price ), |
|
| 1052 | - 'custom_price' => isset( $item['custom_price'] ) ? $item['custom_price'] : '', |
|
| 1050 | + 'name' => !empty($item['name']) ? $item['name'] : get_the_title($item_id), |
|
| 1051 | + 'item_price' => wpinv_round_amount($item_price), |
|
| 1052 | + 'custom_price' => isset($item['custom_price']) ? $item['custom_price'] : '', |
|
| 1053 | 1053 | 'quantity' => $quantity, |
| 1054 | - 'discount' => wpinv_round_amount( $discount ), |
|
| 1055 | - 'subtotal' => wpinv_round_amount( $subtotal ), |
|
| 1056 | - 'tax' => wpinv_round_amount( $tax ), |
|
| 1057 | - 'price' => wpinv_round_amount( $total ), |
|
| 1054 | + 'discount' => wpinv_round_amount($discount), |
|
| 1055 | + 'subtotal' => wpinv_round_amount($subtotal), |
|
| 1056 | + 'tax' => wpinv_round_amount($tax), |
|
| 1057 | + 'price' => wpinv_round_amount($total), |
|
| 1058 | 1058 | 'vat_rates_class' => $tax_class, |
| 1059 | 1059 | 'vat_rate' => $tax_rate, |
| 1060 | - 'meta' => isset( $item['meta'] ) ? $item['meta'] : array(), |
|
| 1060 | + 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
|
| 1061 | 1061 | 'fees' => $fees, |
| 1062 | 1062 | ); |
| 1063 | 1063 | |
| 1064 | - if ( $wpinv_is_last_cart_item ) { |
|
| 1064 | + if ($wpinv_is_last_cart_item) { |
|
| 1065 | 1065 | $wpinv_is_last_cart_item = false; |
| 1066 | 1066 | $wpinv_flat_discount_total = 0.00; |
| 1067 | 1067 | } |
@@ -1070,74 +1070,74 @@ discard block |
||
| 1070 | 1070 | return $details; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | -function wpinv_get_cart_details( $invoice_id = 0 ) { |
|
| 1073 | +function wpinv_get_cart_details($invoice_id = 0) { |
|
| 1074 | 1074 | global $ajax_cart_details; |
| 1075 | 1075 | |
| 1076 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1076 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1077 | 1077 | $cart_details = $ajax_cart_details; |
| 1078 | - if ( empty( $cart_details ) && ! empty( $invoice->cart_details ) ) { |
|
| 1078 | + if (empty($cart_details) && !empty($invoice->cart_details)) { |
|
| 1079 | 1079 | $cart_details = $invoice->cart_details; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( ! empty( $cart_details ) && is_array( $cart_details ) ) { |
|
| 1083 | - $invoice_currency = ! empty( $invoice->currency ) ? $invoice->currency : wpinv_get_default_country(); |
|
| 1082 | + if (!empty($cart_details) && is_array($cart_details)) { |
|
| 1083 | + $invoice_currency = !empty($invoice->currency) ? $invoice->currency : wpinv_get_default_country(); |
|
| 1084 | 1084 | |
| 1085 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 1086 | - $cart_details[ $key ]['currency'] = $invoice_currency; |
|
| 1085 | + foreach ($cart_details as $key => $cart_item) { |
|
| 1086 | + $cart_details[$key]['currency'] = $invoice_currency; |
|
| 1087 | 1087 | |
| 1088 | - if ( ! isset( $cart_item['subtotal'] ) ) { |
|
| 1089 | - $cart_details[ $key ]['subtotal'] = $cart_item['price']; |
|
| 1088 | + if (!isset($cart_item['subtotal'])) { |
|
| 1089 | + $cart_details[$key]['subtotal'] = $cart_item['price']; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - return apply_filters( 'wpinv_get_cart_details', $cart_details, $invoice_id ); |
|
| 1094 | + return apply_filters('wpinv_get_cart_details', $cart_details, $invoice_id); |
|
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | -function wpinv_record_status_change( $invoice_id, $new_status, $old_status ) { |
|
| 1098 | - if ( 'wpi_invoice' != get_post_type( $invoice_id ) ) { |
|
| 1097 | +function wpinv_record_status_change($invoice_id, $new_status, $old_status) { |
|
| 1098 | + if ('wpi_invoice' != get_post_type($invoice_id)) { |
|
| 1099 | 1099 | return; |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | - if ( ( $old_status == 'wpi-pending' && $new_status == 'draft' ) || ( $old_status == 'draft' && $new_status == 'wpi-pending' ) ) { |
|
| 1102 | + if (($old_status == 'wpi-pending' && $new_status == 'draft') || ($old_status == 'draft' && $new_status == 'wpi-pending')) { |
|
| 1103 | 1103 | return; |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1106 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1107 | 1107 | |
| 1108 | - if ( wpinv_use_taxes() && $new_status == 'publish' ) { |
|
| 1108 | + if (wpinv_use_taxes() && $new_status == 'publish') { |
|
| 1109 | 1109 | |
| 1110 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->country ) ) { |
|
| 1111 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
| 1110 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->country)) { |
|
| 1111 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | - $old_status = wpinv_status_nicename( $old_status ); |
|
| 1116 | - $new_status = wpinv_status_nicename( $new_status ); |
|
| 1115 | + $old_status = wpinv_status_nicename($old_status); |
|
| 1116 | + $new_status = wpinv_status_nicename($new_status); |
|
| 1117 | 1117 | |
| 1118 | - $status_change = sprintf( __( 'Invoice status changed from %s to %s', 'invoicing' ), $old_status, $new_status ); |
|
| 1118 | + $status_change = sprintf(__('Invoice status changed from %s to %s', 'invoicing'), $old_status, $new_status); |
|
| 1119 | 1119 | |
| 1120 | 1120 | // Add note |
| 1121 | - return $invoice->add_note( $status_change, false, false, true ); |
|
| 1121 | + return $invoice->add_note($status_change, false, false, true); |
|
| 1122 | 1122 | } |
| 1123 | -add_action( 'wpinv_update_status', 'wpinv_record_status_change', 100, 3 ); |
|
| 1123 | +add_action('wpinv_update_status', 'wpinv_record_status_change', 100, 3); |
|
| 1124 | 1124 | |
| 1125 | -function wpinv_complete_payment( $invoice_id, $new_status, $old_status ) { |
|
| 1125 | +function wpinv_complete_payment($invoice_id, $new_status, $old_status) { |
|
| 1126 | 1126 | global $wpi_has_free_trial; |
| 1127 | 1127 | |
| 1128 | 1128 | $wpi_has_free_trial = false; |
| 1129 | 1129 | |
| 1130 | - if ( $old_status == 'publish' ) { |
|
| 1130 | + if ($old_status == 'publish') { |
|
| 1131 | 1131 | return; // Make sure that payments are only paid once |
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | // Make sure the payment completion is only processed when new status is paid |
| 1135 | - if ( $new_status != 'publish' ) { |
|
| 1135 | + if ($new_status != 'publish') { |
|
| 1136 | 1136 | return; |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1140 | - if ( empty( $invoice ) ) { |
|
| 1139 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1140 | + if (empty($invoice)) { |
|
| 1141 | 1141 | return; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
@@ -1145,58 +1145,58 @@ discard block |
||
| 1145 | 1145 | $completed_date = $invoice->completed_date; |
| 1146 | 1146 | $cart_details = $invoice->cart_details; |
| 1147 | 1147 | |
| 1148 | - do_action( 'wpinv_pre_complete_payment', $invoice_id ); |
|
| 1148 | + do_action('wpinv_pre_complete_payment', $invoice_id); |
|
| 1149 | 1149 | |
| 1150 | - if ( is_array( $cart_details ) ) { |
|
| 1150 | + if (is_array($cart_details)) { |
|
| 1151 | 1151 | // Increase purchase count and earnings |
| 1152 | - foreach ( $cart_details as $cart_index => $item ) { |
|
| 1152 | + foreach ($cart_details as $cart_index => $item) { |
|
| 1153 | 1153 | // Ensure these actions only run once, ever |
| 1154 | - if ( empty( $completed_date ) ) { |
|
| 1155 | - do_action( 'wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index ); |
|
| 1154 | + if (empty($completed_date)) { |
|
| 1155 | + do_action('wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | } |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | // Check for discount codes and increment their use counts |
| 1161 | - if ( $discounts = $invoice->get_discounts( true ) ) { |
|
| 1162 | - if( ! empty( $discounts ) ) { |
|
| 1163 | - foreach( $discounts as $code ) { |
|
| 1164 | - wpinv_increase_discount_usage( $code ); |
|
| 1161 | + if ($discounts = $invoice->get_discounts(true)) { |
|
| 1162 | + if (!empty($discounts)) { |
|
| 1163 | + foreach ($discounts as $code) { |
|
| 1164 | + wpinv_increase_discount_usage($code); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | } |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | // Ensure this action only runs once ever |
| 1170 | - if( empty( $completed_date ) ) { |
|
| 1170 | + if (empty($completed_date)) { |
|
| 1171 | 1171 | // Save the completed date |
| 1172 | - $invoice->set( 'completed_date', current_time( 'mysql', 0 ) ); |
|
| 1172 | + $invoice->set('completed_date', current_time('mysql', 0)); |
|
| 1173 | 1173 | $invoice->save(); |
| 1174 | 1174 | |
| 1175 | - do_action( 'wpinv_complete_payment', $invoice_id ); |
|
| 1175 | + do_action('wpinv_complete_payment', $invoice_id); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | // Empty the shopping cart |
| 1179 | 1179 | wpinv_empty_cart(); |
| 1180 | 1180 | } |
| 1181 | -add_action( 'wpinv_update_status', 'wpinv_complete_payment', 100, 3 ); |
|
| 1181 | +add_action('wpinv_update_status', 'wpinv_complete_payment', 100, 3); |
|
| 1182 | 1182 | |
| 1183 | -function wpinv_update_payment_status( $invoice_id, $new_status = 'publish' ) { |
|
| 1184 | - $invoice = !empty( $invoice_id ) && is_object( $invoice_id ) ? $invoice_id : wpinv_get_invoice( (int)$invoice_id ); |
|
| 1183 | +function wpinv_update_payment_status($invoice_id, $new_status = 'publish') { |
|
| 1184 | + $invoice = !empty($invoice_id) && is_object($invoice_id) ? $invoice_id : wpinv_get_invoice((int) $invoice_id); |
|
| 1185 | 1185 | |
| 1186 | - if ( empty( $invoice ) ) { |
|
| 1186 | + if (empty($invoice)) { |
|
| 1187 | 1187 | return false; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - return $invoice->update_status( $new_status ); |
|
| 1190 | + return $invoice->update_status($new_status); |
|
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | -function wpinv_cart_has_fees( $type = 'all' ) { |
|
| 1193 | +function wpinv_cart_has_fees($type = 'all') { |
|
| 1194 | 1194 | return false; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | function wpinv_validate_checkout_fields() { |
| 1198 | 1198 | // Check if there is $_POST |
| 1199 | - if ( empty( $_POST ) ) { |
|
| 1199 | + if (empty($_POST)) { |
|
| 1200 | 1200 | return false; |
| 1201 | 1201 | } |
| 1202 | 1202 | |
@@ -1219,28 +1219,28 @@ discard block |
||
| 1219 | 1219 | |
| 1220 | 1220 | $invoice = wpinv_get_invoice_cart(); |
| 1221 | 1221 | $has_subscription = $invoice->is_recurring(); |
| 1222 | - if ( empty( $invoice ) ) { |
|
| 1223 | - wpinv_set_error( 'invalid_invoice', __( 'Your cart is empty.', 'invoicing' ) ); |
|
| 1222 | + if (empty($invoice)) { |
|
| 1223 | + wpinv_set_error('invalid_invoice', __('Your cart is empty.', 'invoicing')); |
|
| 1224 | 1224 | return $gateway; |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | // Check if a gateway value is present |
| 1228 | - if ( !empty( $_REQUEST['wpi-gateway'] ) ) { |
|
| 1229 | - $gateway = sanitize_text_field( $_REQUEST['wpi-gateway'] ); |
|
| 1228 | + if (!empty($_REQUEST['wpi-gateway'])) { |
|
| 1229 | + $gateway = sanitize_text_field($_REQUEST['wpi-gateway']); |
|
| 1230 | 1230 | |
| 1231 | - if ( $invoice->is_free() ) { |
|
| 1231 | + if ($invoice->is_free()) { |
|
| 1232 | 1232 | $gateway = 'manual'; |
| 1233 | - } elseif ( !wpinv_is_gateway_active( $gateway ) ) { |
|
| 1234 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'invoicing' ) ); |
|
| 1235 | - } elseif ( $has_subscription && !wpinv_gateway_support_subscription( $gateway ) ) { |
|
| 1236 | - if ( apply_filters( 'wpinv_reject_non_recurring_gateway', true ) ) { |
|
| 1237 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway does not support subscription payment', 'invoicing' ) ); |
|
| 1233 | + } elseif (!wpinv_is_gateway_active($gateway)) { |
|
| 1234 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'invoicing')); |
|
| 1235 | + } elseif ($has_subscription && !wpinv_gateway_support_subscription($gateway)) { |
|
| 1236 | + if (apply_filters('wpinv_reject_non_recurring_gateway', true)) { |
|
| 1237 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway does not support subscription payment', 'invoicing')); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | } |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | - if ( $has_subscription && count( wpinv_get_cart_contents() ) > 1 ) { |
|
| 1243 | - wpinv_set_error( 'subscription_invalid', __( 'Only one subscription may be purchased through payment per checkout.', 'invoicing' ) ); |
|
| 1242 | + if ($has_subscription && count(wpinv_get_cart_contents()) > 1) { |
|
| 1243 | + wpinv_set_error('subscription_invalid', __('Only one subscription may be purchased through payment per checkout.', 'invoicing')); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | return $gateway; |
@@ -1252,41 +1252,41 @@ discard block |
||
| 1252 | 1252 | // Retrieve the discount stored in cookies |
| 1253 | 1253 | $discounts = wpinv_get_cart_discounts(); |
| 1254 | 1254 | |
| 1255 | - if ( ! is_array( $discounts ) ) { |
|
| 1255 | + if (!is_array($discounts)) { |
|
| 1256 | 1256 | return NULL; |
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | - $discounts = array_filter( $discounts ); |
|
| 1260 | - $error = false; |
|
| 1259 | + $discounts = array_filter($discounts); |
|
| 1260 | + $error = false; |
|
| 1261 | 1261 | |
| 1262 | - if ( empty( $discounts ) ) { |
|
| 1262 | + if (empty($discounts)) { |
|
| 1263 | 1263 | return NULL; |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | // If we have discounts, loop through them |
| 1267 | - foreach ( $discounts as $discount ) { |
|
| 1267 | + foreach ($discounts as $discount) { |
|
| 1268 | 1268 | // Check if valid |
| 1269 | - if ( ! wpinv_is_discount_valid( $discount, (int) $wpi_cart->get_user_id() ) ) { |
|
| 1269 | + if (!wpinv_is_discount_valid($discount, (int) $wpi_cart->get_user_id())) { |
|
| 1270 | 1270 | // Discount is not valid |
| 1271 | 1271 | $error = true; |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | - if ( $error && ! wpinv_get_errors() ) { |
|
| 1277 | - wpinv_set_error( 'invalid_discount', __( 'Discount code you entered is invalid', 'invoicing' ) ); |
|
| 1276 | + if ($error && !wpinv_get_errors()) { |
|
| 1277 | + wpinv_set_error('invalid_discount', __('Discount code you entered is invalid', 'invoicing')); |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | - return implode( ',', $discounts ); |
|
| 1280 | + return implode(',', $discounts); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | function wpinv_checkout_validate_cc() { |
| 1284 | 1284 | $card_data = wpinv_checkout_get_cc_info(); |
| 1285 | 1285 | |
| 1286 | 1286 | // Validate the card zip |
| 1287 | - if ( !empty( $card_data['wpinv_zip'] ) ) { |
|
| 1288 | - if ( !wpinv_checkout_validate_cc_zip( $card_data['wpinv_zip'], $card_data['wpinv_country'] ) ) { |
|
| 1289 | - wpinv_set_error( 'invalid_cc_zip', __( 'The zip / postcode you entered for your billing address is invalid', 'invoicing' ) ); |
|
| 1287 | + if (!empty($card_data['wpinv_zip'])) { |
|
| 1288 | + if (!wpinv_checkout_validate_cc_zip($card_data['wpinv_zip'], $card_data['wpinv_country'])) { |
|
| 1289 | + wpinv_set_error('invalid_cc_zip', __('The zip / postcode you entered for your billing address is invalid', 'invoicing')); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | } |
| 1292 | 1292 | |
@@ -1296,28 +1296,28 @@ discard block |
||
| 1296 | 1296 | |
| 1297 | 1297 | function wpinv_checkout_get_cc_info() { |
| 1298 | 1298 | $cc_info = array(); |
| 1299 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1300 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1301 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1302 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1303 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1304 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1305 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1306 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1307 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1308 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1299 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 1300 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 1301 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 1302 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 1303 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 1304 | + $cc_info['card_address'] = isset($_POST['wpinv_address']) ? sanitize_text_field($_POST['wpinv_address']) : ''; |
|
| 1305 | + $cc_info['card_city'] = isset($_POST['wpinv_city']) ? sanitize_text_field($_POST['wpinv_city']) : ''; |
|
| 1306 | + $cc_info['card_state'] = isset($_POST['wpinv_state']) ? sanitize_text_field($_POST['wpinv_state']) : ''; |
|
| 1307 | + $cc_info['card_country'] = isset($_POST['wpinv_country']) ? sanitize_text_field($_POST['wpinv_country']) : ''; |
|
| 1308 | + $cc_info['card_zip'] = isset($_POST['wpinv_zip']) ? sanitize_text_field($_POST['wpinv_zip']) : ''; |
|
| 1309 | 1309 | |
| 1310 | 1310 | // Return cc info |
| 1311 | 1311 | return $cc_info; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | -function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 1314 | +function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 1315 | 1315 | $ret = false; |
| 1316 | 1316 | |
| 1317 | - if ( empty( $zip ) || empty( $country_code ) ) |
|
| 1317 | + if (empty($zip) || empty($country_code)) |
|
| 1318 | 1318 | return $ret; |
| 1319 | 1319 | |
| 1320 | - $country_code = strtoupper( $country_code ); |
|
| 1320 | + $country_code = strtoupper($country_code); |
|
| 1321 | 1321 | |
| 1322 | 1322 | $zip_regex = array( |
| 1323 | 1323 | "AD" => "AD\d{3}", |
@@ -1477,72 +1477,72 @@ discard block |
||
| 1477 | 1477 | "ZM" => "\d{5}" |
| 1478 | 1478 | ); |
| 1479 | 1479 | |
| 1480 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) |
|
| 1480 | + if (!isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip)) |
|
| 1481 | 1481 | $ret = true; |
| 1482 | 1482 | |
| 1483 | - return apply_filters( 'wpinv_is_zip_valid', $ret, $zip, $country_code ); |
|
| 1483 | + return apply_filters('wpinv_is_zip_valid', $ret, $zip, $country_code); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | 1486 | function wpinv_checkout_validate_agree_to_terms() { |
| 1487 | 1487 | // Validate agree to terms |
| 1488 | - if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) { |
|
| 1488 | + if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) { |
|
| 1489 | 1489 | // User did not agree |
| 1490 | - wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) ); |
|
| 1490 | + wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing'))); |
|
| 1491 | 1491 | } |
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | 1494 | function wpinv_checkout_validate_invoice_user() { |
| 1495 | 1495 | global $wpi_cart, $user_ID; |
| 1496 | 1496 | |
| 1497 | - if(empty($wpi_cart)){ |
|
| 1497 | + if (empty($wpi_cart)) { |
|
| 1498 | 1498 | $wpi_cart = wpinv_get_invoice_cart(); |
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | - $invoice_user = (int)$wpi_cart->get_user_id(); |
|
| 1501 | + $invoice_user = (int) $wpi_cart->get_user_id(); |
|
| 1502 | 1502 | $valid_user_data = array( |
| 1503 | 1503 | 'user_id' => $invoice_user |
| 1504 | 1504 | ); |
| 1505 | 1505 | |
| 1506 | 1506 | // If guest checkout allowed |
| 1507 | - if ( !wpinv_require_login_to_checkout() ) { |
|
| 1507 | + if (!wpinv_require_login_to_checkout()) { |
|
| 1508 | 1508 | return $valid_user_data; |
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | // Verify there is a user_ID |
| 1512 | - if ( $user_ID == $invoice_user ) { |
|
| 1512 | + if ($user_ID == $invoice_user) { |
|
| 1513 | 1513 | // Get the logged in user data |
| 1514 | - $user_data = get_userdata( $user_ID ); |
|
| 1515 | - $required_fields = wpinv_checkout_required_fields(); |
|
| 1514 | + $user_data = get_userdata($user_ID); |
|
| 1515 | + $required_fields = wpinv_checkout_required_fields(); |
|
| 1516 | 1516 | |
| 1517 | 1517 | // Loop through required fields and show error messages |
| 1518 | - if ( !empty( $required_fields ) ) { |
|
| 1519 | - foreach ( $required_fields as $field_name => $value ) { |
|
| 1520 | - if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
|
| 1521 | - wpinv_set_error( $value['error_id'], $value['error_message'] ); |
|
| 1518 | + if (!empty($required_fields)) { |
|
| 1519 | + foreach ($required_fields as $field_name => $value) { |
|
| 1520 | + if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) { |
|
| 1521 | + wpinv_set_error($value['error_id'], $value['error_message']); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | // Verify data |
| 1527 | - if ( $user_data ) { |
|
| 1527 | + if ($user_data) { |
|
| 1528 | 1528 | // Collected logged in user data |
| 1529 | 1529 | $valid_user_data = array( |
| 1530 | 1530 | 'user_id' => $user_ID, |
| 1531 | - 'email' => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email, |
|
| 1532 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name, |
|
| 1533 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name'] ) ? sanitize_text_field( $_POST['wpinv_last_name'] ) : $user_data->last_name, |
|
| 1531 | + 'email' => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email, |
|
| 1532 | + 'first_name' => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name, |
|
| 1533 | + 'last_name' => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name, |
|
| 1534 | 1534 | ); |
| 1535 | 1535 | |
| 1536 | - if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) { |
|
| 1537 | - wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) ); |
|
| 1536 | + if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) { |
|
| 1537 | + wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing')); |
|
| 1538 | 1538 | } |
| 1539 | 1539 | } else { |
| 1540 | 1540 | // Set invalid user error |
| 1541 | - wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) ); |
|
| 1541 | + wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing')); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | } else { |
| 1544 | 1544 | // Set invalid user error |
| 1545 | - wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) ); |
|
| 1545 | + wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing')); |
|
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | // Return user data |
@@ -1554,27 +1554,27 @@ discard block |
||
| 1554 | 1554 | |
| 1555 | 1555 | $data = array(); |
| 1556 | 1556 | |
| 1557 | - if ( is_user_logged_in() ) { |
|
| 1558 | - if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) { |
|
| 1559 | - $data['user_id'] = (int)get_current_user_id(); |
|
| 1557 | + if (is_user_logged_in()) { |
|
| 1558 | + if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int) $wpi_cart->get_user_id() === (int) get_current_user_id())) { |
|
| 1559 | + $data['user_id'] = (int) get_current_user_id(); |
|
| 1560 | 1560 | } else { |
| 1561 | - wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) ); |
|
| 1561 | + wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing')); |
|
| 1562 | 1562 | } |
| 1563 | 1563 | } else { |
| 1564 | 1564 | // If guest checkout allowed |
| 1565 | - if ( !wpinv_require_login_to_checkout() ) { |
|
| 1565 | + if (!wpinv_require_login_to_checkout()) { |
|
| 1566 | 1566 | $data['user_id'] = 0; |
| 1567 | 1567 | } else { |
| 1568 | - wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) ); |
|
| 1568 | + wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing')); |
|
| 1569 | 1569 | } |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | return $data; |
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | -function wpinv_checkout_form_get_user( $valid_data = array() ) { |
|
| 1575 | +function wpinv_checkout_form_get_user($valid_data = array()) { |
|
| 1576 | 1576 | |
| 1577 | - if ( !empty( $valid_data['current_user']['user_id'] ) ) { |
|
| 1577 | + if (!empty($valid_data['current_user']['user_id'])) { |
|
| 1578 | 1578 | $user = $valid_data['current_user']; |
| 1579 | 1579 | } else { |
| 1580 | 1580 | // Set the valid invoice user |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | } |
| 1583 | 1583 | |
| 1584 | 1584 | // Verify invoice have an user |
| 1585 | - if ( false === $user || empty( $user ) ) { |
|
| 1585 | + if (false === $user || empty($user)) { |
|
| 1586 | 1586 | return false; |
| 1587 | 1587 | } |
| 1588 | 1588 | |
@@ -1599,11 +1599,11 @@ discard block |
||
| 1599 | 1599 | 'zip', |
| 1600 | 1600 | ); |
| 1601 | 1601 | |
| 1602 | - foreach ( $address_fields as $field ) { |
|
| 1603 | - $user[$field] = !empty( $_POST['wpinv_' . $field] ) ? sanitize_text_field( $_POST['wpinv_' . $field] ) : false; |
|
| 1602 | + foreach ($address_fields as $field) { |
|
| 1603 | + $user[$field] = !empty($_POST['wpinv_' . $field]) ? sanitize_text_field($_POST['wpinv_' . $field]) : false; |
|
| 1604 | 1604 | |
| 1605 | - if ( !empty( $user['user_id'] ) && !empty( $valid_data['current_user']['user_id'] ) && $valid_data['current_user']['user_id'] == $valid_data['invoice_user']['user_id'] ) { |
|
| 1606 | - update_user_meta( $user['user_id'], '_wpinv_' . $field, $user[$field] ); |
|
| 1605 | + if (!empty($user['user_id']) && !empty($valid_data['current_user']['user_id']) && $valid_data['current_user']['user_id'] == $valid_data['invoice_user']['user_id']) { |
|
| 1606 | + update_user_meta($user['user_id'], '_wpinv_' . $field, $user[$field]); |
|
| 1607 | 1607 | } |
| 1608 | 1608 | } |
| 1609 | 1609 | |
@@ -1611,26 +1611,26 @@ discard block |
||
| 1611 | 1611 | return $user; |
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | -function wpinv_set_checkout_session( $invoice_data = array() ) { |
|
| 1614 | +function wpinv_set_checkout_session($invoice_data = array()) { |
|
| 1615 | 1615 | global $wpi_session; |
| 1616 | - return $wpi_session->set( 'wpinv_checkout', $invoice_data ); |
|
| 1616 | + return $wpi_session->set('wpinv_checkout', $invoice_data); |
|
| 1617 | 1617 | } |
| 1618 | 1618 | |
| 1619 | 1619 | function wpinv_get_checkout_session() { |
| 1620 | 1620 | global $wpi_session; |
| 1621 | - return $wpi_session->get( 'wpinv_checkout' ); |
|
| 1621 | + return $wpi_session->get('wpinv_checkout'); |
|
| 1622 | 1622 | } |
| 1623 | 1623 | |
| 1624 | 1624 | function wpinv_empty_cart() { |
| 1625 | 1625 | global $wpi_session; |
| 1626 | 1626 | |
| 1627 | 1627 | // Remove cart contents |
| 1628 | - $wpi_session->set( 'wpinv_checkout', NULL ); |
|
| 1628 | + $wpi_session->set('wpinv_checkout', NULL); |
|
| 1629 | 1629 | |
| 1630 | 1630 | // Remove all cart fees |
| 1631 | - $wpi_session->set( 'wpi_cart_fees', NULL ); |
|
| 1631 | + $wpi_session->set('wpi_cart_fees', NULL); |
|
| 1632 | 1632 | |
| 1633 | - do_action( 'wpinv_empty_cart' ); |
|
| 1633 | + do_action('wpinv_empty_cart'); |
|
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | function wpinv_process_checkout() { |
@@ -1639,7 +1639,7 @@ discard block |
||
| 1639 | 1639 | wpinv_clear_errors(); |
| 1640 | 1640 | |
| 1641 | 1641 | $invoice = wpinv_get_invoice_cart(); |
| 1642 | - if ( empty( $invoice ) ) { |
|
| 1642 | + if (empty($invoice)) { |
|
| 1643 | 1643 | return false; |
| 1644 | 1644 | } |
| 1645 | 1645 | |
@@ -1647,42 +1647,42 @@ discard block |
||
| 1647 | 1647 | |
| 1648 | 1648 | $wpi_checkout_id = $invoice->ID; |
| 1649 | 1649 | |
| 1650 | - do_action( 'wpinv_pre_process_checkout' ); |
|
| 1650 | + do_action('wpinv_pre_process_checkout'); |
|
| 1651 | 1651 | |
| 1652 | - if ( !wpinv_get_cart_contents() ) { // Make sure the cart isn't empty |
|
| 1652 | + if (!wpinv_get_cart_contents()) { // Make sure the cart isn't empty |
|
| 1653 | 1653 | $valid_data = false; |
| 1654 | - wpinv_set_error( 'empty_cart', __( 'Your cart is empty', 'invoicing' ) ); |
|
| 1654 | + wpinv_set_error('empty_cart', __('Your cart is empty', 'invoicing')); |
|
| 1655 | 1655 | } else { |
| 1656 | 1656 | // Validate the form $_POST data |
| 1657 | 1657 | $valid_data = wpinv_validate_checkout_fields(); |
| 1658 | 1658 | |
| 1659 | 1659 | // Allow themes and plugins to hook to errors |
| 1660 | - do_action( 'wpinv_checkout_error_checks', $valid_data, $_POST ); |
|
| 1660 | + do_action('wpinv_checkout_error_checks', $valid_data, $_POST); |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 1663 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 1664 | 1664 | |
| 1665 | 1665 | // Validate the user |
| 1666 | - $user = wpinv_checkout_form_get_user( $valid_data ); |
|
| 1666 | + $user = wpinv_checkout_form_get_user($valid_data); |
|
| 1667 | 1667 | |
| 1668 | 1668 | // Let extensions validate fields after user is logged in if user has used login/registration form |
| 1669 | - do_action( 'wpinv_checkout_user_error_checks', $user, $valid_data, $_POST ); |
|
| 1669 | + do_action('wpinv_checkout_user_error_checks', $user, $valid_data, $_POST); |
|
| 1670 | 1670 | |
| 1671 | - if ( false === $valid_data || wpinv_get_errors() || ! $user ) { |
|
| 1672 | - if ( $is_ajax && 'wpinv_payment_form' != $_REQUEST['action'] ) { |
|
| 1673 | - do_action( 'wpinv_ajax_checkout_errors' ); |
|
| 1671 | + if (false === $valid_data || wpinv_get_errors() || !$user) { |
|
| 1672 | + if ($is_ajax && 'wpinv_payment_form' != $_REQUEST['action']) { |
|
| 1673 | + do_action('wpinv_ajax_checkout_errors'); |
|
| 1674 | 1674 | die(); |
| 1675 | 1675 | } else { |
| 1676 | 1676 | return false; |
| 1677 | 1677 | } |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | - if ( $is_ajax && 'wpinv_payment_form' != $_REQUEST['action'] ) { |
|
| 1680 | + if ($is_ajax && 'wpinv_payment_form' != $_REQUEST['action']) { |
|
| 1681 | 1681 | // Save address fields. |
| 1682 | - $address_fields = array( 'first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company' ); |
|
| 1683 | - foreach ( $address_fields as $field ) { |
|
| 1684 | - if ( isset( $user[$field] ) ) { |
|
| 1685 | - $invoice->set( $field, $user[$field] ); |
|
| 1682 | + $address_fields = array('first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company'); |
|
| 1683 | + foreach ($address_fields as $field) { |
|
| 1684 | + if (isset($user[$field])) { |
|
| 1685 | + $invoice->set($field, $user[$field]); |
|
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | 1688 | $invoice->save(); |
@@ -1690,16 +1690,16 @@ discard block |
||
| 1690 | 1690 | |
| 1691 | 1691 | $response['success'] = true; |
| 1692 | 1692 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 1693 | - $response['data']['subtotalf'] = $invoice->get_subtotal( true ); |
|
| 1693 | + $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
|
| 1694 | 1694 | $response['data']['discount'] = $invoice->get_discount(); |
| 1695 | - $response['data']['discountf'] = $invoice->get_discount( true ); |
|
| 1695 | + $response['data']['discountf'] = $invoice->get_discount(true); |
|
| 1696 | 1696 | $response['data']['tax'] = $invoice->get_tax(); |
| 1697 | - $response['data']['taxf'] = $invoice->get_tax( true ); |
|
| 1697 | + $response['data']['taxf'] = $invoice->get_tax(true); |
|
| 1698 | 1698 | $response['data']['total'] = $invoice->get_total(); |
| 1699 | - $response['data']['totalf'] = $invoice->get_total( true ); |
|
| 1700 | - $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
| 1699 | + $response['data']['totalf'] = $invoice->get_total(true); |
|
| 1700 | + $response['data']['free'] = $invoice->is_free() && (!((float) $response['data']['total'] > 0) || $invoice->is_free_trial()) ? true : false; |
|
| 1701 | 1701 | |
| 1702 | - wp_send_json( $response ); |
|
| 1702 | + wp_send_json($response); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | 1705 | $user_info = array( |
@@ -1721,42 +1721,42 @@ discard block |
||
| 1721 | 1721 | |
| 1722 | 1722 | // Setup invoice information |
| 1723 | 1723 | $invoice_data = array( |
| 1724 | - 'invoice_id' => !empty( $invoice ) ? $invoice->ID : 0, |
|
| 1724 | + 'invoice_id' => !empty($invoice) ? $invoice->ID : 0, |
|
| 1725 | 1725 | 'items' => $cart_items, |
| 1726 | 1726 | 'cart_discounts' => $discounts, |
| 1727 | - 'fees' => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart |
|
| 1728 | - 'subtotal' => wpinv_get_cart_subtotal( $cart_items ), // Amount before taxes and discounts |
|
| 1729 | - 'discount' => wpinv_get_cart_items_discount_amount( $cart_items, $discounts ), // Discounted amount |
|
| 1730 | - 'tax' => wpinv_get_cart_tax( $cart_items, $invoice ), // Taxed amount |
|
| 1731 | - 'price' => wpinv_get_cart_total( $cart_items, $discounts ), // Amount after taxes |
|
| 1727 | + 'fees' => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart |
|
| 1728 | + 'subtotal' => wpinv_get_cart_subtotal($cart_items), // Amount before taxes and discounts |
|
| 1729 | + 'discount' => wpinv_get_cart_items_discount_amount($cart_items, $discounts), // Discounted amount |
|
| 1730 | + 'tax' => wpinv_get_cart_tax($cart_items, $invoice), // Taxed amount |
|
| 1731 | + 'price' => wpinv_get_cart_total($cart_items, $discounts), // Amount after taxes |
|
| 1732 | 1732 | 'invoice_key' => $invoice->get_key() ? $invoice->get_key() : $invoice->generate_key(), |
| 1733 | 1733 | 'user_email' => $invoice->get_email(), |
| 1734 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 1735 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 1734 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 1735 | + 'user_info' => stripslashes_deep($user_info), |
|
| 1736 | 1736 | 'post_data' => $_POST, |
| 1737 | 1737 | 'cart_details' => $cart_items, |
| 1738 | 1738 | 'gateway' => $valid_data['gateway'], |
| 1739 | 1739 | 'card_info' => $valid_data['cc_info'] |
| 1740 | 1740 | ); |
| 1741 | 1741 | |
| 1742 | - $vat_info = $wpinv_euvat->current_vat_data(); |
|
| 1743 | - if ( is_array( $vat_info ) ) { |
|
| 1742 | + $vat_info = $wpinv_euvat->current_vat_data(); |
|
| 1743 | + if (is_array($vat_info)) { |
|
| 1744 | 1744 | $invoice_data['user_info']['vat_number'] = $vat_info['number']; |
| 1745 | 1745 | $invoice_data['user_info']['vat_rate'] = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state']); |
| 1746 | - $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
| 1746 | + $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
| 1747 | 1747 | |
| 1748 | 1748 | // Add the VAT rate to each item in the cart |
| 1749 | - foreach( $invoice_data['cart_details'] as $key => $item_data) { |
|
| 1749 | + foreach ($invoice_data['cart_details'] as $key => $item_data) { |
|
| 1750 | 1750 | $rate = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state'], $item_data['id']); |
| 1751 | - $invoice_data['cart_details'][$key]['vat_rate'] = wpinv_round_amount( $rate, 4 ); |
|
| 1751 | + $invoice_data['cart_details'][$key]['vat_rate'] = wpinv_round_amount($rate, 4); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | 1755 | // Save vat fields. |
| 1756 | - $address_fields = array( 'vat_number', 'vat_rate', 'adddress_confirmed' ); |
|
| 1757 | - foreach ( $address_fields as $field ) { |
|
| 1758 | - if ( isset( $invoice_data['user_info'][$field] ) ) { |
|
| 1759 | - $invoice->set( $field, $invoice_data['user_info'][$field] ); |
|
| 1756 | + $address_fields = array('vat_number', 'vat_rate', 'adddress_confirmed'); |
|
| 1757 | + foreach ($address_fields as $field) { |
|
| 1758 | + if (isset($invoice_data['user_info'][$field])) { |
|
| 1759 | + $invoice->set($field, $invoice_data['user_info'][$field]); |
|
| 1760 | 1760 | } |
| 1761 | 1761 | } |
| 1762 | 1762 | $invoice->save(); |
@@ -1765,54 +1765,54 @@ discard block |
||
| 1765 | 1765 | $valid_data['user'] = $user; |
| 1766 | 1766 | |
| 1767 | 1767 | // Allow themes and plugins to hook before the gateway |
| 1768 | - do_action( 'wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
| 1768 | + do_action('wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
| 1769 | 1769 | |
| 1770 | 1770 | // If it is free, abort. |
| 1771 | - if ( $invoice->is_free() && ( ! $invoice->is_recurring() || 0 == $invoice->get_recurring_details( 'total' ) ) ) { |
|
| 1771 | + if ($invoice->is_free() && (!$invoice->is_recurring() || 0 == $invoice->get_recurring_details('total'))) { |
|
| 1772 | 1772 | $invoice_data['gateway'] = 'manual'; |
| 1773 | 1773 | $_POST['wpi-gateway'] = 'manual'; |
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | 1776 | // Allow the invoice data to be modified before it is sent to the gateway |
| 1777 | - $invoice_data = apply_filters( 'wpinv_data_before_gateway', $invoice_data, $valid_data ); |
|
| 1777 | + $invoice_data = apply_filters('wpinv_data_before_gateway', $invoice_data, $valid_data); |
|
| 1778 | 1778 | |
| 1779 | - if ( $invoice_data['price'] && $invoice_data['gateway'] == 'manual' ) { |
|
| 1779 | + if ($invoice_data['price'] && $invoice_data['gateway'] == 'manual') { |
|
| 1780 | 1780 | $mode = 'test'; |
| 1781 | 1781 | } else { |
| 1782 | - $mode = wpinv_is_test_mode( $invoice_data['gateway'] ) ? 'test' : 'live'; |
|
| 1782 | + $mode = wpinv_is_test_mode($invoice_data['gateway']) ? 'test' : 'live'; |
|
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | 1785 | // Setup the data we're storing in the purchase session |
| 1786 | 1786 | $session_data = $invoice_data; |
| 1787 | 1787 | // Make sure credit card numbers are never stored in sessions |
| 1788 | - if ( !empty( $session_data['card_info']['card_number'] ) ) { |
|
| 1789 | - unset( $session_data['card_info']['card_number'] ); |
|
| 1788 | + if (!empty($session_data['card_info']['card_number'])) { |
|
| 1789 | + unset($session_data['card_info']['card_number']); |
|
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | 1792 | // Used for showing item links to non logged-in users after purchase, and for other plugins needing purchase data. |
| 1793 | - wpinv_set_checkout_session( $invoice_data ); |
|
| 1793 | + wpinv_set_checkout_session($invoice_data); |
|
| 1794 | 1794 | |
| 1795 | 1795 | // Set gateway |
| 1796 | - $invoice->update_meta( '_wpinv_gateway', $invoice_data['gateway'] ); |
|
| 1797 | - $invoice->update_meta( '_wpinv_mode', $mode ); |
|
| 1798 | - $invoice->update_meta( '_wpinv_checkout', date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) ); |
|
| 1796 | + $invoice->update_meta('_wpinv_gateway', $invoice_data['gateway']); |
|
| 1797 | + $invoice->update_meta('_wpinv_mode', $mode); |
|
| 1798 | + $invoice->update_meta('_wpinv_checkout', date_i18n('Y-m-d H:i:s', current_time('timestamp'))); |
|
| 1799 | 1799 | |
| 1800 | - do_action( 'wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data ); |
|
| 1800 | + do_action('wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data); |
|
| 1801 | 1801 | |
| 1802 | 1802 | // Send info to the gateway for payment processing |
| 1803 | - wpinv_send_to_gateway( $invoice_data['gateway'], $invoice_data ); |
|
| 1803 | + wpinv_send_to_gateway($invoice_data['gateway'], $invoice_data); |
|
| 1804 | 1804 | die(); |
| 1805 | 1805 | } |
| 1806 | -add_action( 'wpinv_payment', 'wpinv_process_checkout' ); |
|
| 1806 | +add_action('wpinv_payment', 'wpinv_process_checkout'); |
|
| 1807 | 1807 | |
| 1808 | -function wpinv_get_invoices( $args ) { |
|
| 1809 | - $args = wp_parse_args( $args, array( |
|
| 1810 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 1808 | +function wpinv_get_invoices($args) { |
|
| 1809 | + $args = wp_parse_args($args, array( |
|
| 1810 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 1811 | 1811 | 'type' => 'wpi_invoice', |
| 1812 | 1812 | 'parent' => null, |
| 1813 | 1813 | 'user' => null, |
| 1814 | 1814 | 'email' => '', |
| 1815 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 1815 | + 'limit' => get_option('posts_per_page'), |
|
| 1816 | 1816 | 'offset' => null, |
| 1817 | 1817 | 'page' => 1, |
| 1818 | 1818 | 'exclude' => array(), |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | 'order' => 'DESC', |
| 1821 | 1821 | 'return' => 'objects', |
| 1822 | 1822 | 'paginate' => false, |
| 1823 | - ) ); |
|
| 1823 | + )); |
|
| 1824 | 1824 | |
| 1825 | 1825 | // Handle some BW compatibility arg names where wp_query args differ in naming. |
| 1826 | 1826 | $map_legacy = array( |
@@ -1833,18 +1833,18 @@ discard block |
||
| 1833 | 1833 | 'paged' => 'page', |
| 1834 | 1834 | ); |
| 1835 | 1835 | |
| 1836 | - foreach ( $map_legacy as $from => $to ) { |
|
| 1837 | - if ( isset( $args[ $from ] ) ) { |
|
| 1838 | - $args[ $to ] = $args[ $from ]; |
|
| 1836 | + foreach ($map_legacy as $from => $to) { |
|
| 1837 | + if (isset($args[$from])) { |
|
| 1838 | + $args[$to] = $args[$from]; |
|
| 1839 | 1839 | } |
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | - if ( get_query_var( 'paged' ) ) |
|
| 1842 | + if (get_query_var('paged')) |
|
| 1843 | 1843 | $args['page'] = get_query_var('paged'); |
| 1844 | - else if ( get_query_var( 'page' ) ) |
|
| 1845 | - $args['page'] = get_query_var( 'page' ); |
|
| 1846 | - else if ( !empty( $args[ 'page' ] ) ) |
|
| 1847 | - $args['page'] = $args[ 'page' ]; |
|
| 1844 | + else if (get_query_var('page')) |
|
| 1845 | + $args['page'] = get_query_var('page'); |
|
| 1846 | + else if (!empty($args['page'])) |
|
| 1847 | + $args['page'] = $args['page']; |
|
| 1848 | 1848 | else |
| 1849 | 1849 | $args['page'] = 1; |
| 1850 | 1850 | |
@@ -1857,48 +1857,48 @@ discard block |
||
| 1857 | 1857 | 'post_status' => $args['status'], |
| 1858 | 1858 | 'posts_per_page' => $args['limit'], |
| 1859 | 1859 | 'meta_query' => array(), |
| 1860 | - 'date_query' => !empty( $args['date_query'] ) ? $args['date_query'] : array(), |
|
| 1860 | + 'date_query' => !empty($args['date_query']) ? $args['date_query'] : array(), |
|
| 1861 | 1861 | 'fields' => 'ids', |
| 1862 | 1862 | 'orderby' => $args['orderby'], |
| 1863 | 1863 | 'order' => $args['order'], |
| 1864 | 1864 | ); |
| 1865 | 1865 | |
| 1866 | - if ( !empty( $args['user'] ) ) { |
|
| 1867 | - $wp_query_args['author'] = absint( $args['user'] ); |
|
| 1866 | + if (!empty($args['user'])) { |
|
| 1867 | + $wp_query_args['author'] = absint($args['user']); |
|
| 1868 | 1868 | } |
| 1869 | 1869 | |
| 1870 | - if ( ! is_null( $args['parent'] ) ) { |
|
| 1871 | - $wp_query_args['post_parent'] = absint( $args['parent'] ); |
|
| 1870 | + if (!is_null($args['parent'])) { |
|
| 1871 | + $wp_query_args['post_parent'] = absint($args['parent']); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | - if ( ! is_null( $args['offset'] ) ) { |
|
| 1875 | - $wp_query_args['offset'] = absint( $args['offset'] ); |
|
| 1874 | + if (!is_null($args['offset'])) { |
|
| 1875 | + $wp_query_args['offset'] = absint($args['offset']); |
|
| 1876 | 1876 | } else { |
| 1877 | - $wp_query_args['paged'] = absint( $args['page'] ); |
|
| 1877 | + $wp_query_args['paged'] = absint($args['page']); |
|
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - if ( ! empty( $args['exclude'] ) ) { |
|
| 1881 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
| 1880 | + if (!empty($args['exclude'])) { |
|
| 1881 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | - if ( ! $args['paginate' ] ) { |
|
| 1884 | + if (!$args['paginate']) { |
|
| 1885 | 1885 | $wp_query_args['no_found_rows'] = true; |
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | $wp_query_args = apply_filters('wpinv_get_invoices_args', $wp_query_args, $args); |
| 1889 | 1889 | |
| 1890 | 1890 | // Get results. |
| 1891 | - $invoices = new WP_Query( $wp_query_args ); |
|
| 1891 | + $invoices = new WP_Query($wp_query_args); |
|
| 1892 | 1892 | |
| 1893 | - if ( 'objects' === $args['return'] ) { |
|
| 1894 | - $return = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 1895 | - } elseif ( 'self' === $args['return'] ) { |
|
| 1893 | + if ('objects' === $args['return']) { |
|
| 1894 | + $return = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 1895 | + } elseif ('self' === $args['return']) { |
|
| 1896 | 1896 | return $invoices; |
| 1897 | 1897 | } else { |
| 1898 | 1898 | $return = $invoices->posts; |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | - if ( $args['paginate' ] ) { |
|
| 1901 | + if ($args['paginate']) { |
|
| 1902 | 1902 | return (object) array( |
| 1903 | 1903 | 'invoices' => $return, |
| 1904 | 1904 | 'total' => $invoices->found_posts, |
@@ -1911,22 +1911,22 @@ discard block |
||
| 1911 | 1911 | |
| 1912 | 1912 | function wpinv_get_user_invoices_columns() { |
| 1913 | 1913 | $columns = array( |
| 1914 | - 'invoice-number' => array( 'title' => __( 'ID', 'invoicing' ), 'class' => 'text-left' ), |
|
| 1915 | - 'created-date' => array( 'title' => __( 'Created Date', 'invoicing' ), 'class' => 'text-left' ), |
|
| 1916 | - 'payment-date' => array( 'title' => __( 'Payment Date', 'invoicing' ), 'class' => 'text-left' ), |
|
| 1917 | - 'invoice-status' => array( 'title' => __( 'Status', 'invoicing' ), 'class' => 'text-center' ), |
|
| 1918 | - 'invoice-total' => array( 'title' => __( 'Total', 'invoicing' ), 'class' => 'text-right' ), |
|
| 1919 | - 'invoice-actions' => array( 'title' => ' ', 'class' => 'text-center' ), |
|
| 1914 | + 'invoice-number' => array('title' => __('ID', 'invoicing'), 'class' => 'text-left'), |
|
| 1915 | + 'created-date' => array('title' => __('Created Date', 'invoicing'), 'class' => 'text-left'), |
|
| 1916 | + 'payment-date' => array('title' => __('Payment Date', 'invoicing'), 'class' => 'text-left'), |
|
| 1917 | + 'invoice-status' => array('title' => __('Status', 'invoicing'), 'class' => 'text-center'), |
|
| 1918 | + 'invoice-total' => array('title' => __('Total', 'invoicing'), 'class' => 'text-right'), |
|
| 1919 | + 'invoice-actions' => array('title' => ' ', 'class' => 'text-center'), |
|
| 1920 | 1920 | ); |
| 1921 | 1921 | |
| 1922 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
| 1922 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | -function wpinv_payment_receipt( $atts, $content = null ) { |
|
| 1925 | +function wpinv_payment_receipt($atts, $content = null) { |
|
| 1926 | 1926 | global $wpinv_receipt_args; |
| 1927 | 1927 | |
| 1928 | - $wpinv_receipt_args = shortcode_atts( array( |
|
| 1929 | - 'error' => __( 'Sorry, trouble retrieving payment receipt.', 'invoicing' ), |
|
| 1928 | + $wpinv_receipt_args = shortcode_atts(array( |
|
| 1929 | + 'error' => __('Sorry, trouble retrieving payment receipt.', 'invoicing'), |
|
| 1930 | 1930 | 'price' => true, |
| 1931 | 1931 | 'discount' => true, |
| 1932 | 1932 | 'items' => true, |
@@ -1935,45 +1935,45 @@ discard block |
||
| 1935 | 1935 | 'invoice_key' => false, |
| 1936 | 1936 | 'payment_method' => true, |
| 1937 | 1937 | 'invoice_id' => true |
| 1938 | - ), $atts, 'wpinv_receipt' ); |
|
| 1938 | + ), $atts, 'wpinv_receipt'); |
|
| 1939 | 1939 | |
| 1940 | 1940 | // Find the invoice. |
| 1941 | 1941 | $session = wpinv_get_checkout_session(); |
| 1942 | 1942 | |
| 1943 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
| 1944 | - $invoice_id = wpinv_get_invoice_id_by_key( urldecode( $_GET['invoice_key'] ) ); |
|
| 1945 | - } else if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1943 | + if (isset($_GET['invoice_key'])) { |
|
| 1944 | + $invoice_id = wpinv_get_invoice_id_by_key(urldecode($_GET['invoice_key'])); |
|
| 1945 | + } else if (isset($_GET['invoice-id'])) { |
|
| 1946 | 1946 | $invoice_id = (int) $_GET['invoice-id']; |
| 1947 | - } else if ( $session && isset( $session['invoice_key'] ) ) { |
|
| 1948 | - $invoice_id = wpinv_get_invoice_id_by_key( $session['invoice_key'] ); |
|
| 1949 | - } else if ( isset( $wpinv_receipt_args['invoice_key'] ) && $wpinv_receipt_args['invoice_key'] ) { |
|
| 1950 | - $invoice_id = wpinv_get_invoice_id_by_key( $wpinv_receipt_args['invoice_key'] ); |
|
| 1947 | + } else if ($session && isset($session['invoice_key'])) { |
|
| 1948 | + $invoice_id = wpinv_get_invoice_id_by_key($session['invoice_key']); |
|
| 1949 | + } else if (isset($wpinv_receipt_args['invoice_key']) && $wpinv_receipt_args['invoice_key']) { |
|
| 1950 | + $invoice_id = wpinv_get_invoice_id_by_key($wpinv_receipt_args['invoice_key']); |
|
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | 1953 | // Did we find the invoice? |
| 1954 | - if ( empty( $invoice_id ) || ! $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 1955 | - return '<p class="alert alert-error">' . __( 'We could not find your invoice.', 'invoicing' ) . '</p>'; |
|
| 1954 | + if (empty($invoice_id) || !$invoice = wpinv_get_invoice($invoice_id)) { |
|
| 1955 | + return '<p class="alert alert-error">' . __('We could not find your invoice.', 'invoicing') . '</p>'; |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | $invoice_key = $invoice->get_key(); |
| 1959 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
| 1960 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
| 1961 | - $user_can_view = $_GET['invoice-id'] == $invoice->ID; |
|
| 1959 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
| 1960 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
| 1961 | + $user_can_view = $_GET['invoice-id'] == $invoice->ID; |
|
| 1962 | 1962 | } |
| 1963 | 1963 | |
| 1964 | 1964 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt |
| 1965 | - if ( ! $user_can_view && ! empty( $invoice_key ) && ! is_user_logged_in() ) { |
|
| 1965 | + if (!$user_can_view && !empty($invoice_key) && !is_user_logged_in()) { |
|
| 1966 | 1966 | // login redirect |
| 1967 | - return '<p class="alert alert-error">' . __( 'You must be logged in to view this receipt', 'invoicing' ) . '</p>'; |
|
| 1967 | + return '<p class="alert alert-error">' . __('You must be logged in to view this receipt', 'invoicing') . '</p>'; |
|
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | - if ( ! apply_filters( 'wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args ) ) { |
|
| 1970 | + if (!apply_filters('wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args)) { |
|
| 1971 | 1971 | return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>'; |
| 1972 | 1972 | } |
| 1973 | 1973 | |
| 1974 | 1974 | ob_start(); |
| 1975 | 1975 | |
| 1976 | - wpinv_get_template_part( 'wpinv-invoice-receipt' ); |
|
| 1976 | + wpinv_get_template_part('wpinv-invoice-receipt'); |
|
| 1977 | 1977 | |
| 1978 | 1978 | $display = ob_get_clean(); |
| 1979 | 1979 | |
@@ -1983,148 +1983,148 @@ discard block |
||
| 1983 | 1983 | /** |
| 1984 | 1984 | * Given an invoice key, this function returns the id. |
| 1985 | 1985 | */ |
| 1986 | -function wpinv_get_invoice_id_by_key( $key ) { |
|
| 1986 | +function wpinv_get_invoice_id_by_key($key) { |
|
| 1987 | 1987 | global $wpdb; |
| 1988 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 1989 | - return (int) $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $table WHERE`key` = %s LIMIT 1", $key ) ); |
|
| 1988 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 1989 | + return (int) $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $table WHERE`key` = %s LIMIT 1", $key)); |
|
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | -function wpinv_can_view_receipt( $invoice_key = '' ) { |
|
| 1993 | - $return = current_user_can( 'manage_options' ); |
|
| 1992 | +function wpinv_can_view_receipt($invoice_key = '') { |
|
| 1993 | + $return = current_user_can('manage_options'); |
|
| 1994 | 1994 | |
| 1995 | - if ( empty( $invoice_key ) ) { |
|
| 1995 | + if (empty($invoice_key)) { |
|
| 1996 | 1996 | return false; |
| 1997 | 1997 | } |
| 1998 | 1998 | |
| 1999 | 1999 | global $wpinv_receipt_args; |
| 2000 | 2000 | |
| 2001 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 2002 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
| 2003 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 2001 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 2002 | + if (isset($_GET['invoice-id'])) { |
|
| 2003 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key((int) $_GET['invoice-id']) ? (int) $_GET['invoice-id'] : 0; |
|
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 2006 | + if (empty($wpinv_receipt_args['id'])) { |
|
| 2007 | 2007 | return $return; |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 2011 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 2010 | + $invoice = wpinv_get_invoice($wpinv_receipt_args['id']); |
|
| 2011 | + if (!(!empty($invoice->ID) && $invoice->get_key() === $invoice_key)) { |
|
| 2012 | 2012 | return $return; |
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | - if ( is_user_logged_in() ) { |
|
| 2016 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 2015 | + if (is_user_logged_in()) { |
|
| 2016 | + if ((int) $invoice->get_user_id() === (int) get_current_user_id()) { |
|
| 2017 | 2017 | $return = true; |
| 2018 | 2018 | } |
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | $session = wpinv_get_checkout_session(); |
| 2022 | - if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 2023 | - $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 2022 | + if (isset($_GET['invoice_key']) || ($session && isset($session['invoice_key']))) { |
|
| 2023 | + $check_key = isset($_GET['invoice_key']) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 2024 | 2024 | |
| 2025 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2025 | + if (wpinv_require_login_to_checkout()) { |
|
| 2026 | 2026 | $return = $return && $check_key == $invoice_key; |
| 2027 | 2027 | } else { |
| 2028 | 2028 | $return = $check_key == $invoice_key; |
| 2029 | 2029 | } |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 2032 | + return (bool) apply_filters('wpinv_can_view_receipt', $return, $invoice_key); |
|
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | 2035 | function wpinv_pay_for_invoice() { |
| 2036 | 2036 | global $wpinv_euvat; |
| 2037 | 2037 | |
| 2038 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
| 2038 | + if (isset($_GET['invoice_key'])) { |
|
| 2039 | 2039 | $checkout_uri = wpinv_get_checkout_uri(); |
| 2040 | - $invoice_key = sanitize_text_field( $_GET['invoice_key'] ); |
|
| 2040 | + $invoice_key = sanitize_text_field($_GET['invoice_key']); |
|
| 2041 | 2041 | |
| 2042 | - if ( empty( $invoice_key ) ) { |
|
| 2043 | - wpinv_set_error( 'invalid_invoice', __( 'Invoice not found', 'invoicing' ) ); |
|
| 2044 | - wp_redirect( $checkout_uri ); |
|
| 2042 | + if (empty($invoice_key)) { |
|
| 2043 | + wpinv_set_error('invalid_invoice', __('Invoice not found', 'invoicing')); |
|
| 2044 | + wp_redirect($checkout_uri); |
|
| 2045 | 2045 | exit(); |
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | - do_action( 'wpinv_check_pay_for_invoice', $invoice_key ); |
|
| 2048 | + do_action('wpinv_check_pay_for_invoice', $invoice_key); |
|
| 2049 | 2049 | |
| 2050 | - $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 2051 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
| 2052 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
| 2053 | - $invoice_id = (int)$_GET['invoice-id']; |
|
| 2054 | - $user_can_view = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false; |
|
| 2050 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 2051 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
| 2052 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
| 2053 | + $invoice_id = (int) $_GET['invoice-id']; |
|
| 2054 | + $user_can_view = $invoice_key == wpinv_get_payment_key((int) $_GET['invoice-id']) ? true : false; |
|
| 2055 | 2055 | } |
| 2056 | 2056 | |
| 2057 | - if ( $invoice_id && $user_can_view && ( $invoice = wpinv_get_invoice( $invoice_id ) ) ) { |
|
| 2058 | - if ( $invoice->needs_payment() ) { |
|
| 2057 | + if ($invoice_id && $user_can_view && ($invoice = wpinv_get_invoice($invoice_id))) { |
|
| 2058 | + if ($invoice->needs_payment()) { |
|
| 2059 | 2059 | $data = array(); |
| 2060 | 2060 | $data['invoice_id'] = $invoice_id; |
| 2061 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 2061 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 2062 | 2062 | |
| 2063 | - wpinv_set_checkout_session( $data ); |
|
| 2063 | + wpinv_set_checkout_session($data); |
|
| 2064 | 2064 | |
| 2065 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
| 2065 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
| 2066 | 2066 | $_POST['country'] = $wpinv_euvat->get_country_by_ip(); |
| 2067 | 2067 | $_POST['state'] = $_POST['country'] == $invoice->country ? $invoice->state : ''; |
| 2068 | 2068 | |
| 2069 | - wpinv_recalculate_tax( true ); |
|
| 2069 | + wpinv_recalculate_tax(true); |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | } else { |
| 2073 | 2073 | $checkout_uri = $invoice->get_view_url(); |
| 2074 | 2074 | } |
| 2075 | 2075 | } else { |
| 2076 | - wpinv_set_error( 'invalid_invoice', __( 'You are not allowed to view this invoice', 'invoicing' ) ); |
|
| 2076 | + wpinv_set_error('invalid_invoice', __('You are not allowed to view this invoice', 'invoicing')); |
|
| 2077 | 2077 | |
| 2078 | - $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
| 2078 | + $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | - if(wp_redirect( $checkout_uri )){ |
|
| 2081 | + if (wp_redirect($checkout_uri)) { |
|
| 2082 | 2082 | exit; |
| 2083 | 2083 | }; |
| 2084 | 2084 | wpinv_die(); |
| 2085 | 2085 | } |
| 2086 | 2086 | } |
| 2087 | -add_action( 'wpinv_pay_for_invoice', 'wpinv_pay_for_invoice' ); |
|
| 2087 | +add_action('wpinv_pay_for_invoice', 'wpinv_pay_for_invoice'); |
|
| 2088 | 2088 | |
| 2089 | -function wpinv_handle_pay_via_invoice_link( $invoice_key ) { |
|
| 2090 | - if ( !empty( $invoice_key ) && !empty( $_REQUEST['_wpipay'] ) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ) ) { |
|
| 2091 | - if ( $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 2089 | +function wpinv_handle_pay_via_invoice_link($invoice_key) { |
|
| 2090 | + if (!empty($invoice_key) && !empty($_REQUEST['_wpipay']) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key($invoice_key)) { |
|
| 2091 | + if ($invoice = wpinv_get_invoice($invoice_id)) { |
|
| 2092 | 2092 | $user_id = $invoice->get_user_id(); |
| 2093 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
| 2093 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
| 2094 | 2094 | |
| 2095 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice_key ) ) { // valid invoice link |
|
| 2096 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
| 2095 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice_key)) { // valid invoice link |
|
| 2096 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
| 2097 | 2097 | |
| 2098 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
| 2098 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
| 2099 | 2099 | exit(); |
| 2100 | 2100 | } |
| 2101 | 2101 | } |
| 2102 | 2102 | } |
| 2103 | 2103 | } |
| 2104 | -add_action( 'wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link' ); |
|
| 2104 | +add_action('wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link'); |
|
| 2105 | 2105 | |
| 2106 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
| 2107 | - $invoice_id = is_object( $invoice_id ) && !empty( $invoice_id->ID ) ? $invoice_id : $invoice_id; |
|
| 2106 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
| 2107 | + $invoice_id = is_object($invoice_id) && !empty($invoice_id->ID) ? $invoice_id : $invoice_id; |
|
| 2108 | 2108 | |
| 2109 | - if ( empty( $invoice_id ) && $invoice_id > 0 ) { |
|
| 2109 | + if (empty($invoice_id) && $invoice_id > 0) { |
|
| 2110 | 2110 | return false; |
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | - if ( empty( $transaction_id ) ) { |
|
| 2113 | + if (empty($transaction_id)) { |
|
| 2114 | 2114 | $transaction_id = $invoice_id; |
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | - $transaction_id = apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice_id ); |
|
| 2117 | + $transaction_id = apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice_id); |
|
| 2118 | 2118 | |
| 2119 | - return wpinv_update_invoice_meta( $invoice_id, '_wpinv_transaction_id', $transaction_id ); |
|
| 2119 | + return wpinv_update_invoice_meta($invoice_id, '_wpinv_transaction_id', $transaction_id); |
|
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
| 2123 | - if ( empty( $status_display ) ) { |
|
| 2124 | - $status_display = wpinv_status_nicename( $status ); |
|
| 2122 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
| 2123 | + if (empty($status_display)) { |
|
| 2124 | + $status_display = wpinv_status_nicename($status); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | - switch ( $status ) { |
|
| 2127 | + switch ($status) { |
|
| 2128 | 2128 | case 'publish' : |
| 2129 | 2129 | case 'wpi-renewal' : |
| 2130 | 2130 | $class = 'label-success'; |
@@ -2149,201 +2149,201 @@ discard block |
||
| 2149 | 2149 | |
| 2150 | 2150 | $label = '<span class="label label-inv-' . $status . ' ' . $class . '">' . $status_display . '</span>'; |
| 2151 | 2151 | |
| 2152 | - return apply_filters( 'wpinv_invoice_status_label', $label, $status, $status_display ); |
|
| 2152 | + return apply_filters('wpinv_invoice_status_label', $label, $status, $status_display); |
|
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
| 2156 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
| 2157 | - if ( null !== $check ) { |
|
| 2155 | +function wpinv_format_invoice_number($number, $type = '') { |
|
| 2156 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
| 2157 | + if (null !== $check) { |
|
| 2158 | 2158 | return $check; |
| 2159 | 2159 | } |
| 2160 | 2160 | |
| 2161 | - if ( !empty( $number ) && !is_numeric( $number ) ) { |
|
| 2161 | + if (!empty($number) && !is_numeric($number)) { |
|
| 2162 | 2162 | return $number; |
| 2163 | 2163 | } |
| 2164 | 2164 | |
| 2165 | - $padd = wpinv_get_option( 'invoice_number_padd' ); |
|
| 2166 | - $prefix = wpinv_get_option( 'invoice_number_prefix' ); |
|
| 2167 | - $postfix = wpinv_get_option( 'invoice_number_postfix' ); |
|
| 2165 | + $padd = wpinv_get_option('invoice_number_padd'); |
|
| 2166 | + $prefix = wpinv_get_option('invoice_number_prefix'); |
|
| 2167 | + $postfix = wpinv_get_option('invoice_number_postfix'); |
|
| 2168 | 2168 | |
| 2169 | - $padd = absint( $padd ); |
|
| 2170 | - $formatted_number = absint( $number ); |
|
| 2169 | + $padd = absint($padd); |
|
| 2170 | + $formatted_number = absint($number); |
|
| 2171 | 2171 | |
| 2172 | - if ( $padd > 0 ) { |
|
| 2173 | - $formatted_number = zeroise( $formatted_number, $padd ); |
|
| 2172 | + if ($padd > 0) { |
|
| 2173 | + $formatted_number = zeroise($formatted_number, $padd); |
|
| 2174 | 2174 | } |
| 2175 | 2175 | |
| 2176 | 2176 | $formatted_number = $prefix . $formatted_number . $postfix; |
| 2177 | 2177 | |
| 2178 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
| 2178 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
| 2182 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
| 2183 | - if ( null !== $check ) { |
|
| 2181 | +function wpinv_get_next_invoice_number($type = '') { |
|
| 2182 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
| 2183 | + if (null !== $check) { |
|
| 2184 | 2184 | return $check; |
| 2185 | 2185 | } |
| 2186 | 2186 | |
| 2187 | - if ( !wpinv_sequential_number_active() ) { |
|
| 2187 | + if (!wpinv_sequential_number_active()) { |
|
| 2188 | 2188 | return false; |
| 2189 | 2189 | } |
| 2190 | 2190 | |
| 2191 | - $number = $last_number = get_option( 'wpinv_last_invoice_number', 0 ); |
|
| 2192 | - $start = wpinv_get_option( 'invoice_sequence_start', 1 ); |
|
| 2193 | - if ( !absint( $start ) > 0 ) { |
|
| 2191 | + $number = $last_number = get_option('wpinv_last_invoice_number', 0); |
|
| 2192 | + $start = wpinv_get_option('invoice_sequence_start', 1); |
|
| 2193 | + if (!absint($start) > 0) { |
|
| 2194 | 2194 | $start = 1; |
| 2195 | 2195 | } |
| 2196 | 2196 | $increment_number = true; |
| 2197 | 2197 | $save_number = false; |
| 2198 | 2198 | |
| 2199 | - if ( !empty( $number ) && !is_numeric( $number ) && $number == wpinv_format_invoice_number( $number ) ) { |
|
| 2200 | - $number = wpinv_clean_invoice_number( $number ); |
|
| 2199 | + if (!empty($number) && !is_numeric($number) && $number == wpinv_format_invoice_number($number)) { |
|
| 2200 | + $number = wpinv_clean_invoice_number($number); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | - if ( empty( $number ) ) { |
|
| 2204 | - if ( !( $last_number === 0 || $last_number === '0' ) ) { |
|
| 2205 | - $last_invoice = wpinv_get_invoices( array( 'limit' => 1, 'order' => 'DESC', 'orderby' => 'ID', 'return' => 'posts', 'fields' => 'ids', 'status' => array_keys( wpinv_get_invoice_statuses( true, true ) ) ) ); |
|
| 2203 | + if (empty($number)) { |
|
| 2204 | + if (!($last_number === 0 || $last_number === '0')) { |
|
| 2205 | + $last_invoice = wpinv_get_invoices(array('limit' => 1, 'order' => 'DESC', 'orderby' => 'ID', 'return' => 'posts', 'fields' => 'ids', 'status' => array_keys(wpinv_get_invoice_statuses(true, true)))); |
|
| 2206 | 2206 | |
| 2207 | - if ( !empty( $last_invoice[0] ) && $invoice_number = wpinv_get_invoice_number( $last_invoice[0] ) ) { |
|
| 2208 | - if ( is_numeric( $invoice_number ) ) { |
|
| 2207 | + if (!empty($last_invoice[0]) && $invoice_number = wpinv_get_invoice_number($last_invoice[0])) { |
|
| 2208 | + if (is_numeric($invoice_number)) { |
|
| 2209 | 2209 | $number = $invoice_number; |
| 2210 | 2210 | } else { |
| 2211 | - $number = wpinv_clean_invoice_number( $invoice_number ); |
|
| 2211 | + $number = wpinv_clean_invoice_number($invoice_number); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | - if ( empty( $number ) ) { |
|
| 2215 | + if (empty($number)) { |
|
| 2216 | 2216 | $increment_number = false; |
| 2217 | 2217 | $number = $start; |
| 2218 | - $save_number = ( $number - 1 ); |
|
| 2218 | + $save_number = ($number - 1); |
|
| 2219 | 2219 | } else { |
| 2220 | 2220 | $save_number = $number; |
| 2221 | 2221 | } |
| 2222 | 2222 | } |
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | - if ( $start > $number ) { |
|
| 2225 | + if ($start > $number) { |
|
| 2226 | 2226 | $increment_number = false; |
| 2227 | 2227 | $number = $start; |
| 2228 | - $save_number = ( $number - 1 ); |
|
| 2228 | + $save_number = ($number - 1); |
|
| 2229 | 2229 | } |
| 2230 | 2230 | |
| 2231 | - if ( $save_number !== false ) { |
|
| 2232 | - update_option( 'wpinv_last_invoice_number', $save_number ); |
|
| 2231 | + if ($save_number !== false) { |
|
| 2232 | + update_option('wpinv_last_invoice_number', $save_number); |
|
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | - $increment_number = apply_filters( 'wpinv_increment_payment_number', $increment_number, $number ); |
|
| 2235 | + $increment_number = apply_filters('wpinv_increment_payment_number', $increment_number, $number); |
|
| 2236 | 2236 | |
| 2237 | - if ( $increment_number ) { |
|
| 2237 | + if ($increment_number) { |
|
| 2238 | 2238 | $number++; |
| 2239 | 2239 | } |
| 2240 | 2240 | |
| 2241 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
| 2241 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | -function wpinv_clean_invoice_number( $number, $type = '' ) { |
|
| 2245 | - $check = apply_filters( 'wpinv_pre_clean_invoice_number', null, $number, $type ); |
|
| 2246 | - if ( null !== $check ) { |
|
| 2244 | +function wpinv_clean_invoice_number($number, $type = '') { |
|
| 2245 | + $check = apply_filters('wpinv_pre_clean_invoice_number', null, $number, $type); |
|
| 2246 | + if (null !== $check) { |
|
| 2247 | 2247 | return $check; |
| 2248 | 2248 | } |
| 2249 | 2249 | |
| 2250 | - $prefix = wpinv_get_option( 'invoice_number_prefix' ); |
|
| 2251 | - $postfix = wpinv_get_option( 'invoice_number_postfix' ); |
|
| 2250 | + $prefix = wpinv_get_option('invoice_number_prefix'); |
|
| 2251 | + $postfix = wpinv_get_option('invoice_number_postfix'); |
|
| 2252 | 2252 | |
| 2253 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
| 2253 | + $number = preg_replace('/' . $prefix . '/', '', $number, 1); |
|
| 2254 | 2254 | |
| 2255 | - $length = strlen( $number ); |
|
| 2256 | - $postfix_pos = strrpos( $number, $postfix ); |
|
| 2255 | + $length = strlen($number); |
|
| 2256 | + $postfix_pos = strrpos($number, $postfix); |
|
| 2257 | 2257 | |
| 2258 | - if ( false !== $postfix_pos ) { |
|
| 2259 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
| 2258 | + if (false !== $postfix_pos) { |
|
| 2259 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
| 2260 | 2260 | } |
| 2261 | 2261 | |
| 2262 | - $number = intval( $number ); |
|
| 2262 | + $number = intval($number); |
|
| 2263 | 2263 | |
| 2264 | - return apply_filters( 'wpinv_clean_invoice_number', $number, $prefix, $postfix ); |
|
| 2264 | + return apply_filters('wpinv_clean_invoice_number', $number, $prefix, $postfix); |
|
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | -function wpinv_save_number_post_saved( $post_ID, $post, $update ) { |
|
| 2267 | +function wpinv_save_number_post_saved($post_ID, $post, $update) { |
|
| 2268 | 2268 | global $wpdb; |
| 2269 | 2269 | |
| 2270 | - if ( !$update && !get_post_meta( $post_ID, '_wpinv_number', true ) ) { |
|
| 2271 | - wpinv_update_invoice_number( $post_ID, $post->post_status != 'auto-draft', $post->post_type ); |
|
| 2270 | + if (!$update && !get_post_meta($post_ID, '_wpinv_number', true)) { |
|
| 2271 | + wpinv_update_invoice_number($post_ID, $post->post_status != 'auto-draft', $post->post_type); |
|
| 2272 | 2272 | } |
| 2273 | 2273 | |
| 2274 | - if ( !$update ) { |
|
| 2275 | - $wpdb->update( $wpdb->posts, array( 'post_name' => wpinv_generate_post_name( $post_ID ) ), array( 'ID' => $post_ID ) ); |
|
| 2276 | - clean_post_cache( $post_ID ); |
|
| 2274 | + if (!$update) { |
|
| 2275 | + $wpdb->update($wpdb->posts, array('post_name' => wpinv_generate_post_name($post_ID)), array('ID' => $post_ID)); |
|
| 2276 | + clean_post_cache($post_ID); |
|
| 2277 | 2277 | } |
| 2278 | 2278 | } |
| 2279 | -add_action( 'save_post_wpi_invoice', 'wpinv_save_number_post_saved', 1, 3 ); |
|
| 2279 | +add_action('save_post_wpi_invoice', 'wpinv_save_number_post_saved', 1, 3); |
|
| 2280 | 2280 | |
| 2281 | -function wpinv_save_number_post_updated( $post_ID, $post_after, $post_before ) { |
|
| 2282 | - if ( !empty( $post_after->post_type ) && $post_after->post_type == 'wpi_invoice' && $post_before->post_status == 'auto-draft' && $post_after->post_status != $post_before->post_status ) { |
|
| 2283 | - wpinv_update_invoice_number( $post_ID, true, $post_after->post_type ); |
|
| 2281 | +function wpinv_save_number_post_updated($post_ID, $post_after, $post_before) { |
|
| 2282 | + if (!empty($post_after->post_type) && $post_after->post_type == 'wpi_invoice' && $post_before->post_status == 'auto-draft' && $post_after->post_status != $post_before->post_status) { |
|
| 2283 | + wpinv_update_invoice_number($post_ID, true, $post_after->post_type); |
|
| 2284 | 2284 | } |
| 2285 | 2285 | } |
| 2286 | -add_action( 'post_updated', 'wpinv_save_number_post_updated', 1, 3 ); |
|
| 2286 | +add_action('post_updated', 'wpinv_save_number_post_updated', 1, 3); |
|
| 2287 | 2287 | |
| 2288 | -function wpinv_update_invoice_number( $post_ID, $save_sequential = false, $type = '' ) { |
|
| 2288 | +function wpinv_update_invoice_number($post_ID, $save_sequential = false, $type = '') { |
|
| 2289 | 2289 | global $wpdb; |
| 2290 | 2290 | |
| 2291 | - $check = apply_filters( 'wpinv_pre_update_invoice_number', null, $post_ID, $save_sequential, $type ); |
|
| 2292 | - if ( null !== $check ) { |
|
| 2291 | + $check = apply_filters('wpinv_pre_update_invoice_number', null, $post_ID, $save_sequential, $type); |
|
| 2292 | + if (null !== $check) { |
|
| 2293 | 2293 | return $check; |
| 2294 | 2294 | } |
| 2295 | 2295 | |
| 2296 | - if ( wpinv_sequential_number_active() ) { |
|
| 2296 | + if (wpinv_sequential_number_active()) { |
|
| 2297 | 2297 | $number = wpinv_get_next_invoice_number(); |
| 2298 | 2298 | |
| 2299 | - if ( $save_sequential ) { |
|
| 2300 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
| 2299 | + if ($save_sequential) { |
|
| 2300 | + update_option('wpinv_last_invoice_number', $number); |
|
| 2301 | 2301 | } |
| 2302 | 2302 | } else { |
| 2303 | 2303 | $number = $post_ID; |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | - $number = wpinv_format_invoice_number( $number ); |
|
| 2306 | + $number = wpinv_format_invoice_number($number); |
|
| 2307 | 2307 | |
| 2308 | - update_post_meta( $post_ID, '_wpinv_number', $number ); |
|
| 2308 | + update_post_meta($post_ID, '_wpinv_number', $number); |
|
| 2309 | 2309 | |
| 2310 | - $wpdb->update( $wpdb->posts, array( 'post_title' => $number ), array( 'ID' => $post_ID ) ); |
|
| 2310 | + $wpdb->update($wpdb->posts, array('post_title' => $number), array('ID' => $post_ID)); |
|
| 2311 | 2311 | |
| 2312 | - clean_post_cache( $post_ID ); |
|
| 2312 | + clean_post_cache($post_ID); |
|
| 2313 | 2313 | |
| 2314 | 2314 | return $number; |
| 2315 | 2315 | } |
| 2316 | 2316 | |
| 2317 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
| 2318 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
| 2317 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
| 2318 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | -function wpinv_generate_post_name( $post_ID ) { |
|
| 2322 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
| 2323 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
| 2321 | +function wpinv_generate_post_name($post_ID) { |
|
| 2322 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
| 2323 | + $post_name = sanitize_title($prefix . $post_ID); |
|
| 2324 | 2324 | |
| 2325 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
| 2325 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
| 2326 | 2326 | } |
| 2327 | 2327 | |
| 2328 | -function wpinv_is_invoice_viewed( $invoice_id ) { |
|
| 2329 | - if ( empty( $invoice_id ) ) { |
|
| 2328 | +function wpinv_is_invoice_viewed($invoice_id) { |
|
| 2329 | + if (empty($invoice_id)) { |
|
| 2330 | 2330 | return false; |
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | - $viewed_meta = get_post_meta( $invoice_id, '_wpinv_is_viewed', true ); |
|
| 2333 | + $viewed_meta = get_post_meta($invoice_id, '_wpinv_is_viewed', true); |
|
| 2334 | 2334 | |
| 2335 | - return apply_filters( 'wpinv_is_invoice_viewed', 1 === (int)$viewed_meta, $invoice_id ); |
|
| 2335 | + return apply_filters('wpinv_is_invoice_viewed', 1 === (int) $viewed_meta, $invoice_id); |
|
| 2336 | 2336 | } |
| 2337 | 2337 | |
| 2338 | 2338 | function wpinv_mark_invoice_viewed() { |
| 2339 | 2339 | |
| 2340 | - if ( isset( $_GET['invoice_key'] ) || is_singular( 'wpi_invoice' ) || is_singular( 'wpi_quote' ) ) { |
|
| 2341 | - $invoice_key = isset( $_GET['invoice_key'] ) ? urldecode($_GET['invoice_key']) : ''; |
|
| 2340 | + if (isset($_GET['invoice_key']) || is_singular('wpi_invoice') || is_singular('wpi_quote')) { |
|
| 2341 | + $invoice_key = isset($_GET['invoice_key']) ? urldecode($_GET['invoice_key']) : ''; |
|
| 2342 | 2342 | global $post; |
| 2343 | 2343 | |
| 2344 | - if(!empty($invoice_key)){ |
|
| 2344 | + if (!empty($invoice_key)) { |
|
| 2345 | 2345 | $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
| 2346 | - } else if(!empty( $post ) && ($post->post_type == 'wpi_invoice' || $post->post_type == 'wpi_quote')) { |
|
| 2346 | + } else if (!empty($post) && ($post->post_type == 'wpi_invoice' || $post->post_type == 'wpi_quote')) { |
|
| 2347 | 2347 | $invoice_id = $post->ID; |
| 2348 | 2348 | } else { |
| 2349 | 2349 | return; |
@@ -2351,73 +2351,73 @@ discard block |
||
| 2351 | 2351 | |
| 2352 | 2352 | $invoice = new WPInv_Invoice($invoice_id); |
| 2353 | 2353 | |
| 2354 | - if(!$invoice_id){ |
|
| 2354 | + if (!$invoice_id) { |
|
| 2355 | 2355 | return; |
| 2356 | 2356 | } |
| 2357 | 2357 | |
| 2358 | - if ( is_user_logged_in() ) { |
|
| 2359 | - if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
| 2360 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2361 | - } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2362 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2358 | + if (is_user_logged_in()) { |
|
| 2359 | + if ((int) $invoice->get_user_id() === get_current_user_id()) { |
|
| 2360 | + update_post_meta($invoice_id, '_wpinv_is_viewed', 1); |
|
| 2361 | + } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2362 | + update_post_meta($invoice_id, '_wpinv_is_viewed', 1); |
|
| 2363 | 2363 | } |
| 2364 | 2364 | } else { |
| 2365 | - if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2366 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2365 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2366 | + update_post_meta($invoice_id, '_wpinv_is_viewed', 1); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | } |
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | 2371 | } |
| 2372 | -add_action( 'template_redirect', 'wpinv_mark_invoice_viewed' ); |
|
| 2372 | +add_action('template_redirect', 'wpinv_mark_invoice_viewed'); |
|
| 2373 | 2373 | |
| 2374 | 2374 | /** |
| 2375 | 2375 | * Fetch a subscription given an invoice. |
| 2376 | 2376 | * |
| 2377 | 2377 | * @return WPInv_Subscription|bool |
| 2378 | 2378 | */ |
| 2379 | -function wpinv_get_subscription( $invoice ) { |
|
| 2379 | +function wpinv_get_subscription($invoice) { |
|
| 2380 | 2380 | |
| 2381 | 2381 | // Abort if we do not have an invoice. |
| 2382 | - if ( empty( $invoice ) ) { |
|
| 2382 | + if (empty($invoice)) { |
|
| 2383 | 2383 | return false; |
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | 2386 | // Retrieve the invoice. |
| 2387 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 2387 | + $invoice = new WPInv_Invoice($invoice); |
|
| 2388 | 2388 | |
| 2389 | 2389 | // Ensure it is a recurring invoice. |
| 2390 | - if ( ! $invoice->is_recurring() ) { |
|
| 2390 | + if (!$invoice->is_recurring()) { |
|
| 2391 | 2391 | return false; |
| 2392 | 2392 | } |
| 2393 | 2393 | |
| 2394 | 2394 | // Fetch the subscription handler. |
| 2395 | - $subs_db = new WPInv_Subscriptions_DB(); |
|
| 2395 | + $subs_db = new WPInv_Subscriptions_DB(); |
|
| 2396 | 2396 | |
| 2397 | 2397 | // Fetch the parent in case it is a renewal. |
| 2398 | - if ( $invoice->is_renewal() ) { |
|
| 2399 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->get_parent_id(), 'number' => 1 ) ); |
|
| 2398 | + if ($invoice->is_renewal()) { |
|
| 2399 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->get_parent_id(), 'number' => 1)); |
|
| 2400 | 2400 | } else { |
| 2401 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->get_id(), 'number' => 1 ) ); |
|
| 2401 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->get_id(), 'number' => 1)); |
|
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | 2404 | // Return the subscription if it exists. |
| 2405 | - if ( ! empty( $subs ) ) { |
|
| 2406 | - return reset( $subs ); |
|
| 2405 | + if (!empty($subs)) { |
|
| 2406 | + return reset($subs); |
|
| 2407 | 2407 | } |
| 2408 | 2408 | |
| 2409 | 2409 | return false; |
| 2410 | 2410 | } |
| 2411 | 2411 | |
| 2412 | -function wpinv_filter_posts_clauses( $clauses, $wp_query ) { |
|
| 2412 | +function wpinv_filter_posts_clauses($clauses, $wp_query) { |
|
| 2413 | 2413 | global $wpdb; |
| 2414 | 2414 | |
| 2415 | - if ( ! empty( $wp_query->query_vars['orderby'] ) && $wp_query->query_vars['orderby'] == 'invoice_date' ) { |
|
| 2416 | - if ( !empty( $clauses['join'] ) ) { |
|
| 2415 | + if (!empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'invoice_date') { |
|
| 2416 | + if (!empty($clauses['join'])) { |
|
| 2417 | 2417 | $clauses['join'] .= " "; |
| 2418 | 2418 | } |
| 2419 | 2419 | |
| 2420 | - if ( !empty( $clauses['fields'] ) ) { |
|
| 2420 | + if (!empty($clauses['fields'])) { |
|
| 2421 | 2421 | $clauses['fields'] .= ", "; |
| 2422 | 2422 | } |
| 2423 | 2423 | |
@@ -2428,7 +2428,7 @@ discard block |
||
| 2428 | 2428 | |
| 2429 | 2429 | return $clauses; |
| 2430 | 2430 | } |
| 2431 | -add_filter( 'posts_clauses', 'wpinv_filter_posts_clauses', 10, 2 ); |
|
| 2431 | +add_filter('posts_clauses', 'wpinv_filter_posts_clauses', 10, 2); |
|
| 2432 | 2432 | |
| 2433 | 2433 | /** |
| 2434 | 2434 | * Processes an invoice refund. |
@@ -2438,27 +2438,27 @@ discard block |
||
| 2438 | 2438 | * @param array $status_transition |
| 2439 | 2439 | * @todo: descrease customer/store earnings |
| 2440 | 2440 | */ |
| 2441 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
| 2441 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
| 2442 | 2442 | |
| 2443 | - if ( empty( $status_transition['from'] ) || ! $invoice->has_status( 'wpi-refunded' ) || in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
| 2443 | + if (empty($status_transition['from']) || !$invoice->has_status('wpi-refunded') || in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
| 2444 | 2444 | return; |
| 2445 | 2445 | } |
| 2446 | 2446 | |
| 2447 | 2447 | $discount_code = $invoice->get_discount_code(); |
| 2448 | - if ( ! empty( $discount_code ) ) { |
|
| 2449 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 2448 | + if (!empty($discount_code)) { |
|
| 2449 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 2450 | 2450 | |
| 2451 | - if ( $discount->exists() ) { |
|
| 2451 | + if ($discount->exists()) { |
|
| 2452 | 2452 | $discount->increase_usage( -1 ); |
| 2453 | 2453 | } |
| 2454 | 2454 | |
| 2455 | 2455 | } |
| 2456 | 2456 | |
| 2457 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
| 2458 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
| 2459 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
| 2457 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
| 2458 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
| 2459 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
| 2460 | 2460 | } |
| 2461 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
| 2461 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
| 2462 | 2462 | |
| 2463 | 2463 | /** |
| 2464 | 2464 | * Fires when a payment fails. |
@@ -2466,22 +2466,22 @@ discard block |
||
| 2466 | 2466 | * @param int $invoice_id |
| 2467 | 2467 | * @param WPInv_Invoice $invoice |
| 2468 | 2468 | */ |
| 2469 | -function getpaid_maybe_process_failure( $invoice_id, $invoice ) { |
|
| 2469 | +function getpaid_maybe_process_failure($invoice_id, $invoice) { |
|
| 2470 | 2470 | |
| 2471 | - if ( ! $invoice->has_status( 'wpi-failed' ) ) { |
|
| 2471 | + if (!$invoice->has_status('wpi-failed')) { |
|
| 2472 | 2472 | return; |
| 2473 | 2473 | } |
| 2474 | 2474 | |
| 2475 | 2475 | $discount_code = $invoice->get_discount_code(); |
| 2476 | - if ( ! empty( $discount_code ) ) { |
|
| 2477 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 2476 | + if (!empty($discount_code)) { |
|
| 2477 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 2478 | 2478 | |
| 2479 | - if ( $discount->exists() ) { |
|
| 2479 | + if ($discount->exists()) { |
|
| 2480 | 2480 | $discount->increase_usage( -1 ); |
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | - do_action( 'wpinv_invoice_payment_failed', $invoice, $invoice_id ); |
|
| 2485 | + do_action('wpinv_invoice_payment_failed', $invoice, $invoice_id); |
|
| 2486 | 2486 | } |
| 2487 | -add_action( 'getpaid_invoice_status_wpi-failed', 'getpaid_maybe_process_failure', 10, 2 ); |
|
| 2488 | 2487 | \ No newline at end of file |
| 2488 | +add_action('getpaid_invoice_status_wpi-failed', 'getpaid_maybe_process_failure', 10, 2); |
|
| 2489 | 2489 | \ No newline at end of file |
@@ -7,86 +7,86 @@ 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 | function wpinv_item_quantities_enabled() { |
| 15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
| 15 | + $ret = wpinv_get_option('item_quantities', true); |
|
| 16 | 16 | |
| 17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
| 17 | + return (bool) apply_filters('wpinv_item_quantities_enabled', $ret); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function wpinv_get_ip() { |
| 21 | 21 | $ip = '127.0.0.1'; |
| 22 | 22 | |
| 23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
| 25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
| 27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
| 25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
| 28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
| 31 | + return apply_filters('wpinv_get_ip', $ip); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function wpinv_get_user_agent() { |
| 35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
| 37 | 37 | } else { |
| 38 | 38 | $user_agent = ''; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
| 41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
| 44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
| 45 | 45 | $is_negative = false; |
| 46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
| 47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
| 48 | - if ( $decimals === NULL ) { |
|
| 48 | + if ($decimals === NULL) { |
|
| 49 | 49 | $decimals = wpinv_decimals(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Sanitize the amount |
| 53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
| 57 | - $amount = str_replace( '.', '', $amount ); |
|
| 53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
| 54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
| 57 | + $amount = str_replace('.', '', $amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
| 61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
| 61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if( $amount < 0 ) { |
|
| 65 | + if ($amount < 0) { |
|
| 66 | 66 | $is_negative = true; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
| 69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
| 70 | 70 | |
| 71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
| 72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
| 71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
| 72 | + $amount = number_format((double) $amount, absint($decimals), '.', ''); |
|
| 73 | 73 | |
| 74 | - if( $is_negative ) { |
|
| 74 | + if ($is_negative) { |
|
| 75 | 75 | $amount *= -1; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
| 78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
| 79 | 79 | } |
| 80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 81 | 81 | |
| 82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
| 83 | - if ( $decimals === NULL ) { |
|
| 82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
| 83 | + if ($decimals === NULL) { |
|
| 84 | 84 | $decimals = wpinv_decimals(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
| 87 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
| 89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,48 +95,48 @@ discard block |
||
| 95 | 95 | * @since 1.0.19 |
| 96 | 96 | * @return array |
| 97 | 97 | */ |
| 98 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
| 98 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
| 99 | 99 | $invoice_statuses = array( |
| 100 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 101 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
| 102 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 103 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 104 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 105 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 106 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 107 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
| 100 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
| 101 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
| 102 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
| 103 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
| 104 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
| 105 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
| 106 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
| 107 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - if ( $draft ) { |
|
| 111 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
| 110 | + if ($draft) { |
|
| 111 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( $trashed ) { |
|
| 115 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
| 114 | + if ($trashed) { |
|
| 115 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 118 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -function wpinv_status_nicename( $status ) { |
|
| 122 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
| 123 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
| 121 | +function wpinv_status_nicename($status) { |
|
| 122 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
| 123 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
| 124 | 124 | |
| 125 | 125 | return $status; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | function wpinv_get_currency() { |
| 129 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
| 129 | + $currency = wpinv_get_option('currency', 'USD'); |
|
| 130 | 130 | |
| 131 | - return apply_filters( 'wpinv_currency', $currency ); |
|
| 131 | + return apply_filters('wpinv_currency', $currency); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -function wpinv_currency_symbol( $currency = '' ) { |
|
| 135 | - if ( empty( $currency ) ) { |
|
| 134 | +function wpinv_currency_symbol($currency = '') { |
|
| 135 | + if (empty($currency)) { |
|
| 136 | 136 | $currency = wpinv_get_currency(); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
| 139 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
| 140 | 140 | 'AED' => 'د.إ', |
| 141 | 141 | 'AFN' => '؋', |
| 142 | 142 | 'ALL' => 'L', |
@@ -299,209 +299,209 @@ discard block |
||
| 299 | 299 | 'YER' => '﷼', |
| 300 | 300 | 'ZAR' => 'R', |
| 301 | 301 | 'ZMW' => 'ZK', |
| 302 | - ) ); |
|
| 302 | + )); |
|
| 303 | 303 | |
| 304 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 304 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 305 | 305 | |
| 306 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 306 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | function wpinv_currency_position() { |
| 310 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 310 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 311 | 311 | |
| 312 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 312 | + return apply_filters('wpinv_currency_position', $position); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | function wpinv_thousands_separator() { |
| 316 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 316 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
| 317 | 317 | |
| 318 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
| 318 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | function wpinv_decimal_separator() { |
| 322 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 322 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
| 323 | 323 | |
| 324 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
| 324 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | function wpinv_decimals() { |
| 328 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
| 328 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
| 329 | 329 | |
| 330 | - return absint( $decimals ); |
|
| 330 | + return absint($decimals); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | function wpinv_get_currencies() { |
| 334 | 334 | $currencies = array( |
| 335 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
| 336 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
| 337 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
| 338 | - 'AED' => __( 'United Arab Emirates', 'invoicing' ), |
|
| 339 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
| 340 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
| 341 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
| 342 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
| 343 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
| 344 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
| 345 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
| 346 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
| 347 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
| 348 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
| 349 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
| 350 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
| 351 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
| 352 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
| 353 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
| 354 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
| 355 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
| 356 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
| 357 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
| 358 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
| 359 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
| 360 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
| 361 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
| 362 | - 'BYN' => __( 'Belarusian Ruble', 'invoicing' ), |
|
| 363 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
| 364 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
| 365 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
| 366 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
| 367 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
| 368 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
| 369 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
| 370 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
| 371 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
| 372 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
| 373 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
| 374 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
| 375 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
| 376 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
| 377 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
| 378 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
| 379 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
| 380 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
| 381 | - 'ETB' => __( 'Ethiopian Irr', 'invoicing' ), |
|
| 382 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
| 383 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
| 384 | - 'GEL' => __( 'Georgian Lari', 'invoicing' ), |
|
| 385 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
| 386 | - 'GHS' => __( 'Ghana Cedi', 'invoicing' ), |
|
| 387 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
| 388 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
| 389 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
| 390 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
| 391 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
| 392 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
| 393 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
| 394 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
| 395 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
| 396 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
| 397 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
| 398 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
| 399 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
| 400 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
| 401 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
| 402 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
| 403 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
| 404 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
| 405 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
| 406 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
| 407 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
| 408 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
| 409 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
| 410 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
| 411 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
| 412 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
| 413 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
| 414 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
| 415 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
| 416 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
| 417 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
| 418 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
| 419 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
| 420 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
| 421 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
| 422 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
| 423 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
| 424 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
| 425 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
| 426 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
| 427 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
| 428 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
| 429 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
| 430 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
| 431 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
| 432 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
| 433 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
| 434 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
| 435 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
| 436 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
| 437 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
| 438 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
| 439 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
| 440 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
| 441 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
| 442 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
| 443 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
| 444 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
| 445 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
| 446 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
| 447 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
| 448 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
| 449 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
| 450 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
| 451 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
| 452 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
| 453 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
| 454 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
| 455 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
| 456 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
| 457 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
| 458 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
| 459 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
| 460 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
| 461 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
| 462 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
| 463 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
| 464 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
| 465 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
| 466 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
| 467 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
| 468 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
| 469 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
| 470 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
| 471 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
| 472 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
| 473 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
| 474 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
| 475 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
| 476 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
| 477 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
| 478 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
| 479 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
| 480 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
| 481 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
| 482 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
| 483 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
| 484 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
| 485 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
| 486 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
| 487 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
| 488 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
| 489 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
| 490 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
| 491 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
| 492 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
| 493 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
| 494 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
| 495 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
| 335 | + 'USD' => __('US Dollar', 'invoicing'), |
|
| 336 | + 'EUR' => __('Euro', 'invoicing'), |
|
| 337 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
| 338 | + 'AED' => __('United Arab Emirates', 'invoicing'), |
|
| 339 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
| 340 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
| 341 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
| 342 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
| 343 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
| 344 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
| 345 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
| 346 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
| 347 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
| 348 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
| 349 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
| 350 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
| 351 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
| 352 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
| 353 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
| 354 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
| 355 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
| 356 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
| 357 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
| 358 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
| 359 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
| 360 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
| 361 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
| 362 | + 'BYN' => __('Belarusian Ruble', 'invoicing'), |
|
| 363 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
| 364 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
| 365 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
| 366 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
| 367 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
| 368 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
| 369 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
| 370 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
| 371 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
| 372 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
| 373 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
| 374 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
| 375 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
| 376 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
| 377 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
| 378 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
| 379 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
| 380 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
| 381 | + 'ETB' => __('Ethiopian Irr', 'invoicing'), |
|
| 382 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
| 383 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
| 384 | + 'GEL' => __('Georgian Lari', 'invoicing'), |
|
| 385 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
| 386 | + 'GHS' => __('Ghana Cedi', 'invoicing'), |
|
| 387 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
| 388 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
| 389 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
| 390 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
| 391 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
| 392 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
| 393 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
| 394 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
| 395 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
| 396 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
| 397 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
| 398 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
| 399 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
| 400 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
| 401 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
| 402 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
| 403 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
| 404 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
| 405 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
| 406 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
| 407 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
| 408 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
| 409 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
| 410 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
| 411 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
| 412 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
| 413 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
| 414 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
| 415 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
| 416 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
| 417 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
| 418 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
| 419 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
| 420 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
| 421 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
| 422 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
| 423 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
| 424 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
| 425 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
| 426 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
| 427 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
| 428 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
| 429 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
| 430 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
| 431 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
| 432 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
| 433 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
| 434 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
| 435 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
| 436 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
| 437 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
| 438 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
| 439 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
| 440 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
| 441 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
| 442 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
| 443 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
| 444 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
| 445 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
| 446 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
| 447 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
| 448 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
| 449 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
| 450 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
| 451 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
| 452 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
| 453 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
| 454 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
| 455 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
| 456 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
| 457 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
| 458 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
| 459 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
| 460 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
| 461 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
| 462 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
| 463 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
| 464 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
| 465 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
| 466 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
| 467 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
| 468 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
| 469 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
| 470 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
| 471 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
| 472 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
| 473 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
| 474 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
| 475 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
| 476 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
| 477 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
| 478 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
| 479 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
| 480 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
| 481 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
| 482 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
| 483 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
| 484 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
| 485 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
| 486 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
| 487 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
| 488 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
| 489 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
| 490 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
| 491 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
| 492 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
| 493 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
| 494 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
| 495 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
| 496 | 496 | ); |
| 497 | 497 | |
| 498 | 498 | //asort( $currencies ); // this |
| 499 | 499 | |
| 500 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
| 500 | + return apply_filters('wpinv_currencies', $currencies); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
| 504 | - if( empty( $currency ) ) { |
|
| 503 | +function wpinv_price($amount = '', $currency = '') { |
|
| 504 | + if (empty($currency)) { |
|
| 505 | 505 | $currency = wpinv_get_currency(); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -509,14 +509,14 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | $negative = $amount < 0; |
| 511 | 511 | |
| 512 | - if ( $negative ) { |
|
| 513 | - $amount = substr( $amount, 1 ); |
|
| 512 | + if ($negative) { |
|
| 513 | + $amount = substr($amount, 1); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - $symbol = wpinv_currency_symbol( $currency ); |
|
| 516 | + $symbol = wpinv_currency_symbol($currency); |
|
| 517 | 517 | |
| 518 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
| 519 | - switch ( $currency ) { |
|
| 518 | + if ($position == 'left' || $position == 'left_space') { |
|
| 519 | + switch ($currency) { |
|
| 520 | 520 | case "GBP" : |
| 521 | 521 | case "BRL" : |
| 522 | 522 | case "EUR" : |
@@ -528,15 +528,15 @@ discard block |
||
| 528 | 528 | case "NZD" : |
| 529 | 529 | case "SGD" : |
| 530 | 530 | case "JPY" : |
| 531 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 531 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 532 | 532 | break; |
| 533 | 533 | default : |
| 534 | 534 | //$price = $currency . ' ' . $amount; |
| 535 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 535 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 536 | 536 | break; |
| 537 | 537 | } |
| 538 | 538 | } else { |
| 539 | - switch ( $currency ) { |
|
| 539 | + switch ($currency) { |
|
| 540 | 540 | case "GBP" : |
| 541 | 541 | case "BRL" : |
| 542 | 542 | case "EUR" : |
@@ -547,83 +547,83 @@ discard block |
||
| 547 | 547 | case "MXN" : |
| 548 | 548 | case "SGD" : |
| 549 | 549 | case "JPY" : |
| 550 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 550 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 551 | 551 | break; |
| 552 | 552 | default : |
| 553 | 553 | //$price = $amount . ' ' . $currency; |
| 554 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 554 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 555 | 555 | break; |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - if ( $negative ) { |
|
| 559 | + if ($negative) { |
|
| 560 | 560 | $price = '-' . $price; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
| 563 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
| 564 | 564 | |
| 565 | 565 | return $price; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
| 568 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
| 569 | 569 | $thousands_sep = wpinv_thousands_separator(); |
| 570 | 570 | $decimal_sep = wpinv_decimal_separator(); |
| 571 | 571 | |
| 572 | - if ( $decimals === NULL ) { |
|
| 572 | + if ($decimals === NULL) { |
|
| 573 | 573 | $decimals = wpinv_decimals(); |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 577 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 578 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 576 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 577 | + $whole = substr($amount, 0, $sep_found); |
|
| 578 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 579 | 579 | $amount = $whole . '.' . $part; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 583 | - $amount = str_replace( ',', '', $amount ); |
|
| 582 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 583 | + $amount = str_replace(',', '', $amount); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 587 | - $amount = str_replace( ' ', '', $amount ); |
|
| 586 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 587 | + $amount = str_replace(' ', '', $amount); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - if ( empty( $amount ) ) { |
|
| 590 | + if (empty($amount)) { |
|
| 591 | 591 | $amount = 0; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
| 595 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 594 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
| 595 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 596 | 596 | |
| 597 | - if ( $calculate ) { |
|
| 598 | - if ( $thousands_sep === "," ) { |
|
| 599 | - $formatted = str_replace( ",", "", $formatted ); |
|
| 597 | + if ($calculate) { |
|
| 598 | + if ($thousands_sep === ",") { |
|
| 599 | + $formatted = str_replace(",", "", $formatted); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - if ( $decimal_sep === "," ) { |
|
| 603 | - $formatted = str_replace( ",", ".", $formatted ); |
|
| 602 | + if ($decimal_sep === ",") { |
|
| 603 | + $formatted = str_replace(",", ".", $formatted); |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
| 607 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
| 608 | 608 | } |
| 609 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 609 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 610 | 610 | |
| 611 | -function wpinv_sanitize_key( $key ) { |
|
| 611 | +function wpinv_sanitize_key($key) { |
|
| 612 | 612 | $raw_key = $key; |
| 613 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 613 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 614 | 614 | |
| 615 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 615 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | -function wpinv_get_file_extension( $str ) { |
|
| 619 | - $parts = explode( '.', $str ); |
|
| 620 | - return end( $parts ); |
|
| 618 | +function wpinv_get_file_extension($str) { |
|
| 619 | + $parts = explode('.', $str); |
|
| 620 | + return end($parts); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | -function wpinv_string_is_image_url( $str ) { |
|
| 624 | - $ext = wpinv_get_file_extension( $str ); |
|
| 623 | +function wpinv_string_is_image_url($str) { |
|
| 624 | + $ext = wpinv_get_file_extension($str); |
|
| 625 | 625 | |
| 626 | - switch ( strtolower( $ext ) ) { |
|
| 626 | + switch (strtolower($ext)) { |
|
| 627 | 627 | case 'jpeg'; |
| 628 | 628 | case 'jpg'; |
| 629 | 629 | $return = true; |
@@ -639,33 +639,33 @@ discard block |
||
| 639 | 639 | break; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
| 642 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 646 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
| 645 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 646 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
| 647 | 647 | |
| 648 | - if ( true === $should_log ) { |
|
| 648 | + if (true === $should_log) { |
|
| 649 | 649 | $label = ''; |
| 650 | - if ( $file && $file !== '' ) { |
|
| 651 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
| 650 | + if ($file && $file !== '') { |
|
| 651 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - if ( $title && $title !== '' ) { |
|
| 654 | + if ($title && $title !== '') { |
|
| 655 | 655 | $label = $label !== '' ? $label . ' ' : ''; |
| 656 | 656 | $label .= $title . ' '; |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
| 659 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
| 660 | 660 | |
| 661 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
| 662 | - error_log( $label . print_r( $log, true ) ); |
|
| 661 | + if (is_array($log) || is_object($log)) { |
|
| 662 | + error_log($label . print_r($log, true)); |
|
| 663 | 663 | } else { |
| 664 | - error_log( $label . $log ); |
|
| 664 | + error_log($label . $log); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - error_log( wp_debug_backtrace_summary() ); |
|
| 668 | - if ( $exit ) { |
|
| 667 | + error_log(wp_debug_backtrace_summary()); |
|
| 668 | + if ($exit) { |
|
| 669 | 669 | exit; |
| 670 | 670 | } |
| 671 | 671 | } |
@@ -673,32 +673,32 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | function wpinv_is_ajax_disabled() { |
| 675 | 675 | $retval = false; |
| 676 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
| 676 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
| 679 | +function wpinv_get_current_page_url($nocache = false) { |
|
| 680 | 680 | global $wp; |
| 681 | 681 | |
| 682 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 683 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 682 | + if (get_option('permalink_structure')) { |
|
| 683 | + $base = trailingslashit(home_url($wp->request)); |
|
| 684 | 684 | } else { |
| 685 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 686 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 685 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 686 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | $scheme = is_ssl() ? 'https' : 'http'; |
| 690 | - $uri = set_url_scheme( $base, $scheme ); |
|
| 690 | + $uri = set_url_scheme($base, $scheme); |
|
| 691 | 691 | |
| 692 | - if ( is_front_page() ) { |
|
| 693 | - $uri = home_url( '/' ); |
|
| 694 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
| 692 | + if (is_front_page()) { |
|
| 693 | + $uri = home_url('/'); |
|
| 694 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
| 695 | 695 | $uri = wpinv_get_checkout_uri(); |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
| 698 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
| 699 | 699 | |
| 700 | - if ( $nocache ) { |
|
| 701 | - $uri = wpinv_add_cache_busting( $uri ); |
|
| 700 | + if ($nocache) { |
|
| 701 | + $uri = wpinv_add_cache_busting($uri); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return $uri; |
@@ -711,46 +711,46 @@ discard block |
||
| 711 | 711 | * @param string $name Constant name. |
| 712 | 712 | * @param mixed $value Value. |
| 713 | 713 | */ |
| 714 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
| 715 | - if ( ! defined( $name ) ) { |
|
| 716 | - define( $name, $value ); |
|
| 714 | +function getpaid_maybe_define_constant($name, $value) { |
|
| 715 | + if (!defined($name)) { |
|
| 716 | + define($name, $value); |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | function wpinv_get_php_arg_separator_output() { |
| 721 | - return ini_get( 'arg_separator.output' ); |
|
| 721 | + return ini_get('arg_separator.output'); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | -function wpinv_rgb_from_hex( $color ) { |
|
| 725 | - $color = str_replace( '#', '', $color ); |
|
| 724 | +function wpinv_rgb_from_hex($color) { |
|
| 725 | + $color = str_replace('#', '', $color); |
|
| 726 | 726 | |
| 727 | 727 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 728 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 729 | - if ( empty( $color ) ) { |
|
| 728 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 729 | + if (empty($color)) { |
|
| 730 | 730 | return NULL; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - $color = str_split( $color ); |
|
| 733 | + $color = str_split($color); |
|
| 734 | 734 | |
| 735 | 735 | $rgb = array(); |
| 736 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
| 737 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
| 738 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
| 736 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
| 737 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
| 738 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
| 739 | 739 | |
| 740 | 740 | return $rgb; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 744 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 743 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 744 | + $base = wpinv_rgb_from_hex($color); |
|
| 745 | 745 | $color = '#'; |
| 746 | 746 | |
| 747 | - foreach ( $base as $k => $v ) { |
|
| 747 | + foreach ($base as $k => $v) { |
|
| 748 | 748 | $amount = $v / 100; |
| 749 | - $amount = round( $amount * $factor ); |
|
| 749 | + $amount = round($amount * $factor); |
|
| 750 | 750 | $new_decimal = $v - $amount; |
| 751 | 751 | |
| 752 | - $new_hex_component = dechex( $new_decimal ); |
|
| 753 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 752 | + $new_hex_component = dechex($new_decimal); |
|
| 753 | + if (strlen($new_hex_component) < 2) { |
|
| 754 | 754 | $new_hex_component = "0" . $new_hex_component; |
| 755 | 755 | } |
| 756 | 756 | $color .= $new_hex_component; |
@@ -759,18 +759,18 @@ discard block |
||
| 759 | 759 | return $color; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 763 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 762 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 763 | + $base = wpinv_rgb_from_hex($color); |
|
| 764 | 764 | $color = '#'; |
| 765 | 765 | |
| 766 | - foreach ( $base as $k => $v ) { |
|
| 766 | + foreach ($base as $k => $v) { |
|
| 767 | 767 | $amount = 255 - $v; |
| 768 | 768 | $amount = $amount / 100; |
| 769 | - $amount = round( $amount * $factor ); |
|
| 769 | + $amount = round($amount * $factor); |
|
| 770 | 770 | $new_decimal = $v + $amount; |
| 771 | 771 | |
| 772 | - $new_hex_component = dechex( $new_decimal ); |
|
| 773 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 772 | + $new_hex_component = dechex($new_decimal); |
|
| 773 | + if (strlen($new_hex_component) < 2) { |
|
| 774 | 774 | $new_hex_component = "0" . $new_hex_component; |
| 775 | 775 | } |
| 776 | 776 | $color .= $new_hex_component; |
@@ -779,22 +779,22 @@ discard block |
||
| 779 | 779 | return $color; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 783 | - $hex = str_replace( '#', '', $color ); |
|
| 782 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 783 | + $hex = str_replace('#', '', $color); |
|
| 784 | 784 | |
| 785 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 786 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 787 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 785 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 786 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 787 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 788 | 788 | |
| 789 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 789 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 790 | 790 | |
| 791 | 791 | return $brightness > 155 ? $dark : $light; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | -function wpinv_format_hex( $hex ) { |
|
| 795 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 794 | +function wpinv_format_hex($hex) { |
|
| 795 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 796 | 796 | |
| 797 | - if ( strlen( $hex ) == 3 ) { |
|
| 797 | + if (strlen($hex) == 3) { |
|
| 798 | 798 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 799 | 799 | } |
| 800 | 800 | |
@@ -814,12 +814,12 @@ discard block |
||
| 814 | 814 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 815 | 815 | * @return string |
| 816 | 816 | */ |
| 817 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 818 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 819 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 817 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 818 | + if (function_exists('mb_strimwidth')) { |
|
| 819 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 822 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
@@ -831,28 +831,28 @@ discard block |
||
| 831 | 831 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 832 | 832 | * @return int Returns the number of characters in string. |
| 833 | 833 | */ |
| 834 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 835 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 836 | - return mb_strlen( $str, $encoding ); |
|
| 834 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 835 | + if (function_exists('mb_strlen')) { |
|
| 836 | + return mb_strlen($str, $encoding); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - return strlen( $str ); |
|
| 839 | + return strlen($str); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 843 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 844 | - return mb_strtolower( $str, $encoding ); |
|
| 842 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 843 | + if (function_exists('mb_strtolower')) { |
|
| 844 | + return mb_strtolower($str, $encoding); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - return strtolower( $str ); |
|
| 847 | + return strtolower($str); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 851 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 852 | - return mb_strtoupper( $str, $encoding ); |
|
| 850 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 851 | + if (function_exists('mb_strtoupper')) { |
|
| 852 | + return mb_strtoupper($str, $encoding); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - return strtoupper( $str ); |
|
| 855 | + return strtoupper($str); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -866,12 +866,12 @@ discard block |
||
| 866 | 866 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 867 | 867 | * @return int Returns the position of the first occurrence of search in the string. |
| 868 | 868 | */ |
| 869 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 870 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 871 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 869 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 870 | + if (function_exists('mb_strpos')) { |
|
| 871 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - return strpos( $str, $find, $offset ); |
|
| 874 | + return strpos($str, $find, $offset); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | /** |
@@ -885,12 +885,12 @@ discard block |
||
| 885 | 885 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 886 | 886 | * @return int Returns the position of the last occurrence of search. |
| 887 | 887 | */ |
| 888 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 889 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 890 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 888 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 889 | + if (function_exists('mb_strrpos')) { |
|
| 890 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - return strrpos( $str, $find, $offset ); |
|
| 893 | + return strrpos($str, $find, $offset); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | /** |
@@ -905,16 +905,16 @@ discard block |
||
| 905 | 905 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 906 | 906 | * @return string |
| 907 | 907 | */ |
| 908 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 909 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 910 | - if ( $length === null ) { |
|
| 911 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 908 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 909 | + if (function_exists('mb_substr')) { |
|
| 910 | + if ($length === null) { |
|
| 911 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 912 | 912 | } else { |
| 913 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 913 | + return mb_substr($str, $start, $length, $encoding); |
|
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | - return substr( $str, $start, $length ); |
|
| 917 | + return substr($str, $start, $length); |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -926,48 +926,48 @@ discard block |
||
| 926 | 926 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 927 | 927 | * @return string The width of string. |
| 928 | 928 | */ |
| 929 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 930 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 931 | - return mb_strwidth( $str, $encoding ); |
|
| 929 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 930 | + if (function_exists('mb_strwidth')) { |
|
| 931 | + return mb_strwidth($str, $encoding); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 934 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 938 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 939 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 937 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 938 | + if (function_exists('mb_strlen')) { |
|
| 939 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 940 | 940 | $str_end = ""; |
| 941 | 941 | |
| 942 | - if ( $lower_str_end ) { |
|
| 943 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 942 | + if ($lower_str_end) { |
|
| 943 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 944 | 944 | } else { |
| 945 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 945 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | return $first_letter . $str_end; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - return ucfirst( $str ); |
|
| 951 | + return ucfirst($str); |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 955 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 956 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 954 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 955 | + if (function_exists('mb_convert_case')) { |
|
| 956 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - return ucwords( $str ); |
|
| 959 | + return ucwords($str); |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 963 | - $period = absint( $period ); |
|
| 962 | +function wpinv_period_in_days($period, $unit) { |
|
| 963 | + $period = absint($period); |
|
| 964 | 964 | |
| 965 | - if ( $period > 0 ) { |
|
| 966 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 965 | + if ($period > 0) { |
|
| 966 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 967 | 967 | $period = $period * 7; |
| 968 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 968 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 969 | 969 | $period = $period * 30; |
| 970 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 970 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 971 | 971 | $period = $period * 365; |
| 972 | 972 | } |
| 973 | 973 | } |
@@ -975,14 +975,14 @@ discard block |
||
| 975 | 975 | return $period; |
| 976 | 976 | } |
| 977 | 977 | |
| 978 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
| 979 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
| 980 | - return cal_days_in_month( $calendar, $month, $year ); |
|
| 978 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
| 979 | + if (function_exists('cal_days_in_month')) { |
|
| 980 | + return cal_days_in_month($calendar, $month, $year); |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | // Fallback in case the calendar extension is not loaded in PHP |
| 984 | 984 | // Only supports Gregorian calendar |
| 985 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 985 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -993,11 +993,11 @@ discard block |
||
| 993 | 993 | * |
| 994 | 994 | * @return string |
| 995 | 995 | */ |
| 996 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
| 997 | - if ( $allow_html ) { |
|
| 998 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
| 996 | +function wpi_help_tip($tip, $allow_html = false) { |
|
| 997 | + if ($allow_html) { |
|
| 998 | + $tip = wpi_sanitize_tooltip($tip); |
|
| 999 | 999 | } else { |
| 1000 | - $tip = esc_attr( $tip ); |
|
| 1000 | + $tip = esc_attr($tip); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -1011,8 +1011,8 @@ discard block |
||
| 1011 | 1011 | * @param string $var |
| 1012 | 1012 | * @return string |
| 1013 | 1013 | */ |
| 1014 | -function wpi_sanitize_tooltip( $var ) { |
|
| 1015 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 1014 | +function wpi_sanitize_tooltip($var) { |
|
| 1015 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 1016 | 1016 | 'br' => array(), |
| 1017 | 1017 | 'em' => array(), |
| 1018 | 1018 | 'strong' => array(), |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | 'li' => array(), |
| 1023 | 1023 | 'ol' => array(), |
| 1024 | 1024 | 'p' => array(), |
| 1025 | - ) ) ); |
|
| 1025 | + ))); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | */ |
| 1033 | 1033 | function wpinv_get_screen_ids() { |
| 1034 | 1034 | |
| 1035 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
| 1035 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
| 1036 | 1036 | |
| 1037 | 1037 | $screen_ids = array( |
| 1038 | 1038 | 'toplevel_page_' . $screen_id, |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | 'invoicing_page_wpi-addons', |
| 1051 | 1051 | ); |
| 1052 | 1052 | |
| 1053 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
| 1053 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | /** |
@@ -1061,14 +1061,14 @@ discard block |
||
| 1061 | 1061 | * @param array|string $list List of values. |
| 1062 | 1062 | * @return array Sanitized array of values. |
| 1063 | 1063 | */ |
| 1064 | -function wpinv_parse_list( $list ) { |
|
| 1064 | +function wpinv_parse_list($list) { |
|
| 1065 | 1065 | |
| 1066 | - if ( empty( $list ) ) { |
|
| 1066 | + if (empty($list)) { |
|
| 1067 | 1067 | $list = array(); |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - if ( ! is_array( $list ) ) { |
|
| 1071 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 1070 | + if (!is_array($list)) { |
|
| 1071 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | return $list; |
@@ -1082,16 +1082,16 @@ discard block |
||
| 1082 | 1082 | * @param string $key Type of data to fetch. |
| 1083 | 1083 | * @return mixed Fetched data. |
| 1084 | 1084 | */ |
| 1085 | -function wpinv_get_data( $key ) { |
|
| 1085 | +function wpinv_get_data($key) { |
|
| 1086 | 1086 | |
| 1087 | 1087 | // Try fetching it from the cache. |
| 1088 | - $data = wp_cache_get( "wpinv-$key", 'wpinv' ); |
|
| 1089 | - if( $data ) { |
|
| 1088 | + $data = wp_cache_get("wpinv-$key", 'wpinv'); |
|
| 1089 | + if ($data) { |
|
| 1090 | 1090 | return $data; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
| 1094 | - wp_cache_set( "wpinv-$key", $data, 'wpinv' ); |
|
| 1093 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
| 1094 | + wp_cache_set("wpinv-$key", $data, 'wpinv'); |
|
| 1095 | 1095 | |
| 1096 | 1096 | return $data; |
| 1097 | 1097 | } |
@@ -1105,10 +1105,10 @@ discard block |
||
| 1105 | 1105 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 1106 | 1106 | * @return mixed Fetched data. |
| 1107 | 1107 | */ |
| 1108 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
| 1108 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
| 1109 | 1109 | |
| 1110 | - if ( ! empty( $options ) && $first_empty ) { |
|
| 1111 | - return array_merge( array( '' => '' ), $options ); |
|
| 1110 | + if (!empty($options) && $first_empty) { |
|
| 1111 | + return array_merge(array('' => ''), $options); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | return $options; |
| 1114 | 1114 | |
@@ -1120,21 +1120,21 @@ discard block |
||
| 1120 | 1120 | * @param mixed $var Data to sanitize. |
| 1121 | 1121 | * @return string|array |
| 1122 | 1122 | */ |
| 1123 | -function wpinv_clean( $var ) { |
|
| 1123 | +function wpinv_clean($var) { |
|
| 1124 | 1124 | |
| 1125 | - if ( is_array( $var ) ) { |
|
| 1126 | - return array_map( 'wpinv_clean', $var ); |
|
| 1125 | + if (is_array($var)) { |
|
| 1126 | + return array_map('wpinv_clean', $var); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - if ( is_object( $var ) ) { |
|
| 1130 | - $object_vars = get_object_vars( $var ); |
|
| 1131 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 1132 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 1129 | + if (is_object($var)) { |
|
| 1130 | + $object_vars = get_object_vars($var); |
|
| 1131 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 1132 | + $var->$property_name = wpinv_clean($property_value); |
|
| 1133 | 1133 | } |
| 1134 | 1134 | return $var; |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 1137 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | /** |
@@ -1143,43 +1143,43 @@ discard block |
||
| 1143 | 1143 | * @param string $str Data to convert. |
| 1144 | 1144 | * @return string|array |
| 1145 | 1145 | */ |
| 1146 | -function getpaid_convert_price_string_to_options( $str ) { |
|
| 1146 | +function getpaid_convert_price_string_to_options($str) { |
|
| 1147 | 1147 | |
| 1148 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 1149 | - $options = array(); |
|
| 1148 | + $raw_options = array_map('trim', explode(',', $str)); |
|
| 1149 | + $options = array(); |
|
| 1150 | 1150 | |
| 1151 | - foreach ( $raw_options as $option ) { |
|
| 1151 | + foreach ($raw_options as $option) { |
|
| 1152 | 1152 | |
| 1153 | - if ( '' == $option ) { |
|
| 1153 | + if ('' == $option) { |
|
| 1154 | 1154 | continue; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
| 1157 | + $option = array_map('trim', explode('|', $option)); |
|
| 1158 | 1158 | |
| 1159 | 1159 | $price = null; |
| 1160 | 1160 | $label = null; |
| 1161 | 1161 | |
| 1162 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
| 1163 | - $label = $option[0]; |
|
| 1162 | + if (isset($option[0]) && '' != $option[0]) { |
|
| 1163 | + $label = $option[0]; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
| 1166 | + if (isset($option[1]) && '' != $option[1]) { |
|
| 1167 | 1167 | $price = $option[1]; |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | - if ( ! isset( $price ) ) { |
|
| 1170 | + if (!isset($price)) { |
|
| 1171 | 1171 | $price = $label; |
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
| 1174 | + if (!isset($price) || !is_numeric($price)) { |
|
| 1175 | 1175 | continue; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - if ( ! isset( $label ) ) { |
|
| 1178 | + if (!isset($label)) { |
|
| 1179 | 1179 | $label = $price; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | - $options[ $price ] = $label; |
|
| 1182 | + $options[$price] = $label; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | return $options; |
@@ -1188,22 +1188,22 @@ discard block |
||
| 1188 | 1188 | /** |
| 1189 | 1189 | * Returns the help tip. |
| 1190 | 1190 | */ |
| 1191 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
| 1192 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
| 1193 | - $tip = esc_attr__( $tip ); |
|
| 1191 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
| 1192 | + $additional_classes = sanitize_html_class($additional_classes); |
|
| 1193 | + $tip = esc_attr__($tip); |
|
| 1194 | 1194 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
| 1198 | 1198 | * Formats a date |
| 1199 | 1199 | */ |
| 1200 | -function getpaid_format_date( $date ) { |
|
| 1200 | +function getpaid_format_date($date) { |
|
| 1201 | 1201 | |
| 1202 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
| 1202 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
| 1203 | 1203 | return ''; |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | |
| 1207 | - return date_i18n( get_option( 'date_format' ), strtotime( $date ) ); |
|
| 1207 | + return date_i18n(get_option('date_format'), strtotime($date)); |
|
| 1208 | 1208 | |
| 1209 | 1209 | } |
@@ -7,16 +7,16 @@ 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 | -if ( !is_admin() ) { |
|
| 15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 14 | +if (!is_admin()) { |
|
| 15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | function wpinv_template_path() { |
| 19 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 19 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,118 +24,118 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param WPInv_Invoice $invoice. |
| 26 | 26 | */ |
| 27 | -function getpaid_invoice( $invoice ) { |
|
| 28 | - if ( ! empty( $invoice ) ) { |
|
| 29 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
| 27 | +function getpaid_invoice($invoice) { |
|
| 28 | + if (!empty($invoice)) { |
|
| 29 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | -add_action( 'getpaid_invoice', 'getpaid_invoice' ); |
|
| 32 | +add_action('getpaid_invoice', 'getpaid_invoice'); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Displays the invoice footer. |
| 36 | 36 | */ |
| 37 | -function getpaid_invoice_footer( $invoice ) { |
|
| 38 | - if ( ! empty( $invoice ) ) { |
|
| 39 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
| 37 | +function getpaid_invoice_footer($invoice) { |
|
| 38 | + if (!empty($invoice)) { |
|
| 39 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
| 42 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Displays the invoice top bar. |
| 46 | 46 | */ |
| 47 | -function getpaid_invoice_header( $invoice ) { |
|
| 48 | - if ( ! empty( $invoice ) ) { |
|
| 49 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
| 47 | +function getpaid_invoice_header($invoice) { |
|
| 48 | + if (!empty($invoice)) { |
|
| 49 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
| 52 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Displays actions on the left side of the header. |
| 56 | 56 | */ |
| 57 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
| 58 | - if ( ! empty( $invoice ) ) { |
|
| 59 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
| 57 | +function getpaid_invoice_header_left_actions($invoice) { |
|
| 58 | + if (!empty($invoice)) { |
|
| 59 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
| 62 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Displays actions on the right side of the invoice top bar. |
| 66 | 66 | */ |
| 67 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
| 68 | - if ( ! empty( $invoice ) ) { |
|
| 69 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
| 67 | +function getpaid_invoice_header_right_actions($invoice) { |
|
| 68 | + if (!empty($invoice)) { |
|
| 69 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
| 72 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * Displays the invoice title, watermark, logo etc. |
| 76 | 76 | */ |
| 77 | -function getpaid_invoice_details_top( $invoice ) { |
|
| 78 | - if ( ! empty( $invoice ) ) { |
|
| 79 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
| 77 | +function getpaid_invoice_details_top($invoice) { |
|
| 78 | + if (!empty($invoice)) { |
|
| 79 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
| 82 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Displays the company logo. |
| 86 | 86 | */ |
| 87 | -function getpaid_invoice_logo( $invoice ) { |
|
| 88 | - if ( ! empty( $invoice ) ) { |
|
| 89 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
| 87 | +function getpaid_invoice_logo($invoice) { |
|
| 88 | + if (!empty($invoice)) { |
|
| 89 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
| 92 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * Displays the type of invoice. |
| 96 | 96 | */ |
| 97 | -function getpaid_invoice_type( $invoice ) { |
|
| 98 | - if ( ! empty( $invoice ) ) { |
|
| 99 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
| 97 | +function getpaid_invoice_type($invoice) { |
|
| 98 | + if (!empty($invoice)) { |
|
| 99 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
| 102 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * Displays the invoice details. |
| 106 | 106 | */ |
| 107 | -function getpaid_invoice_details_main( $invoice ) { |
|
| 108 | - if ( ! empty( $invoice ) ) { |
|
| 109 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
| 107 | +function getpaid_invoice_details_main($invoice) { |
|
| 108 | + if (!empty($invoice)) { |
|
| 109 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 300 ); |
|
| 112 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 300); |
|
| 113 | 113 | |
| 114 | -function wpinv_before_invoice_content( $content ) { |
|
| 114 | +function wpinv_before_invoice_content($content) { |
|
| 115 | 115 | global $post; |
| 116 | 116 | |
| 117 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 117 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 118 | 118 | ob_start(); |
| 119 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
| 119 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
| 120 | 120 | $content = ob_get_clean() . $content; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | return $content; |
| 124 | 124 | } |
| 125 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
| 125 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
| 126 | 126 | |
| 127 | -function wpinv_after_invoice_content( $content ) { |
|
| 127 | +function wpinv_after_invoice_content($content) { |
|
| 128 | 128 | global $post; |
| 129 | 129 | |
| 130 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 130 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 131 | 131 | ob_start(); |
| 132 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
| 132 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
| 133 | 133 | $content .= ob_get_clean(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | return $content; |
| 137 | 137 | } |
| 138 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
| 138 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
| 139 | 139 | |
| 140 | 140 | function wpinv_get_templates_dir() { |
| 141 | 141 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -145,105 +145,105 @@ discard block |
||
| 145 | 145 | return WPINV_PLUGIN_URL . 'templates'; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 149 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 150 | - extract( $args ); |
|
| 148 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 149 | + if (!empty($args) && is_array($args)) { |
|
| 150 | + extract($args); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 153 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
| 154 | 154 | // Allow 3rd party plugin filter template file from their plugin. |
| 155 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 155 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 156 | 156 | |
| 157 | - if ( ! file_exists( $located ) ) { |
|
| 158 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
| 157 | + if (!file_exists($located)) { |
|
| 158 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 162 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
| 163 | 163 | |
| 164 | - include( $located ); |
|
| 164 | + include($located); |
|
| 165 | 165 | |
| 166 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 166 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 169 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 170 | 170 | ob_start(); |
| 171 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 171 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
| 172 | 172 | return ob_get_clean(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 176 | - if ( ! $template_path ) { |
|
| 175 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 176 | + if (!$template_path) { |
|
| 177 | 177 | $template_path = wpinv_template_path(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ( ! $default_path ) { |
|
| 180 | + if (!$default_path) { |
|
| 181 | 181 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Look within passed path within the theme - this is priority. |
| 185 | 185 | $template = locate_template( |
| 186 | 186 | array( |
| 187 | - trailingslashit( $template_path ) . $template_name, |
|
| 187 | + trailingslashit($template_path) . $template_name, |
|
| 188 | 188 | $template_name |
| 189 | 189 | ) |
| 190 | 190 | ); |
| 191 | 191 | |
| 192 | 192 | // Get default templates/ |
| 193 | - if ( !$template && $default_path ) { |
|
| 194 | - $template = trailingslashit( $default_path ) . $template_name; |
|
| 193 | + if (!$template && $default_path) { |
|
| 194 | + $template = trailingslashit($default_path) . $template_name; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Return what we found. |
| 198 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
| 198 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 202 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 201 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 202 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 203 | 203 | |
| 204 | 204 | // Setup possible parts |
| 205 | 205 | $templates = array(); |
| 206 | - if ( isset( $name ) ) |
|
| 206 | + if (isset($name)) |
|
| 207 | 207 | $templates[] = $slug . '-' . $name . '.php'; |
| 208 | 208 | $templates[] = $slug . '.php'; |
| 209 | 209 | |
| 210 | 210 | // Allow template parts to be filtered |
| 211 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 211 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 212 | 212 | |
| 213 | 213 | // Return the part that is found |
| 214 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 214 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 217 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 218 | 218 | // No file found yet |
| 219 | 219 | $located = false; |
| 220 | 220 | |
| 221 | 221 | // Try to find a template file |
| 222 | - foreach ( (array)$template_names as $template_name ) { |
|
| 222 | + foreach ((array) $template_names as $template_name) { |
|
| 223 | 223 | |
| 224 | 224 | // Continue if template is empty |
| 225 | - if ( empty( $template_name ) ) |
|
| 225 | + if (empty($template_name)) |
|
| 226 | 226 | continue; |
| 227 | 227 | |
| 228 | 228 | // Trim off any slashes from the template name |
| 229 | - $template_name = ltrim( $template_name, '/' ); |
|
| 229 | + $template_name = ltrim($template_name, '/'); |
|
| 230 | 230 | |
| 231 | 231 | // try locating this template file by looping through the template paths |
| 232 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 232 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 233 | 233 | |
| 234 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 234 | + if (file_exists($template_path . $template_name)) { |
|
| 235 | 235 | $located = $template_path . $template_name; |
| 236 | 236 | break; |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if( !empty( $located ) ) { |
|
| 240 | + if (!empty($located)) { |
|
| 241 | 241 | break; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 246 | - load_template( $located, $require_once ); |
|
| 245 | + if ((true == $load) && !empty($located)) |
|
| 246 | + load_template($located, $require_once); |
|
| 247 | 247 | |
| 248 | 248 | return $located; |
| 249 | 249 | } |
@@ -252,159 +252,159 @@ discard block |
||
| 252 | 252 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 253 | 253 | |
| 254 | 254 | $file_paths = array( |
| 255 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 256 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 255 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 256 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 257 | 257 | 100 => wpinv_get_templates_dir() |
| 258 | 258 | ); |
| 259 | 259 | |
| 260 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 260 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 261 | 261 | |
| 262 | 262 | // sort the file paths based on priority |
| 263 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 263 | + ksort($file_paths, SORT_NUMERIC); |
|
| 264 | 264 | |
| 265 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 265 | + return array_map('trailingslashit', $file_paths); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | function wpinv_get_theme_template_dir_name() { |
| 269 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 269 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | function wpinv_checkout_meta_tags() { |
| 273 | 273 | |
| 274 | 274 | $pages = array(); |
| 275 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 276 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 277 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 278 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 275 | + $pages[] = wpinv_get_option('success_page'); |
|
| 276 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 277 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 278 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 279 | 279 | |
| 280 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 280 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 285 | 285 | } |
| 286 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 286 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 287 | 287 | |
| 288 | -function wpinv_add_body_classes( $class ) { |
|
| 289 | - $classes = (array)$class; |
|
| 288 | +function wpinv_add_body_classes($class) { |
|
| 289 | + $classes = (array) $class; |
|
| 290 | 290 | |
| 291 | - if( wpinv_is_checkout() ) { |
|
| 291 | + if (wpinv_is_checkout()) { |
|
| 292 | 292 | $classes[] = 'wpinv-checkout'; |
| 293 | 293 | $classes[] = 'wpinv-page'; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if( wpinv_is_success_page() ) { |
|
| 296 | + if (wpinv_is_success_page()) { |
|
| 297 | 297 | $classes[] = 'wpinv-success'; |
| 298 | 298 | $classes[] = 'wpinv-page'; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 301 | + if (wpinv_is_failed_transaction_page()) { |
|
| 302 | 302 | $classes[] = 'wpinv-failed-transaction'; |
| 303 | 303 | $classes[] = 'wpinv-page'; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if( wpinv_is_invoice_history_page() ) { |
|
| 306 | + if (wpinv_is_invoice_history_page()) { |
|
| 307 | 307 | $classes[] = 'wpinv-history'; |
| 308 | 308 | $classes[] = 'wpinv-page'; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 311 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 312 | 312 | $classes[] = 'wpinv-subscription'; |
| 313 | 313 | $classes[] = 'wpinv-page'; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if( wpinv_is_test_mode() ) { |
|
| 316 | + if (wpinv_is_test_mode()) { |
|
| 317 | 317 | $classes[] = 'wpinv-test-mode'; |
| 318 | 318 | $classes[] = 'wpinv-page'; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - return array_unique( $classes ); |
|
| 321 | + return array_unique($classes); |
|
| 322 | 322 | } |
| 323 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 323 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 324 | 324 | |
| 325 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 326 | - $args = array( 'nopaging' => true ); |
|
| 325 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 326 | + $args = array('nopaging' => true); |
|
| 327 | 327 | |
| 328 | - if ( ! empty( $status ) ) |
|
| 328 | + if (!empty($status)) |
|
| 329 | 329 | $args['post_status'] = $status; |
| 330 | 330 | |
| 331 | - $discounts = wpinv_get_discounts( $args ); |
|
| 331 | + $discounts = wpinv_get_discounts($args); |
|
| 332 | 332 | $options = array(); |
| 333 | 333 | |
| 334 | - if ( $discounts ) { |
|
| 335 | - foreach ( $discounts as $discount ) { |
|
| 336 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 334 | + if ($discounts) { |
|
| 335 | + foreach ($discounts as $discount) { |
|
| 336 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 337 | 337 | } |
| 338 | 338 | } else { |
| 339 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 339 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $output = wpinv_html_select( array( |
|
| 342 | + $output = wpinv_html_select(array( |
|
| 343 | 343 | 'name' => $name, |
| 344 | 344 | 'selected' => $selected, |
| 345 | 345 | 'options' => $options, |
| 346 | 346 | 'show_option_all' => false, |
| 347 | 347 | 'show_option_none' => false, |
| 348 | - ) ); |
|
| 348 | + )); |
|
| 349 | 349 | |
| 350 | 350 | return $output; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 354 | - $current = date( 'Y' ); |
|
| 355 | - $start_year = $current - absint( $years_before ); |
|
| 356 | - $end_year = $current + absint( $years_after ); |
|
| 357 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 353 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 354 | + $current = date('Y'); |
|
| 355 | + $start_year = $current - absint($years_before); |
|
| 356 | + $end_year = $current + absint($years_after); |
|
| 357 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 358 | 358 | $options = array(); |
| 359 | 359 | |
| 360 | - while ( $start_year <= $end_year ) { |
|
| 361 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 360 | + while ($start_year <= $end_year) { |
|
| 361 | + $options[absint($start_year)] = $start_year; |
|
| 362 | 362 | $start_year++; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $output = wpinv_html_select( array( |
|
| 365 | + $output = wpinv_html_select(array( |
|
| 366 | 366 | 'name' => $name, |
| 367 | 367 | 'selected' => $selected, |
| 368 | 368 | 'options' => $options, |
| 369 | 369 | 'show_option_all' => false, |
| 370 | 370 | 'show_option_none' => false |
| 371 | - ) ); |
|
| 371 | + )); |
|
| 372 | 372 | |
| 373 | 373 | return $output; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 376 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 377 | 377 | |
| 378 | 378 | $options = array( |
| 379 | - '1' => __( 'January', 'invoicing' ), |
|
| 380 | - '2' => __( 'February', 'invoicing' ), |
|
| 381 | - '3' => __( 'March', 'invoicing' ), |
|
| 382 | - '4' => __( 'April', 'invoicing' ), |
|
| 383 | - '5' => __( 'May', 'invoicing' ), |
|
| 384 | - '6' => __( 'June', 'invoicing' ), |
|
| 385 | - '7' => __( 'July', 'invoicing' ), |
|
| 386 | - '8' => __( 'August', 'invoicing' ), |
|
| 387 | - '9' => __( 'September', 'invoicing' ), |
|
| 388 | - '10' => __( 'October', 'invoicing' ), |
|
| 389 | - '11' => __( 'November', 'invoicing' ), |
|
| 390 | - '12' => __( 'December', 'invoicing' ), |
|
| 379 | + '1' => __('January', 'invoicing'), |
|
| 380 | + '2' => __('February', 'invoicing'), |
|
| 381 | + '3' => __('March', 'invoicing'), |
|
| 382 | + '4' => __('April', 'invoicing'), |
|
| 383 | + '5' => __('May', 'invoicing'), |
|
| 384 | + '6' => __('June', 'invoicing'), |
|
| 385 | + '7' => __('July', 'invoicing'), |
|
| 386 | + '8' => __('August', 'invoicing'), |
|
| 387 | + '9' => __('September', 'invoicing'), |
|
| 388 | + '10' => __('October', 'invoicing'), |
|
| 389 | + '11' => __('November', 'invoicing'), |
|
| 390 | + '12' => __('December', 'invoicing'), |
|
| 391 | 391 | ); |
| 392 | 392 | |
| 393 | 393 | // If no month is selected, default to the current month |
| 394 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 394 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 395 | 395 | |
| 396 | - $output = wpinv_html_select( array( |
|
| 396 | + $output = wpinv_html_select(array( |
|
| 397 | 397 | 'name' => $name, |
| 398 | 398 | 'selected' => $selected, |
| 399 | 399 | 'options' => $options, |
| 400 | 400 | 'show_option_all' => false, |
| 401 | 401 | 'show_option_none' => false |
| 402 | - ) ); |
|
| 402 | + )); |
|
| 403 | 403 | |
| 404 | 404 | return $output; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | -function wpinv_html_select( $args = array() ) { |
|
| 407 | +function wpinv_html_select($args = array()) { |
|
| 408 | 408 | $defaults = array( |
| 409 | 409 | 'options' => array(), |
| 410 | 410 | 'name' => null, |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | 'selected' => 0, |
| 414 | 414 | 'placeholder' => null, |
| 415 | 415 | 'multiple' => false, |
| 416 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 417 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 416 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 417 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 418 | 418 | 'data' => array(), |
| 419 | 419 | 'onchange' => null, |
| 420 | 420 | 'required' => false, |
@@ -422,74 +422,74 @@ discard block |
||
| 422 | 422 | 'readonly' => false, |
| 423 | 423 | ); |
| 424 | 424 | |
| 425 | - $args = wp_parse_args( $args, $defaults ); |
|
| 425 | + $args = wp_parse_args($args, $defaults); |
|
| 426 | 426 | |
| 427 | 427 | $data_elements = ''; |
| 428 | - foreach ( $args['data'] as $key => $value ) { |
|
| 429 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 428 | + foreach ($args['data'] as $key => $value) { |
|
| 429 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if( $args['multiple'] ) { |
|
| 432 | + if ($args['multiple']) { |
|
| 433 | 433 | $multiple = ' MULTIPLE'; |
| 434 | 434 | } else { |
| 435 | 435 | $multiple = ''; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if( $args['placeholder'] ) { |
|
| 438 | + if ($args['placeholder']) { |
|
| 439 | 439 | $placeholder = $args['placeholder']; |
| 440 | 440 | } else { |
| 441 | 441 | $placeholder = ''; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | $options = ''; |
| 445 | - if( !empty( $args['onchange'] ) ) { |
|
| 446 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 445 | + if (!empty($args['onchange'])) { |
|
| 446 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - if( !empty( $args['required'] ) ) { |
|
| 449 | + if (!empty($args['required'])) { |
|
| 450 | 450 | $options .= ' required="required"'; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if( !empty( $args['disabled'] ) ) { |
|
| 453 | + if (!empty($args['disabled'])) { |
|
| 454 | 454 | $options .= ' disabled'; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - if( !empty( $args['readonly'] ) ) { |
|
| 457 | + if (!empty($args['readonly'])) { |
|
| 458 | 458 | $options .= ' readonly'; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 462 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 461 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 462 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 463 | 463 | |
| 464 | - if ( $args['show_option_all'] ) { |
|
| 465 | - if( $args['multiple'] ) { |
|
| 466 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 464 | + if ($args['show_option_all']) { |
|
| 465 | + if ($args['multiple']) { |
|
| 466 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 467 | 467 | } else { |
| 468 | - $selected = selected( $args['selected'], 0, false ); |
|
| 468 | + $selected = selected($args['selected'], 0, false); |
|
| 469 | 469 | } |
| 470 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 470 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if ( !empty( $args['options'] ) ) { |
|
| 473 | + if (!empty($args['options'])) { |
|
| 474 | 474 | |
| 475 | - if ( $args['show_option_none'] ) { |
|
| 476 | - if( $args['multiple'] ) { |
|
| 477 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 475 | + if ($args['show_option_none']) { |
|
| 476 | + if ($args['multiple']) { |
|
| 477 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 478 | 478 | } else { |
| 479 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 479 | + $selected = selected($args['selected'] === "", true, false); |
|
| 480 | 480 | } |
| 481 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 481 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - foreach( $args['options'] as $key => $option ) { |
|
| 484 | + foreach ($args['options'] as $key => $option) { |
|
| 485 | 485 | |
| 486 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 487 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 486 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 487 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
| 488 | 488 | } else { |
| 489 | - $selected = selected( $args['selected'], $key, false ); |
|
| 489 | + $selected = selected($args['selected'], $key, false); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 492 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | return $output; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 501 | +function wpinv_item_dropdown($args = array()) { |
|
| 502 | 502 | $defaults = array( |
| 503 | 503 | 'name' => 'wpi_item', |
| 504 | 504 | 'id' => 'wpi_item', |
@@ -506,14 +506,14 @@ discard block |
||
| 506 | 506 | 'multiple' => false, |
| 507 | 507 | 'selected' => 0, |
| 508 | 508 | 'number' => 100, |
| 509 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 510 | - 'data' => array( 'search-type' => 'item' ), |
|
| 509 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 510 | + 'data' => array('search-type' => 'item'), |
|
| 511 | 511 | 'show_option_all' => false, |
| 512 | 512 | 'show_option_none' => false, |
| 513 | 513 | 'show_recurring' => false, |
| 514 | 514 | ); |
| 515 | 515 | |
| 516 | - $args = wp_parse_args( $args, $defaults ); |
|
| 516 | + $args = wp_parse_args($args, $defaults); |
|
| 517 | 517 | |
| 518 | 518 | $item_args = array( |
| 519 | 519 | 'post_type' => 'wpi_item', |
@@ -522,44 +522,44 @@ discard block |
||
| 522 | 522 | 'posts_per_page' => $args['number'] |
| 523 | 523 | ); |
| 524 | 524 | |
| 525 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 525 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 526 | 526 | |
| 527 | - $items = get_posts( $item_args ); |
|
| 527 | + $items = get_posts($item_args); |
|
| 528 | 528 | $options = array(); |
| 529 | - if ( $items ) { |
|
| 530 | - foreach ( $items as $item ) { |
|
| 531 | - $title = esc_html( $item->post_title ); |
|
| 529 | + if ($items) { |
|
| 530 | + foreach ($items as $item) { |
|
| 531 | + $title = esc_html($item->post_title); |
|
| 532 | 532 | |
| 533 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 534 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 533 | + if (!empty($args['show_recurring'])) { |
|
| 534 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - $options[ absint( $item->ID ) ] = $title; |
|
| 537 | + $options[absint($item->ID)] = $title; |
|
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // This ensures that any selected items are included in the drop down |
| 542 | - if( is_array( $args['selected'] ) ) { |
|
| 543 | - foreach( $args['selected'] as $item ) { |
|
| 544 | - if( ! in_array( $item, $options ) ) { |
|
| 545 | - $title = get_the_title( $item ); |
|
| 546 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 547 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 542 | + if (is_array($args['selected'])) { |
|
| 543 | + foreach ($args['selected'] as $item) { |
|
| 544 | + if (!in_array($item, $options)) { |
|
| 545 | + $title = get_the_title($item); |
|
| 546 | + if (!empty($args['show_recurring'])) { |
|
| 547 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 548 | 548 | } |
| 549 | 549 | $options[$item] = $title; |
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 553 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 554 | - $title = get_the_title( $args['selected'] ); |
|
| 555 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 556 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 552 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 553 | + if (!in_array($args['selected'], $options)) { |
|
| 554 | + $title = get_the_title($args['selected']); |
|
| 555 | + if (!empty($args['show_recurring'])) { |
|
| 556 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 557 | 557 | } |
| 558 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 558 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - $output = wpinv_html_select( array( |
|
| 562 | + $output = wpinv_html_select(array( |
|
| 563 | 563 | 'name' => $args['name'], |
| 564 | 564 | 'selected' => $args['selected'], |
| 565 | 565 | 'id' => $args['id'], |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | 'show_option_all' => $args['show_option_all'], |
| 571 | 571 | 'show_option_none' => $args['show_option_none'], |
| 572 | 572 | 'data' => $args['data'], |
| 573 | - ) ); |
|
| 573 | + )); |
|
| 574 | 574 | |
| 575 | 575 | return $output; |
| 576 | 576 | } |
@@ -590,16 +590,16 @@ discard block |
||
| 590 | 590 | ); |
| 591 | 591 | |
| 592 | 592 | $options = array(); |
| 593 | - if ( $items ) { |
|
| 594 | - foreach ( $items as $item ) { |
|
| 595 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
| 593 | + if ($items) { |
|
| 594 | + foreach ($items as $item) { |
|
| 595 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | return $options; |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 602 | +function wpinv_html_checkbox($args = array()) { |
|
| 603 | 603 | $defaults = array( |
| 604 | 604 | 'name' => null, |
| 605 | 605 | 'current' => null, |
@@ -610,38 +610,38 @@ discard block |
||
| 610 | 610 | ) |
| 611 | 611 | ); |
| 612 | 612 | |
| 613 | - $args = wp_parse_args( $args, $defaults ); |
|
| 613 | + $args = wp_parse_args($args, $defaults); |
|
| 614 | 614 | |
| 615 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 615 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 616 | 616 | $options = ''; |
| 617 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 617 | + if (!empty($args['options']['disabled'])) { |
|
| 618 | 618 | $options .= ' disabled="disabled"'; |
| 619 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 619 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 620 | 620 | $options .= ' readonly'; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 623 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 624 | 624 | |
| 625 | 625 | return $output; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | -function wpinv_html_text( $args = array() ) { |
|
| 628 | +function wpinv_html_text($args = array()) { |
|
| 629 | 629 | // Backwards compatibility |
| 630 | - if ( func_num_args() > 1 ) { |
|
| 630 | + if (func_num_args() > 1) { |
|
| 631 | 631 | $args = func_get_args(); |
| 632 | 632 | |
| 633 | 633 | $name = $args[0]; |
| 634 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 635 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 636 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 634 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 635 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 636 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | $defaults = array( |
| 640 | 640 | 'id' => '', |
| 641 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 642 | - 'value' => isset( $value ) ? $value : null, |
|
| 643 | - 'label' => isset( $label ) ? $label : null, |
|
| 644 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 641 | + 'name' => isset($name) ? $name : 'text', |
|
| 642 | + 'value' => isset($value) ? $value : null, |
|
| 643 | + 'label' => isset($label) ? $label : null, |
|
| 644 | + 'desc' => isset($desc) ? $desc : null, |
|
| 645 | 645 | 'placeholder' => '', |
| 646 | 646 | 'class' => 'regular-text', |
| 647 | 647 | 'disabled' => false, |
@@ -651,51 +651,51 @@ discard block |
||
| 651 | 651 | 'data' => false |
| 652 | 652 | ); |
| 653 | 653 | |
| 654 | - $args = wp_parse_args( $args, $defaults ); |
|
| 654 | + $args = wp_parse_args($args, $defaults); |
|
| 655 | 655 | |
| 656 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 656 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 657 | 657 | $options = ''; |
| 658 | - if( $args['required'] ) { |
|
| 658 | + if ($args['required']) { |
|
| 659 | 659 | $options .= ' required="required"'; |
| 660 | 660 | } |
| 661 | - if( $args['readonly'] ) { |
|
| 661 | + if ($args['readonly']) { |
|
| 662 | 662 | $options .= ' readonly'; |
| 663 | 663 | } |
| 664 | - if( $args['readonly'] ) { |
|
| 664 | + if ($args['readonly']) { |
|
| 665 | 665 | $options .= ' readonly'; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | $data = ''; |
| 669 | - if ( !empty( $args['data'] ) ) { |
|
| 670 | - foreach ( $args['data'] as $key => $value ) { |
|
| 671 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 669 | + if (!empty($args['data'])) { |
|
| 670 | + foreach ($args['data'] as $key => $value) { |
|
| 671 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 676 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 677 | - if ( ! empty( $args['desc'] ) ) { |
|
| 678 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 675 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 676 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 677 | + if (!empty($args['desc'])) { |
|
| 678 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 681 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 682 | 682 | |
| 683 | 683 | $output .= '</span>'; |
| 684 | 684 | |
| 685 | 685 | return $output; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | -function wpinv_html_date_field( $args = array() ) { |
|
| 689 | - if( empty( $args['class'] ) ) { |
|
| 688 | +function wpinv_html_date_field($args = array()) { |
|
| 689 | + if (empty($args['class'])) { |
|
| 690 | 690 | $args['class'] = 'wpiDatepicker'; |
| 691 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 691 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 692 | 692 | $args['class'] .= ' wpiDatepicker'; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - return wpinv_html_text( $args ); |
|
| 695 | + return wpinv_html_text($args); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | -function wpinv_html_textarea( $args = array() ) { |
|
| 698 | +function wpinv_html_textarea($args = array()) { |
|
| 699 | 699 | $defaults = array( |
| 700 | 700 | 'name' => 'textarea', |
| 701 | 701 | 'value' => null, |
@@ -706,31 +706,31 @@ discard block |
||
| 706 | 706 | 'placeholder' => '', |
| 707 | 707 | ); |
| 708 | 708 | |
| 709 | - $args = wp_parse_args( $args, $defaults ); |
|
| 709 | + $args = wp_parse_args($args, $defaults); |
|
| 710 | 710 | |
| 711 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 711 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 712 | 712 | $disabled = ''; |
| 713 | - if( $args['disabled'] ) { |
|
| 713 | + if ($args['disabled']) { |
|
| 714 | 714 | $disabled = ' disabled="disabled"'; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 718 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 719 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 717 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 718 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 719 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 720 | 720 | |
| 721 | - if ( ! empty( $args['desc'] ) ) { |
|
| 722 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 721 | + if (!empty($args['desc'])) { |
|
| 722 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 723 | 723 | } |
| 724 | 724 | $output .= '</span>'; |
| 725 | 725 | |
| 726 | 726 | return $output; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 729 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 730 | 730 | $defaults = array( |
| 731 | 731 | 'name' => 'user_id', |
| 732 | 732 | 'value' => null, |
| 733 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 733 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 734 | 734 | 'label' => null, |
| 735 | 735 | 'desc' => null, |
| 736 | 736 | 'class' => '', |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | 'data' => false |
| 740 | 740 | ); |
| 741 | 741 | |
| 742 | - $args = wp_parse_args( $args, $defaults ); |
|
| 742 | + $args = wp_parse_args($args, $defaults); |
|
| 743 | 743 | |
| 744 | 744 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 745 | 745 | |
| 746 | 746 | $output = '<span class="wpinv_user_search_wrap">'; |
| 747 | - $output .= wpinv_html_text( $args ); |
|
| 748 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 747 | + $output .= wpinv_html_text($args); |
|
| 748 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 749 | 749 | $output .= '</span>'; |
| 750 | 750 | |
| 751 | 751 | return $output; |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | function wpinv_ip_geolocation() { |
| 755 | 755 | global $wpinv_euvat; |
| 756 | 756 | |
| 757 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
| 757 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
| 758 | 758 | $content = ''; |
| 759 | 759 | $iso = ''; |
| 760 | 760 | $country = ''; |
@@ -765,69 +765,69 @@ discard block |
||
| 765 | 765 | $credit = ''; |
| 766 | 766 | $address = ''; |
| 767 | 767 | |
| 768 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
| 768 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
| 769 | 769 | try { |
| 770 | 770 | $iso = $geoip2_city->country->isoCode; |
| 771 | 771 | $country = $geoip2_city->country->name; |
| 772 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 772 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 773 | 773 | $city = $geoip2_city->city->name; |
| 774 | 774 | $longitude = $geoip2_city->location->longitude; |
| 775 | 775 | $latitude = $geoip2_city->location->latitude; |
| 776 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 777 | - } catch( Exception $e ) { } |
|
| 776 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 777 | + } catch (Exception $e) { } |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 780 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
| 781 | 781 | try { |
| 782 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 782 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 783 | 783 | |
| 784 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
| 784 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 785 | 785 | $iso = $load_xml->geoplugin_countryCode; |
| 786 | 786 | $country = $load_xml->geoplugin_countryName; |
| 787 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 788 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 787 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 788 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 789 | 789 | $longitude = $load_xml->geoplugin_longitude; |
| 790 | 790 | $latitude = $load_xml->geoplugin_latitude; |
| 791 | 791 | $credit = $load_xml->geoplugin_credit; |
| 792 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
| 792 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
| 793 | 793 | } |
| 794 | - } catch( Exception $e ) { } |
|
| 794 | + } catch (Exception $e) { } |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - if ( $iso && $longitude && $latitude ) { |
|
| 798 | - if ( $city ) { |
|
| 797 | + if ($iso && $longitude && $latitude) { |
|
| 798 | + if ($city) { |
|
| 799 | 799 | $address .= $city . ', '; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if ( $region ) { |
|
| 802 | + if ($region) { |
|
| 803 | 803 | $address .= $region . ', '; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | $address .= $country . ' (' . $iso . ')'; |
| 807 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
| 808 | - $content .= '<p>'. $credit . '</p>'; |
|
| 807 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
| 808 | + $content .= '<p>' . $credit . '</p>'; |
|
| 809 | 809 | } else { |
| 810 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
| 810 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
| 811 | 811 | } |
| 812 | 812 | ?> |
| 813 | 813 | <!DOCTYPE html> |
| 814 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 814 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 815 | 815 | <body> |
| 816 | - <?php if ( $latitude && $latitude ) { ?> |
|
| 816 | + <?php if ($latitude && $latitude) { ?> |
|
| 817 | 817 | <div id="map"></div> |
| 818 | 818 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
| 819 | 819 | <script type="text/javascript"> |
| 820 | 820 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 821 | 821 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 822 | 822 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
| 823 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
| 823 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
| 824 | 824 | |
| 825 | 825 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
| 826 | 826 | |
| 827 | 827 | var marker = new L.Marker(latlng); |
| 828 | 828 | map.addLayer(marker); |
| 829 | 829 | |
| 830 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
| 830 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
| 831 | 831 | </script> |
| 832 | 832 | <?php } ?> |
| 833 | 833 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -835,22 +835,22 @@ discard block |
||
| 835 | 835 | <?php |
| 836 | 836 | exit; |
| 837 | 837 | } |
| 838 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 839 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 838 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 839 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 840 | 840 | |
| 841 | 841 | // Set up the template for the invoice. |
| 842 | -function wpinv_template( $template ) { |
|
| 842 | +function wpinv_template($template) { |
|
| 843 | 843 | global $post; |
| 844 | 844 | |
| 845 | - if ( ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 845 | + if ((is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 846 | 846 | |
| 847 | 847 | // If the user can view this invoice, display it. |
| 848 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 849 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 848 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 849 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 850 | 850 | |
| 851 | 851 | // Else display an error message. |
| 852 | 852 | } else { |
| 853 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 853 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | |
| 861 | 861 | function wpinv_get_business_address() { |
| 862 | 862 | $business_address = wpinv_store_address(); |
| 863 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 863 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 864 | 864 | |
| 865 | 865 | /* |
| 866 | 866 | $default_country = wpinv_get_default_country(); |
@@ -884,38 +884,38 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 886 | 886 | |
| 887 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 887 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
| 891 | 891 | * Displays the company address. |
| 892 | 892 | */ |
| 893 | 893 | function wpinv_display_from_address() { |
| 894 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 894 | + wpinv_get_template('invoice/company-address.php'); |
|
| 895 | 895 | } |
| 896 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 896 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 897 | 897 | |
| 898 | -function wpinv_watermark( $id = 0 ) { |
|
| 899 | - $output = wpinv_get_watermark( $id ); |
|
| 900 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 898 | +function wpinv_watermark($id = 0) { |
|
| 899 | + $output = wpinv_get_watermark($id); |
|
| 900 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | -function wpinv_get_watermark( $id ) { |
|
| 904 | - if ( !$id > 0 ) { |
|
| 903 | +function wpinv_get_watermark($id) { |
|
| 904 | + if (!$id > 0) { |
|
| 905 | 905 | return NULL; |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - $invoice = wpinv_get_invoice( $id ); |
|
| 908 | + $invoice = wpinv_get_invoice($id); |
|
| 909 | 909 | |
| 910 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 911 | - if ( $invoice->is_paid() ) { |
|
| 912 | - return __( 'Paid', 'invoicing' ); |
|
| 910 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 911 | + if ($invoice->is_paid()) { |
|
| 912 | + return __('Paid', 'invoicing'); |
|
| 913 | 913 | } |
| 914 | - if ( $invoice->is_refunded() ) { |
|
| 915 | - return __( 'Refunded', 'invoicing' ); |
|
| 914 | + if ($invoice->is_refunded()) { |
|
| 915 | + return __('Refunded', 'invoicing'); |
|
| 916 | 916 | } |
| 917 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 918 | - return __( 'Cancelled', 'invoicing' ); |
|
| 917 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 918 | + return __('Cancelled', 'invoicing'); |
|
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | |
@@ -925,125 +925,125 @@ discard block |
||
| 925 | 925 | /** |
| 926 | 926 | * @deprecated |
| 927 | 927 | */ |
| 928 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 929 | - return getpaid_invoice_meta( $invoice ); |
|
| 928 | +function wpinv_display_invoice_details($invoice) { |
|
| 929 | + return getpaid_invoice_meta($invoice); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | /** |
| 933 | 933 | * Displays invoice meta. |
| 934 | 934 | */ |
| 935 | -function getpaid_invoice_meta( $invoice ) { |
|
| 935 | +function getpaid_invoice_meta($invoice) { |
|
| 936 | 936 | |
| 937 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 937 | + $invoice = new WPInv_Invoice($invoice); |
|
| 938 | 938 | |
| 939 | 939 | // Ensure that we have an invoice. |
| 940 | - if ( 0 == $invoice->get_id() ) { |
|
| 940 | + if (0 == $invoice->get_id()) { |
|
| 941 | 941 | return; |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | // Load the invoice meta. |
| 945 | - $meta = array( |
|
| 945 | + $meta = array( |
|
| 946 | 946 | |
| 947 | 947 | 'number' => array( |
| 948 | 948 | 'label' => sprintf( |
| 949 | - __( '%s Number', 'invoicing' ), |
|
| 950 | - ucfirst( $invoice->get_type() ) |
|
| 949 | + __('%s Number', 'invoicing'), |
|
| 950 | + ucfirst($invoice->get_type()) |
|
| 951 | 951 | ), |
| 952 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
| 952 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
| 953 | 953 | ), |
| 954 | 954 | |
| 955 | 955 | 'status' => array( |
| 956 | 956 | 'label' => sprintf( |
| 957 | - __( '%s Status', 'invoicing' ), |
|
| 958 | - ucfirst( $invoice->get_type() ) |
|
| 957 | + __('%s Status', 'invoicing'), |
|
| 958 | + ucfirst($invoice->get_type()) |
|
| 959 | 959 | ), |
| 960 | - 'value' => sanitize_text_field( $invoice->get_status_nicename() ), |
|
| 960 | + 'value' => sanitize_text_field($invoice->get_status_nicename()), |
|
| 961 | 961 | ), |
| 962 | 962 | |
| 963 | 963 | 'date' => array( |
| 964 | 964 | 'label' => sprintf( |
| 965 | - __( '%s Date', 'invoicing' ), |
|
| 966 | - ucfirst( $invoice->get_type() ) |
|
| 965 | + __('%s Date', 'invoicing'), |
|
| 966 | + ucfirst($invoice->get_type()) |
|
| 967 | 967 | ), |
| 968 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
| 968 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
| 969 | 969 | ), |
| 970 | 970 | |
| 971 | 971 | 'date_paid' => array( |
| 972 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
| 973 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
| 972 | + 'label' => __('Paid On', 'invoicing'), |
|
| 973 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
| 974 | 974 | ), |
| 975 | 975 | |
| 976 | 976 | 'due_date' => array( |
| 977 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
| 978 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
| 977 | + 'label' => __('Due Date', 'invoicing'), |
|
| 978 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
| 979 | 979 | ), |
| 980 | 980 | |
| 981 | 981 | 'vat_number' => array( |
| 982 | 982 | 'label' => sprintf( |
| 983 | - __( '%s Number', 'invoicing' ), |
|
| 983 | + __('%s Number', 'invoicing'), |
|
| 984 | 984 | $GLOBALS['wpinv_euvat']->get_vat_name() |
| 985 | 985 | ), |
| 986 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
| 986 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
| 987 | 987 | ), |
| 988 | 988 | |
| 989 | 989 | ); |
| 990 | 990 | |
| 991 | 991 | // If it is not paid, remove the date of payment. |
| 992 | - if ( ! $invoice->is_paid() ) { |
|
| 993 | - unset( $meta[ 'date_paid' ] ); |
|
| 992 | + if (!$invoice->is_paid()) { |
|
| 993 | + unset($meta['date_paid']); |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | // Only display the due date if due dates are enabled. |
| 997 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
| 998 | - unset( $meta[ 'due_date' ] ); |
|
| 997 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
| 998 | + unset($meta['due_date']); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | // Only display the vat number if taxes are enabled. |
| 1002 | - if ( ! wpinv_use_taxes() ) { |
|
| 1003 | - unset( $meta[ 'vat_number' ] ); |
|
| 1002 | + if (!wpinv_use_taxes()) { |
|
| 1003 | + unset($meta['vat_number']); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - if ( $invoice->is_recurring() ) { |
|
| 1006 | + if ($invoice->is_recurring()) { |
|
| 1007 | 1007 | |
| 1008 | 1008 | // Link to the parent invoice. |
| 1009 | - if ( $invoice->is_renewal() ) { |
|
| 1009 | + if ($invoice->is_renewal()) { |
|
| 1010 | 1010 | |
| 1011 | - $meta[ 'parent' ] = array( |
|
| 1011 | + $meta['parent'] = array( |
|
| 1012 | 1012 | |
| 1013 | 1013 | 'label' => sprintf( |
| 1014 | - __( 'Parent %s', 'invoicing' ), |
|
| 1015 | - ucfirst( $invoice->get_type() ) |
|
| 1014 | + __('Parent %s', 'invoicing'), |
|
| 1015 | + ucfirst($invoice->get_type()) |
|
| 1016 | 1016 | ), |
| 1017 | 1017 | |
| 1018 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
| 1018 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
| 1019 | 1019 | |
| 1020 | 1020 | ); |
| 1021 | 1021 | |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 1024 | + $subscription = wpinv_get_subscription($invoice); |
|
| 1025 | 1025 | |
| 1026 | - if ( ! empty ( $subscription ) ) { |
|
| 1026 | + if (!empty ($subscription)) { |
|
| 1027 | 1027 | |
| 1028 | 1028 | // Display the renewal date. |
| 1029 | - if ( $subscription->is_active() && 'cancelled' != $subscription->status ) { |
|
| 1029 | + if ($subscription->is_active() && 'cancelled' != $subscription->status) { |
|
| 1030 | 1030 | |
| 1031 | - $meta[ 'renewal_date' ] = array( |
|
| 1031 | + $meta['renewal_date'] = array( |
|
| 1032 | 1032 | |
| 1033 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 1034 | - 'value' => getpaid_format_date( $subscription->expiration ), |
|
| 1033 | + 'label' => __('Renews On', 'invoicing'), |
|
| 1034 | + 'value' => getpaid_format_date($subscription->expiration), |
|
| 1035 | 1035 | |
| 1036 | 1036 | ); |
| 1037 | 1037 | |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - if ( $invoice->is_parent() ) { |
|
| 1040 | + if ($invoice->is_parent()) { |
|
| 1041 | 1041 | |
| 1042 | 1042 | // Display the recurring amount. |
| 1043 | - $meta[ 'recurring_total' ] = array( |
|
| 1043 | + $meta['recurring_total'] = array( |
|
| 1044 | 1044 | |
| 1045 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
| 1046 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ), |
|
| 1045 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
| 1046 | + 'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()), |
|
| 1047 | 1047 | |
| 1048 | 1048 | ); |
| 1049 | 1049 | |
@@ -1053,20 +1053,20 @@ discard block |
||
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | // Add the invoice total to the meta. |
| 1056 | - $meta[ 'invoice_total' ] = array( |
|
| 1056 | + $meta['invoice_total'] = array( |
|
| 1057 | 1057 | |
| 1058 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
| 1059 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
| 1058 | + 'label' => __('Total Amount', 'invoicing'), |
|
| 1059 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
| 1060 | 1060 | |
| 1061 | 1061 | ); |
| 1062 | 1062 | |
| 1063 | 1063 | // Provide a way for third party plugins to filter the meta. |
| 1064 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
| 1064 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
| 1065 | 1065 | |
| 1066 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 1066 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 1067 | 1067 | |
| 1068 | 1068 | } |
| 1069 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 1069 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 1070 | 1070 | |
| 1071 | 1071 | /** |
| 1072 | 1072 | * Retrieves the address markup to use on Invoices. |
@@ -1078,29 +1078,29 @@ discard block |
||
| 1078 | 1078 | * @param string $separator How to separate address lines. |
| 1079 | 1079 | * @return string |
| 1080 | 1080 | */ |
| 1081 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 1081 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 1082 | 1082 | |
| 1083 | 1083 | // Retrieve the address markup... |
| 1084 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 1085 | - $format = wpinv_get_full_address_format( $country ); |
|
| 1084 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 1085 | + $format = wpinv_get_full_address_format($country); |
|
| 1086 | 1086 | |
| 1087 | 1087 | // ... and the replacements. |
| 1088 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 1088 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 1089 | 1089 | |
| 1090 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 1090 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 1091 | 1091 | |
| 1092 | 1092 | // Remove unavailable tags. |
| 1093 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 1093 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 1094 | 1094 | |
| 1095 | 1095 | // Clean up white space. |
| 1096 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 1097 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 1096 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 1097 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 1098 | 1098 | |
| 1099 | 1099 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 1100 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 1100 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 1101 | 1101 | |
| 1102 | 1102 | // Add html breaks. |
| 1103 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 1103 | + $formatted_address = implode($separator, $formatted_address); |
|
| 1104 | 1104 | |
| 1105 | 1105 | // We're done! |
| 1106 | 1106 | return $formatted_address; |
@@ -1112,24 +1112,24 @@ discard block |
||
| 1112 | 1112 | * |
| 1113 | 1113 | * @param WPInv_Invoice $invoice |
| 1114 | 1114 | */ |
| 1115 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 1116 | - if ( ! empty( $invoice ) ) { |
|
| 1117 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 1115 | +function wpinv_display_to_address($invoice = 0) { |
|
| 1116 | + if (!empty($invoice)) { |
|
| 1117 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| 1120 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 1120 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 1121 | 1121 | |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
| 1124 | 1124 | * Displays invoice line items. |
| 1125 | 1125 | */ |
| 1126 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 1126 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 1127 | 1127 | |
| 1128 | 1128 | // Prepare the invoice. |
| 1129 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1129 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1130 | 1130 | |
| 1131 | 1131 | // Abort if there is no invoice. |
| 1132 | - if ( 0 == $invoice->get_id() ) { |
|
| 1132 | + if (0 == $invoice->get_id()) { |
|
| 1133 | 1133 | return; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
@@ -1137,110 +1137,110 @@ discard block |
||
| 1137 | 1137 | $columns = apply_filters( |
| 1138 | 1138 | 'getpaid_invoice_line_items_table_columns', |
| 1139 | 1139 | array( |
| 1140 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 1141 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 1142 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 1143 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 1140 | + 'name' => __('Item', 'invoicing'), |
|
| 1141 | + 'price' => __('Price', 'invoicing'), |
|
| 1142 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 1143 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 1144 | 1144 | ), |
| 1145 | 1145 | $invoice |
| 1146 | 1146 | ); |
| 1147 | 1147 | |
| 1148 | 1148 | // Quantities. |
| 1149 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
| 1149 | + if (isset($columns['quantity'])) { |
|
| 1150 | 1150 | |
| 1151 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 1152 | - unset( $columns[ 'quantity' ] ); |
|
| 1151 | + if ('amount' == $invoice->get_template()) { |
|
| 1152 | + unset($columns['quantity']); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 1156 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
| 1155 | + if ('hours' == $invoice->get_template()) { |
|
| 1156 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | - if ( ! wpinv_item_quantities_enabled() ) { |
|
| 1160 | - unset( $columns[ 'quantity' ] ); |
|
| 1159 | + if (!wpinv_item_quantities_enabled()) { |
|
| 1160 | + unset($columns['quantity']); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | // Price. |
| 1166 | - if ( isset( $columns[ 'price' ] ) ) { |
|
| 1166 | + if (isset($columns['price'])) { |
|
| 1167 | 1167 | |
| 1168 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 1169 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
| 1168 | + if ('amount' == $invoice->get_template()) { |
|
| 1169 | + $columns['price'] = __('Amount', 'invoicing'); |
|
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 1173 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
| 1172 | + if ('hours' == $invoice->get_template()) { |
|
| 1173 | + $columns['price'] = __('Rate', 'invoicing'); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | // Sub total. |
| 1179 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
| 1179 | + if (isset($columns['subtotal'])) { |
|
| 1180 | 1180 | |
| 1181 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 1182 | - unset( $columns[ 'subtotal' ] ); |
|
| 1181 | + if ('amount' == $invoice->get_template()) { |
|
| 1182 | + unset($columns['subtotal']); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 1187 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 1188 | 1188 | } |
| 1189 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items' ); |
|
| 1189 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items'); |
|
| 1190 | 1190 | |
| 1191 | 1191 | /** |
| 1192 | 1192 | * @param WPInv_Invoice $invoice |
| 1193 | 1193 | */ |
| 1194 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 1194 | +function wpinv_display_invoice_notes($invoice) { |
|
| 1195 | 1195 | |
| 1196 | - $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' ); |
|
| 1196 | + $notes = wpinv_get_invoice_notes($invoice->ID, 'customer'); |
|
| 1197 | 1197 | |
| 1198 | - if ( empty( $notes ) ) { |
|
| 1198 | + if (empty($notes)) { |
|
| 1199 | 1199 | return; |
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | echo '<div class="wpi_invoice_notes_container">'; |
| 1203 | - echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>'; |
|
| 1203 | + echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>'; |
|
| 1204 | 1204 | echo '<ul class="wpi_invoice_notes">'; |
| 1205 | 1205 | |
| 1206 | - foreach( $notes as $note ) { |
|
| 1207 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 1206 | + foreach ($notes as $note) { |
|
| 1207 | + wpinv_get_invoice_note_line_item($note); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | echo '</ul>'; |
| 1211 | 1211 | echo '</div>'; |
| 1212 | 1212 | } |
| 1213 | -add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' ); |
|
| 1213 | +add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes'); |
|
| 1214 | 1214 | |
| 1215 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
| 1215 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
| 1216 | 1216 | $use_taxes = wpinv_use_taxes(); |
| 1217 | 1217 | |
| 1218 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
| 1218 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
| 1219 | 1219 | ?> |
| 1220 | 1220 | <table class="table table-sm table-bordered table-responsive"> |
| 1221 | 1221 | <tbody> |
| 1222 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
| 1222 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
| 1223 | 1223 | <tr class="row-sub-total"> |
| 1224 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
| 1225 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1224 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
| 1225 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1226 | 1226 | </tr> |
| 1227 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
| 1228 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 1227 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
| 1228 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 1229 | 1229 | <tr class="row-discount"> |
| 1230 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
| 1231 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1230 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
| 1231 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1232 | 1232 | </tr> |
| 1233 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
| 1233 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
| 1234 | 1234 | <?php } ?> |
| 1235 | - <?php if ( $use_taxes ) { ?> |
|
| 1235 | + <?php if ($use_taxes) { ?> |
|
| 1236 | 1236 | <tr class="row-tax"> |
| 1237 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
| 1238 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1237 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
| 1238 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1239 | 1239 | </tr> |
| 1240 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
| 1240 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
| 1241 | 1241 | <?php } ?> |
| 1242 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
| 1243 | - <?php foreach ( $fees as $fee ) { ?> |
|
| 1242 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
| 1243 | + <?php foreach ($fees as $fee) { ?> |
|
| 1244 | 1244 | <tr class="row-fee"> |
| 1245 | 1245 | <td class="rate"><?php echo $fee['label']; ?></td> |
| 1246 | 1246 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1248,36 +1248,36 @@ discard block |
||
| 1248 | 1248 | <?php } ?> |
| 1249 | 1249 | <?php } ?> |
| 1250 | 1250 | <tr class="table-active row-total"> |
| 1251 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
| 1252 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1251 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
| 1252 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1253 | 1253 | </tr> |
| 1254 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
| 1254 | + <?php do_action('wpinv_after_totals'); ?> |
|
| 1255 | 1255 | </tbody> |
| 1256 | 1256 | |
| 1257 | 1257 | </table> |
| 1258 | 1258 | |
| 1259 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
| 1259 | + <?php do_action('wpinv_after_totals_table'); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
| 1263 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1262 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
| 1263 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1264 | 1264 | |
| 1265 | 1265 | ob_start(); |
| 1266 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
| 1267 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 1266 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
| 1267 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 1268 | 1268 | ?> |
| 1269 | 1269 | <div class="wpi-payment-info"> |
| 1270 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
| 1271 | - <?php if ( $gateway_title ) { ?> |
|
| 1272 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
| 1270 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
| 1271 | + <?php if ($gateway_title) { ?> |
|
| 1272 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
| 1273 | 1273 | <?php } ?> |
| 1274 | 1274 | </div> |
| 1275 | 1275 | <?php |
| 1276 | 1276 | } |
| 1277 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
| 1277 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
| 1278 | 1278 | $outout = ob_get_clean(); |
| 1279 | 1279 | |
| 1280 | - if ( $echo ) { |
|
| 1280 | + if ($echo) { |
|
| 1281 | 1281 | echo $outout; |
| 1282 | 1282 | } else { |
| 1283 | 1283 | return $outout; |
@@ -1290,55 +1290,55 @@ discard block |
||
| 1290 | 1290 | function wpinv_display_style() { |
| 1291 | 1291 | |
| 1292 | 1292 | // Make sure that all scripts have been loaded. |
| 1293 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 1294 | - do_action( 'wp_enqueue_scripts' ); |
|
| 1293 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 1294 | + do_action('wp_enqueue_scripts'); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | // Register the invoices style. |
| 1298 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 1298 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 1299 | 1299 | |
| 1300 | 1300 | // Load required styles |
| 1301 | - wp_print_styles( 'open-sans' ); |
|
| 1302 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1303 | - wp_print_styles( 'ayecode-ui' ); |
|
| 1301 | + wp_print_styles('open-sans'); |
|
| 1302 | + wp_print_styles('wpinv-single-style'); |
|
| 1303 | + wp_print_styles('ayecode-ui'); |
|
| 1304 | 1304 | |
| 1305 | 1305 | // Maybe load custom css. |
| 1306 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 1306 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 1307 | 1307 | |
| 1308 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 1309 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 1310 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 1308 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 1309 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 1310 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 1311 | 1311 | echo '<style type="text/css">'; |
| 1312 | 1312 | echo $custom_css; |
| 1313 | 1313 | echo '</style>'; |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | } |
| 1317 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1318 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 1317 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1318 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1319 | 1319 | |
| 1320 | 1320 | function wpinv_checkout_billing_details() { |
| 1321 | - $invoice_id = (int)wpinv_get_invoice_cart_id(); |
|
| 1321 | + $invoice_id = (int) wpinv_get_invoice_cart_id(); |
|
| 1322 | 1322 | if (empty($invoice_id)) { |
| 1323 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1323 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
| 1324 | 1324 | return null; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1327 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1328 | 1328 | if (empty($invoice)) { |
| 1329 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1329 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
| 1330 | 1330 | return null; |
| 1331 | 1331 | } |
| 1332 | 1332 | $user_id = $invoice->get_user_id(); |
| 1333 | 1333 | $user_info = $invoice->get_user_info(); |
| 1334 | - $address_info = wpinv_get_user_address( $user_id ); |
|
| 1334 | + $address_info = wpinv_get_user_address($user_id); |
|
| 1335 | 1335 | |
| 1336 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
| 1336 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
| 1337 | 1337 | $user_info['first_name'] = $user_info['first_name']; |
| 1338 | 1338 | $user_info['last_name'] = $user_info['last_name']; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
| 1341 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
| 1342 | 1342 | $user_info['country'] = $address_info['country']; |
| 1343 | 1343 | $user_info['state'] = $address_info['state']; |
| 1344 | 1344 | $user_info['city'] = $address_info['city']; |
@@ -1354,99 +1354,99 @@ discard block |
||
| 1354 | 1354 | 'address' |
| 1355 | 1355 | ); |
| 1356 | 1356 | |
| 1357 | - foreach ( $address_fields as $field ) { |
|
| 1358 | - if ( empty( $user_info[$field] ) ) { |
|
| 1357 | + foreach ($address_fields as $field) { |
|
| 1358 | + if (empty($user_info[$field])) { |
|
| 1359 | 1359 | $user_info[$field] = $address_info[$field]; |
| 1360 | 1360 | } |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
| 1363 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | 1366 | function wpinv_admin_get_line_items($invoice = array()) { |
| 1367 | 1367 | $item_quantities = wpinv_item_quantities_enabled(); |
| 1368 | 1368 | $use_taxes = wpinv_use_taxes(); |
| 1369 | 1369 | |
| 1370 | - if ( empty( $invoice ) ) { |
|
| 1370 | + if (empty($invoice)) { |
|
| 1371 | 1371 | return NULL; |
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | $cart_items = $invoice->get_cart_details(); |
| 1375 | - if ( empty( $cart_items ) ) { |
|
| 1375 | + if (empty($cart_items)) { |
|
| 1376 | 1376 | return NULL; |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | 1379 | ob_start(); |
| 1380 | 1380 | |
| 1381 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
| 1381 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
| 1382 | 1382 | |
| 1383 | 1383 | $count = 0; |
| 1384 | - foreach ( $cart_items as $key => $cart_item ) { |
|
| 1384 | + foreach ($cart_items as $key => $cart_item) { |
|
| 1385 | 1385 | $item_id = $cart_item['id']; |
| 1386 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
| 1386 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
| 1387 | 1387 | |
| 1388 | 1388 | if (empty($wpi_item)) { |
| 1389 | 1389 | continue; |
| 1390 | 1390 | } |
| 1391 | 1391 | |
| 1392 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
| 1393 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1394 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
| 1392 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
| 1393 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1394 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
| 1395 | 1395 | $can_remove = true; |
| 1396 | 1396 | |
| 1397 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
| 1397 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
| 1398 | 1398 | |
| 1399 | 1399 | $item_tax = ''; |
| 1400 | 1400 | $tax_rate = ''; |
| 1401 | - if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1402 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1403 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1404 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1401 | + if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1402 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1403 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1404 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1405 | 1405 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
| 1406 | 1406 | } |
| 1407 | 1407 | $line_item_tax = $item_tax . $tax_rate; |
| 1408 | 1408 | |
| 1409 | - if ( $line_item_tax === '' ) { |
|
| 1409 | + if ($line_item_tax === '') { |
|
| 1410 | 1410 | $line_item_tax = 0; // Zero tax |
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
| 1413 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
| 1414 | 1414 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
| 1415 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
| 1416 | - if ( $summary !== '' ) { |
|
| 1417 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 1415 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
| 1416 | + if ($summary !== '') { |
|
| 1417 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 1418 | 1418 | } |
| 1419 | 1419 | $line_item .= '</td>'; |
| 1420 | 1420 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
| 1421 | 1421 | |
| 1422 | - if ( $item_quantities ) { |
|
| 1423 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
| 1422 | + if ($item_quantities) { |
|
| 1423 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
| 1424 | 1424 | $can_remove = false; |
| 1425 | 1425 | } |
| 1426 | 1426 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 1427 | 1427 | } else { |
| 1428 | - if ( count( $cart_items ) == 1 ) { |
|
| 1428 | + if (count($cart_items) == 1) { |
|
| 1429 | 1429 | $can_remove = false; |
| 1430 | 1430 | } |
| 1431 | 1431 | } |
| 1432 | 1432 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 1433 | 1433 | |
| 1434 | - if ( $use_taxes ) { |
|
| 1434 | + if ($use_taxes) { |
|
| 1435 | 1435 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1436 | 1436 | } |
| 1437 | 1437 | $line_item .= '<td class="action">'; |
| 1438 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
| 1438 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 1439 | 1439 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 1440 | 1440 | } |
| 1441 | 1441 | $line_item .= '</td>'; |
| 1442 | 1442 | $line_item .= '</tr>'; |
| 1443 | 1443 | |
| 1444 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
| 1444 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
| 1445 | 1445 | |
| 1446 | 1446 | $count++; |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
| 1449 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
| 1450 | 1450 | |
| 1451 | 1451 | return ob_get_clean(); |
| 1452 | 1452 | } |
@@ -1456,70 +1456,70 @@ discard block |
||
| 1456 | 1456 | |
| 1457 | 1457 | // Set current invoice id. |
| 1458 | 1458 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
| 1459 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 1459 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 1460 | 1460 | $payment_form = wpinv_get_default_payment_form(); |
| 1461 | 1461 | |
| 1462 | 1462 | ob_start(); |
| 1463 | - do_action( 'wpinv_checkout_content_before' ); |
|
| 1463 | + do_action('wpinv_checkout_content_before'); |
|
| 1464 | 1464 | |
| 1465 | - if ( wpinv_get_cart_contents() ) { |
|
| 1465 | + if (wpinv_get_cart_contents()) { |
|
| 1466 | 1466 | |
| 1467 | 1467 | // Get the form elements and items. |
| 1468 | - $elements = $invoicing->form_elements->get_form_elements( $payment_form ); |
|
| 1469 | - $items = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() ); |
|
| 1468 | + $elements = $invoicing->form_elements->get_form_elements($payment_form); |
|
| 1469 | + $items = $invoicing->form_elements->convert_checkout_items(wpinv_get_cart_contents(), wpinv_get_invoice_cart()); |
|
| 1470 | 1470 | ?> |
| 1471 | 1471 | <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST"> |
| 1472 | - <?php do_action( 'wpinv_main_checkout_form_top' ); ?> |
|
| 1473 | - <input type='hidden' name='form_id' value='<?php echo esc_attr( $payment_form ); ?>'/> |
|
| 1474 | - <input type='hidden' name='invoice_id' value='<?php echo esc_attr( $wpi_checkout_id ); ?>'/> |
|
| 1472 | + <?php do_action('wpinv_main_checkout_form_top'); ?> |
|
| 1473 | + <input type='hidden' name='form_id' value='<?php echo esc_attr($payment_form); ?>'/> |
|
| 1474 | + <input type='hidden' name='invoice_id' value='<?php echo esc_attr($wpi_checkout_id); ?>'/> |
|
| 1475 | 1475 | <?php |
| 1476 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 1477 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
| 1476 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
| 1477 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
| 1478 | 1478 | |
| 1479 | - foreach ( $elements as $element ) { |
|
| 1480 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $payment_form ); |
|
| 1481 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form ); |
|
| 1479 | + foreach ($elements as $element) { |
|
| 1480 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $payment_form); |
|
| 1481 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form); |
|
| 1482 | 1482 | } |
| 1483 | 1483 | ?> |
| 1484 | 1484 | <div class='wpinv_payment_form_errors alert alert-danger d-none'></div> |
| 1485 | - <?php do_action( 'wpinv_main_checkout_form_bottom' ); ?> |
|
| 1485 | + <?php do_action('wpinv_main_checkout_form_bottom'); ?> |
|
| 1486 | 1486 | </form> |
| 1487 | 1487 | <?php |
| 1488 | 1488 | |
| 1489 | 1489 | } else { |
| 1490 | - do_action( 'wpinv_cart_empty' ); |
|
| 1490 | + do_action('wpinv_cart_empty'); |
|
| 1491 | 1491 | } |
| 1492 | 1492 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
| 1493 | - do_action( 'wpinv_checkout_content_after' ); |
|
| 1493 | + do_action('wpinv_checkout_content_after'); |
|
| 1494 | 1494 | $content = ob_get_clean(); |
| 1495 | 1495 | |
| 1496 | - return str_replace( 'sr-only', '', $content ); |
|
| 1496 | + return str_replace('sr-only', '', $content); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
| 1499 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
| 1500 | 1500 | global $ajax_cart_details; |
| 1501 | 1501 | $ajax_cart_details = $cart_details; |
| 1502 | 1502 | |
| 1503 | 1503 | ob_start(); |
| 1504 | - do_action( 'wpinv_before_checkout_cart' ); |
|
| 1504 | + do_action('wpinv_before_checkout_cart'); |
|
| 1505 | 1505 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
| 1506 | 1506 | echo '<div id="wpinv_checkout_cart_wrap">'; |
| 1507 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
| 1507 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
| 1508 | 1508 | echo '</div>'; |
| 1509 | 1509 | echo '</div>'; |
| 1510 | - do_action( 'wpinv_after_checkout_cart' ); |
|
| 1510 | + do_action('wpinv_after_checkout_cart'); |
|
| 1511 | 1511 | $content = ob_get_clean(); |
| 1512 | 1512 | |
| 1513 | - if ( $echo ) { |
|
| 1513 | + if ($echo) { |
|
| 1514 | 1514 | echo $content; |
| 1515 | 1515 | } else { |
| 1516 | 1516 | return $content; |
| 1517 | 1517 | } |
| 1518 | 1518 | } |
| 1519 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
| 1519 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
| 1520 | 1520 | |
| 1521 | 1521 | function wpinv_empty_cart_message() { |
| 1522 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1522 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | /** |
@@ -1536,83 +1536,83 @@ discard block |
||
| 1536 | 1536 | ) |
| 1537 | 1537 | ); |
| 1538 | 1538 | } |
| 1539 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1539 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1540 | 1540 | |
| 1541 | 1541 | function wpinv_update_cart_button() { |
| 1542 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1542 | + if (!wpinv_item_quantities_enabled()) |
|
| 1543 | 1543 | return; |
| 1544 | 1544 | ?> |
| 1545 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
| 1545 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
| 1546 | 1546 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1547 | 1547 | <?php |
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | 1550 | function wpinv_checkout_cart_columns() { |
| 1551 | 1551 | $default = 3; |
| 1552 | - if ( wpinv_item_quantities_enabled() ) { |
|
| 1552 | + if (wpinv_item_quantities_enabled()) { |
|
| 1553 | 1553 | $default++; |
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | - if ( wpinv_use_taxes() ) { |
|
| 1556 | + if (wpinv_use_taxes()) { |
|
| 1557 | 1557 | $default++; |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
| 1560 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | function wpinv_display_cart_messages() { |
| 1564 | 1564 | global $wpi_session; |
| 1565 | 1565 | |
| 1566 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
| 1566 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
| 1567 | 1567 | |
| 1568 | - if ( $messages ) { |
|
| 1569 | - foreach ( $messages as $message_id => $message ) { |
|
| 1568 | + if ($messages) { |
|
| 1569 | + foreach ($messages as $message_id => $message) { |
|
| 1570 | 1570 | // Try and detect what type of message this is |
| 1571 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
| 1571 | + if (strpos(strtolower($message), 'error')) { |
|
| 1572 | 1572 | $type = 'error'; |
| 1573 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
| 1573 | + } elseif (strpos(strtolower($message), 'success')) { |
|
| 1574 | 1574 | $type = 'success'; |
| 1575 | 1575 | } else { |
| 1576 | 1576 | $type = 'info'; |
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
| 1579 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
| 1580 | 1580 | |
| 1581 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 1581 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 1582 | 1582 | // Loop message codes and display messages |
| 1583 | 1583 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
| 1584 | 1584 | echo '</div>'; |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | // Remove all of the cart saving messages |
| 1588 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
| 1588 | + $wpi_session->set('wpinv_cart_messages', null); |
|
| 1589 | 1589 | } |
| 1590 | 1590 | } |
| 1591 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
| 1591 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
| 1592 | 1592 | |
| 1593 | 1593 | function wpinv_discount_field() { |
| 1594 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
| 1594 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
| 1595 | 1595 | return; // Only show before a payment method has been selected if ajax is disabled |
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | - if ( !wpinv_is_checkout() ) { |
|
| 1598 | + if (!wpinv_is_checkout()) { |
|
| 1599 | 1599 | return; |
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
| 1602 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
| 1603 | 1603 | ?> |
| 1604 | 1604 | <div id="wpinv-discount-field" class="panel panel-default"> |
| 1605 | 1605 | <div class="panel-body"> |
| 1606 | 1606 | <p> |
| 1607 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
| 1608 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
| 1607 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
| 1608 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
| 1609 | 1609 | </p> |
| 1610 | 1610 | <div class="form-group row"> |
| 1611 | 1611 | <div class="col-sm-4"> |
| 1612 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
| 1612 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
| 1613 | 1613 | </div> |
| 1614 | 1614 | <div class="col-sm-3"> |
| 1615 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
| 1615 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
| 1616 | 1616 | </div> |
| 1617 | 1617 | <div style="clear:both"></div> |
| 1618 | 1618 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1625,10 +1625,10 @@ discard block |
||
| 1625 | 1625 | <?php |
| 1626 | 1626 | } |
| 1627 | 1627 | } |
| 1628 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
| 1628 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
| 1629 | 1629 | |
| 1630 | 1630 | function wpinv_agree_to_terms_js() { |
| 1631 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 1631 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 1632 | 1632 | ?> |
| 1633 | 1633 | <script type="text/javascript"> |
| 1634 | 1634 | jQuery(document).ready(function($){ |
@@ -1643,127 +1643,127 @@ discard block |
||
| 1643 | 1643 | <?php |
| 1644 | 1644 | } |
| 1645 | 1645 | } |
| 1646 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
| 1646 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
| 1647 | 1647 | |
| 1648 | -function wpinv_payment_mode_select( $title ) { |
|
| 1649 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 1650 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
| 1651 | - $invoice = wpinv_get_invoice( 0, true ); |
|
| 1648 | +function wpinv_payment_mode_select($title) { |
|
| 1649 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 1650 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
| 1651 | + $invoice = wpinv_get_invoice(0, true); |
|
| 1652 | 1652 | |
| 1653 | 1653 | do_action('wpinv_payment_mode_top'); |
| 1654 | - $invoice_id = $invoice ? (int)$invoice->ID : 0; |
|
| 1655 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
| 1654 | + $invoice_id = $invoice ? (int) $invoice->ID : 0; |
|
| 1655 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
| 1656 | 1656 | ?> |
| 1657 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
| 1658 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
| 1657 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
| 1658 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
| 1659 | 1659 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
| 1660 | 1660 | <div class="panel-heading wpi-payment_methods_title"> |
| 1661 | - <h6 class="panel-title"><?php echo sanitize_text_field( $title ); ?></h6> |
|
| 1661 | + <h6 class="panel-title"><?php echo sanitize_text_field($title); ?></h6> |
|
| 1662 | 1662 | </div> |
| 1663 | 1663 | <div class="panel-body wpi-payment_methods"> |
| 1664 | 1664 | <?php |
| 1665 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
| 1666 | - |
|
| 1667 | - if ( !empty( $gateways ) ) { |
|
| 1668 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1669 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1670 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1671 | - $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id ); |
|
| 1672 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1665 | + do_action('wpinv_payment_mode_before_gateways'); |
|
| 1666 | + |
|
| 1667 | + if (!empty($gateways)) { |
|
| 1668 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 1669 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
| 1670 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
| 1671 | + $gateway_label = wpinv_get_gateway_checkout_label($gateway_id); |
|
| 1672 | + $description = wpinv_get_gateway_description($gateway_id); |
|
| 1673 | 1673 | ?> |
| 1674 | 1674 | <div class="pt-2 pb-2"> |
| 1675 | 1675 | <div class="radio"> |
| 1676 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label> |
|
| 1676 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label> |
|
| 1677 | 1677 | </div> |
| 1678 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
| 1679 | - <?php if ( !empty( $description ) ) { ?> |
|
| 1680 | - <div class="wpi-gateway-desc"><?php _e( $description, 'invoicing' ); ?></div> |
|
| 1678 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
| 1679 | + <?php if (!empty($description)) { ?> |
|
| 1680 | + <div class="wpi-gateway-desc"><?php _e($description, 'invoicing'); ?></div> |
|
| 1681 | 1681 | <?php } ?> |
| 1682 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
| 1682 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
| 1683 | 1683 | </div> |
| 1684 | 1684 | </div> |
| 1685 | 1685 | <?php |
| 1686 | 1686 | } |
| 1687 | 1687 | } else { |
| 1688 | - echo '<div class="alert alert-danger">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
| 1688 | + echo '<div class="alert alert-danger">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
| 1691 | + do_action('wpinv_payment_mode_after_gateways'); |
|
| 1692 | 1692 | ?> |
| 1693 | 1693 | </div> |
| 1694 | 1694 | </div> |
| 1695 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
| 1695 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
| 1696 | 1696 | </div> |
| 1697 | 1697 | <?php |
| 1698 | 1698 | do_action('wpinv_payment_mode_bottom'); |
| 1699 | 1699 | } |
| 1700 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
| 1700 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
| 1701 | 1701 | |
| 1702 | 1702 | function wpinv_checkout_billing_info() { |
| 1703 | - if ( wpinv_is_checkout() ) { |
|
| 1703 | + if (wpinv_is_checkout()) { |
|
| 1704 | 1704 | $billing_details = wpinv_checkout_billing_details(); |
| 1705 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1705 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1706 | 1706 | ?> |
| 1707 | 1707 | <div id="wpinv-fields" class="clearfix"> |
| 1708 | 1708 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
| 1709 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
| 1709 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
| 1710 | 1710 | <div id="wpinv-fields-box" class="panel-body"> |
| 1711 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
| 1711 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
| 1712 | 1712 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1713 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1713 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1714 | 1714 | <?php |
| 1715 | - echo wpinv_html_text( array( |
|
| 1715 | + echo wpinv_html_text(array( |
|
| 1716 | 1716 | 'id' => 'wpinv_first_name', |
| 1717 | 1717 | 'name' => 'wpinv_first_name', |
| 1718 | 1718 | 'value' => $billing_details['first_name'], |
| 1719 | 1719 | 'class' => 'wpi-input form-control', |
| 1720 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
| 1721 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
| 1722 | - ) ); |
|
| 1720 | + 'placeholder' => __('First name', 'invoicing'), |
|
| 1721 | + 'required' => (bool) wpinv_get_option('fname_mandatory'), |
|
| 1722 | + )); |
|
| 1723 | 1723 | ?> |
| 1724 | 1724 | </p> |
| 1725 | 1725 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1726 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1726 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1727 | 1727 | <?php |
| 1728 | - echo wpinv_html_text( array( |
|
| 1728 | + echo wpinv_html_text(array( |
|
| 1729 | 1729 | 'id' => 'wpinv_last_name', |
| 1730 | 1730 | 'name' => 'wpinv_last_name', |
| 1731 | 1731 | 'value' => $billing_details['last_name'], |
| 1732 | 1732 | 'class' => 'wpi-input form-control', |
| 1733 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
| 1734 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
| 1735 | - ) ); |
|
| 1733 | + 'placeholder' => __('Last name', 'invoicing'), |
|
| 1734 | + 'required' => (bool) wpinv_get_option('lname_mandatory'), |
|
| 1735 | + )); |
|
| 1736 | 1736 | ?> |
| 1737 | 1737 | </p> |
| 1738 | 1738 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1739 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1739 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1740 | 1740 | <?php |
| 1741 | - echo wpinv_html_text( array( |
|
| 1741 | + echo wpinv_html_text(array( |
|
| 1742 | 1742 | 'id' => 'wpinv_address', |
| 1743 | 1743 | 'name' => 'wpinv_address', |
| 1744 | 1744 | 'value' => $billing_details['address'], |
| 1745 | 1745 | 'class' => 'wpi-input form-control', |
| 1746 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
| 1747 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
| 1748 | - ) ); |
|
| 1746 | + 'placeholder' => __('Address', 'invoicing'), |
|
| 1747 | + 'required' => (bool) wpinv_get_option('address_mandatory'), |
|
| 1748 | + )); |
|
| 1749 | 1749 | ?> |
| 1750 | 1750 | </p> |
| 1751 | 1751 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1752 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1752 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1753 | 1753 | <?php |
| 1754 | - echo wpinv_html_text( array( |
|
| 1754 | + echo wpinv_html_text(array( |
|
| 1755 | 1755 | 'id' => 'wpinv_city', |
| 1756 | 1756 | 'name' => 'wpinv_city', |
| 1757 | 1757 | 'value' => $billing_details['city'], |
| 1758 | 1758 | 'class' => 'wpi-input form-control', |
| 1759 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
| 1760 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
| 1761 | - ) ); |
|
| 1759 | + 'placeholder' => __('City', 'invoicing'), |
|
| 1760 | + 'required' => (bool) wpinv_get_option('city_mandatory'), |
|
| 1761 | + )); |
|
| 1762 | 1762 | ?> |
| 1763 | 1763 | </p> |
| 1764 | 1764 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1765 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1766 | - <?php echo wpinv_html_select( array( |
|
| 1765 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1766 | + <?php echo wpinv_html_select(array( |
|
| 1767 | 1767 | 'options' => wpinv_get_country_list(), |
| 1768 | 1768 | 'name' => 'wpinv_country', |
| 1769 | 1769 | 'id' => 'wpinv_country', |
@@ -1771,16 +1771,16 @@ discard block |
||
| 1771 | 1771 | 'show_option_all' => false, |
| 1772 | 1772 | 'show_option_none' => false, |
| 1773 | 1773 | 'class' => 'wpi-input form-control wpi_select2', |
| 1774 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 1775 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
| 1776 | - ) ); ?> |
|
| 1774 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 1775 | + 'required' => (bool) wpinv_get_option('country_mandatory'), |
|
| 1776 | + )); ?> |
|
| 1777 | 1777 | </p> |
| 1778 | 1778 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1779 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1779 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1780 | 1780 | <?php |
| 1781 | - $states = wpinv_get_country_states( $selected_country ); |
|
| 1782 | - if( !empty( $states ) ) { |
|
| 1783 | - echo wpinv_html_select( array( |
|
| 1781 | + $states = wpinv_get_country_states($selected_country); |
|
| 1782 | + if (!empty($states)) { |
|
| 1783 | + echo wpinv_html_select(array( |
|
| 1784 | 1784 | 'options' => $states, |
| 1785 | 1785 | 'name' => 'wpinv_state', |
| 1786 | 1786 | 'id' => 'wpinv_state', |
@@ -1788,61 +1788,61 @@ discard block |
||
| 1788 | 1788 | 'show_option_all' => false, |
| 1789 | 1789 | 'show_option_none' => false, |
| 1790 | 1790 | 'class' => 'wpi-input form-control wpi_select2', |
| 1791 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 1792 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1793 | - ) ); |
|
| 1791 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 1792 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
| 1793 | + )); |
|
| 1794 | 1794 | } else { |
| 1795 | - echo wpinv_html_text( array( |
|
| 1795 | + echo wpinv_html_text(array( |
|
| 1796 | 1796 | 'name' => 'wpinv_state', |
| 1797 | 1797 | 'value' => $billing_details['state'], |
| 1798 | 1798 | 'id' => 'wpinv_state', |
| 1799 | 1799 | 'class' => 'wpi-input form-control', |
| 1800 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
| 1801 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1802 | - ) ); |
|
| 1800 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
| 1801 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
| 1802 | + )); |
|
| 1803 | 1803 | } |
| 1804 | 1804 | ?> |
| 1805 | 1805 | </p> |
| 1806 | 1806 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1807 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1807 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1808 | 1808 | <?php |
| 1809 | - echo wpinv_html_text( array( |
|
| 1809 | + echo wpinv_html_text(array( |
|
| 1810 | 1810 | 'name' => 'wpinv_zip', |
| 1811 | 1811 | 'value' => $billing_details['zip'], |
| 1812 | 1812 | 'id' => 'wpinv_zip', |
| 1813 | 1813 | 'class' => 'wpi-input form-control', |
| 1814 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 1815 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
| 1816 | - ) ); |
|
| 1814 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
| 1815 | + 'required' => (bool) wpinv_get_option('zip_mandatory'), |
|
| 1816 | + )); |
|
| 1817 | 1817 | ?> |
| 1818 | 1818 | </p> |
| 1819 | 1819 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1820 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1820 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1821 | 1821 | <?php |
| 1822 | - echo wpinv_html_text( array( |
|
| 1822 | + echo wpinv_html_text(array( |
|
| 1823 | 1823 | 'id' => 'wpinv_phone', |
| 1824 | 1824 | 'name' => 'wpinv_phone', |
| 1825 | 1825 | 'value' => $billing_details['phone'], |
| 1826 | 1826 | 'class' => 'wpi-input form-control', |
| 1827 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
| 1828 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
| 1829 | - ) ); |
|
| 1827 | + 'placeholder' => __('Phone', 'invoicing'), |
|
| 1828 | + 'required' => (bool) wpinv_get_option('phone_mandatory'), |
|
| 1829 | + )); |
|
| 1830 | 1830 | ?> |
| 1831 | 1831 | </p> |
| 1832 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
| 1832 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
| 1833 | 1833 | <div class="clearfix"></div> |
| 1834 | 1834 | </div> |
| 1835 | 1835 | </div> |
| 1836 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
| 1836 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
| 1837 | 1837 | </div> |
| 1838 | 1838 | <?php |
| 1839 | 1839 | } |
| 1840 | 1840 | } |
| 1841 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
| 1841 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
| 1842 | 1842 | |
| 1843 | 1843 | function wpinv_checkout_hidden_fields() { |
| 1844 | 1844 | ?> |
| 1845 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 1845 | + <?php if (is_user_logged_in()) { ?> |
|
| 1846 | 1846 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
| 1847 | 1847 | <?php } ?> |
| 1848 | 1848 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1852,9 +1852,9 @@ discard block |
||
| 1852 | 1852 | function wpinv_checkout_button_purchase() { |
| 1853 | 1853 | ob_start(); |
| 1854 | 1854 | ?> |
| 1855 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
| 1855 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
| 1856 | 1856 | <?php |
| 1857 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
| 1857 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | 1860 | function wpinv_checkout_total() { |
@@ -1863,64 +1863,64 @@ discard block |
||
| 1863 | 1863 | <div id="wpinv_checkout_total" class="panel panel-info"> |
| 1864 | 1864 | <div class="panel-body"> |
| 1865 | 1865 | <?php |
| 1866 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
| 1866 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
| 1867 | 1867 | ?> |
| 1868 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
| 1868 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
| 1869 | 1869 | <?php |
| 1870 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
| 1870 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
| 1871 | 1871 | ?> |
| 1872 | 1872 | </div> |
| 1873 | 1873 | </div> |
| 1874 | 1874 | <?php |
| 1875 | 1875 | } |
| 1876 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
| 1876 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
| 1877 | 1877 | |
| 1878 | 1878 | function wpinv_checkout_submit() { |
| 1879 | 1879 | ?> |
| 1880 | 1880 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
| 1881 | 1881 | <div class="panel-body text-center"> |
| 1882 | 1882 | <?php |
| 1883 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
| 1883 | + do_action('wpinv_purchase_form_before_submit'); |
|
| 1884 | 1884 | wpinv_checkout_hidden_fields(); |
| 1885 | 1885 | echo wpinv_checkout_button_purchase(); |
| 1886 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
| 1886 | + do_action('wpinv_purchase_form_after_submit'); |
|
| 1887 | 1887 | ?> |
| 1888 | 1888 | </div> |
| 1889 | 1889 | </div> |
| 1890 | 1890 | <?php |
| 1891 | 1891 | } |
| 1892 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
| 1892 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
| 1893 | 1893 | |
| 1894 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1895 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1894 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1895 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1896 | 1896 | |
| 1897 | - if ( empty( $invoice ) ) { |
|
| 1897 | + if (empty($invoice)) { |
|
| 1898 | 1898 | return NULL; |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | 1901 | $billing_details = $invoice->get_user_info(); |
| 1902 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 1902 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 1903 | 1903 | |
| 1904 | 1904 | ob_start(); |
| 1905 | 1905 | ?> |
| 1906 | 1906 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1907 | 1907 | <tbody> |
| 1908 | 1908 | <tr class="wpi-receipt-name"> |
| 1909 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1910 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1909 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1910 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1911 | 1911 | </tr> |
| 1912 | 1912 | <tr class="wpi-receipt-email"> |
| 1913 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1914 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1913 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1914 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1915 | 1915 | </tr> |
| 1916 | 1916 | <tr class="wpi-receipt-address"> |
| 1917 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1918 | - <td><?php echo $address_row ;?></td> |
|
| 1917 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1918 | + <td><?php echo $address_row; ?></td> |
|
| 1919 | 1919 | </tr> |
| 1920 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1920 | + <?php if ($billing_details['phone']) { ?> |
|
| 1921 | 1921 | <tr class="wpi-receipt-phone"> |
| 1922 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1923 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1922 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1923 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1924 | 1924 | </tr> |
| 1925 | 1925 | <?php } ?> |
| 1926 | 1926 | </tbody> |
@@ -1928,74 +1928,74 @@ discard block |
||
| 1928 | 1928 | <?php |
| 1929 | 1929 | $output = ob_get_clean(); |
| 1930 | 1930 | |
| 1931 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1931 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1932 | 1932 | |
| 1933 | 1933 | echo $output; |
| 1934 | 1934 | } |
| 1935 | 1935 | |
| 1936 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1937 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1938 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
| 1939 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
| 1936 | +function wpinv_filter_success_page_content($content) { |
|
| 1937 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1938 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
| 1939 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | return $content; |
| 1944 | 1944 | } |
| 1945 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1945 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1946 | 1946 | |
| 1947 | -function wpinv_receipt_actions( $invoice ) { |
|
| 1948 | - if ( !empty( $invoice ) ) { |
|
| 1947 | +function wpinv_receipt_actions($invoice) { |
|
| 1948 | + if (!empty($invoice)) { |
|
| 1949 | 1949 | $actions = array(); |
| 1950 | 1950 | |
| 1951 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
| 1952 | - $actions['print'] = array( |
|
| 1953 | - 'url' => $invoice->get_view_url( true ), |
|
| 1954 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
| 1951 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
| 1952 | + $actions['print'] = array( |
|
| 1953 | + 'url' => $invoice->get_view_url(true), |
|
| 1954 | + 'name' => __('Print Invoice', 'invoicing'), |
|
| 1955 | 1955 | 'class' => 'btn-primary', |
| 1956 | 1956 | ); |
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | - if ( is_user_logged_in() ) { |
|
| 1959 | + if (is_user_logged_in()) { |
|
| 1960 | 1960 | $actions['history'] = array( |
| 1961 | 1961 | 'url' => wpinv_get_history_page_uri(), |
| 1962 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 1962 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 1963 | 1963 | 'class' => 'btn-warning', |
| 1964 | 1964 | ); |
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
| 1967 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
| 1968 | 1968 | |
| 1969 | - if ( !empty( $actions ) ) { |
|
| 1969 | + if (!empty($actions)) { |
|
| 1970 | 1970 | ?> |
| 1971 | 1971 | <div class="wpinv-receipt-actions text-right"> |
| 1972 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
| 1973 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
| 1972 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
| 1973 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
| 1974 | 1974 | <?php } ?> |
| 1975 | 1975 | </div> |
| 1976 | 1976 | <?php |
| 1977 | 1977 | } |
| 1978 | 1978 | } |
| 1979 | 1979 | } |
| 1980 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
| 1980 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
| 1981 | 1981 | |
| 1982 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1983 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1982 | +function wpinv_invoice_link($invoice_id) { |
|
| 1983 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1984 | 1984 | |
| 1985 | - if ( empty( $invoice ) ) { |
|
| 1985 | + if (empty($invoice)) { |
|
| 1986 | 1986 | return NULL; |
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1989 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1990 | 1990 | |
| 1991 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1991 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | |
| 1994 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
| 1995 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
| 1996 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
| 1994 | +function wpinv_invoice_subscription_details($invoice) { |
|
| 1995 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
| 1996 | + $subscription = wpinv_get_subscription($invoice, true); |
|
| 1997 | 1997 | |
| 1998 | - if ( empty( $subscription ) ) { |
|
| 1998 | + if (empty($subscription)) { |
|
| 1999 | 1999 | return; |
| 2000 | 2000 | } |
| 2001 | 2001 | |
@@ -2006,15 +2006,15 @@ discard block |
||
| 2006 | 2006 | $payments = $subscription->get_child_payments(); |
| 2007 | 2007 | ?> |
| 2008 | 2008 | <div class="wpinv-subscriptions-details"> |
| 2009 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
| 2009 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
| 2010 | 2010 | <table class="table"> |
| 2011 | 2011 | <thead> |
| 2012 | 2012 | <tr> |
| 2013 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
| 2014 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
| 2015 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
| 2016 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
| 2017 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
| 2013 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
| 2014 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
| 2015 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
| 2016 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
| 2017 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
| 2018 | 2018 | </tr> |
| 2019 | 2019 | </thead> |
| 2020 | 2020 | <tbody> |
@@ -2028,29 +2028,29 @@ discard block |
||
| 2028 | 2028 | </tbody> |
| 2029 | 2029 | </table> |
| 2030 | 2030 | </div> |
| 2031 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 2031 | + <?php if (!empty($payments)) { ?> |
|
| 2032 | 2032 | <div class="wpinv-renewal-payments"> |
| 2033 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
| 2033 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
| 2034 | 2034 | <table class="table"> |
| 2035 | 2035 | <thead> |
| 2036 | 2036 | <tr> |
| 2037 | 2037 | <th>#</th> |
| 2038 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
| 2039 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
| 2040 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
| 2038 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 2039 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 2040 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
| 2041 | 2041 | </tr> |
| 2042 | 2042 | </thead> |
| 2043 | 2043 | <tbody> |
| 2044 | 2044 | <?php |
| 2045 | 2045 | $i = 1; |
| 2046 | - foreach ( $payments as $payment ) { |
|
| 2046 | + foreach ($payments as $payment) { |
|
| 2047 | 2047 | $invoice_id = $payment->ID; |
| 2048 | 2048 | ?> |
| 2049 | 2049 | <tr> |
| 2050 | - <th scope="row"><?php echo $i;?></th> |
|
| 2051 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
| 2052 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
| 2053 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
| 2050 | + <th scope="row"><?php echo $i; ?></th> |
|
| 2051 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
| 2052 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
| 2053 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
| 2054 | 2054 | </tr> |
| 2055 | 2055 | <?php $i++; } ?> |
| 2056 | 2056 | </tbody> |
@@ -2061,52 +2061,52 @@ discard block |
||
| 2061 | 2061 | } |
| 2062 | 2062 | } |
| 2063 | 2063 | |
| 2064 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 2065 | - if ( empty( $invoice ) ) { |
|
| 2064 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 2065 | + if (empty($invoice)) { |
|
| 2066 | 2066 | return $label; |
| 2067 | 2067 | } |
| 2068 | 2068 | |
| 2069 | 2069 | $prefix_label = ''; |
| 2070 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 2071 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 2072 | - } else if ( $invoice->is_renewal() ) { |
|
| 2073 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 2070 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 2071 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 2072 | + } else if ($invoice->is_renewal()) { |
|
| 2073 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | - if ( $prefix_label != '' ) { |
|
| 2077 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2076 | + if ($prefix_label != '') { |
|
| 2077 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | return $label; |
| 2081 | 2081 | } |
| 2082 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2083 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2084 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2082 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2083 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2084 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2085 | 2085 | |
| 2086 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
| 2086 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
| 2087 | 2087 | |
| 2088 | -function wpinv_invoice_print_description( $invoice ) { |
|
| 2089 | - if ( empty( $invoice ) ) { |
|
| 2088 | +function wpinv_invoice_print_description($invoice) { |
|
| 2089 | + if (empty($invoice)) { |
|
| 2090 | 2090 | return NULL; |
| 2091 | 2091 | } |
| 2092 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
| 2092 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
| 2093 | 2093 | ?> |
| 2094 | 2094 | <div class="row wpinv-lower"> |
| 2095 | 2095 | <div class="col-sm-12 wpinv-description"> |
| 2096 | - <?php echo wpautop( $description ); ?> |
|
| 2096 | + <?php echo wpautop($description); ?> |
|
| 2097 | 2097 | </div> |
| 2098 | 2098 | </div> |
| 2099 | 2099 | <?php |
| 2100 | 2100 | } |
| 2101 | 2101 | } |
| 2102 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
| 2102 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
| 2103 | 2103 | |
| 2104 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
| 2105 | - if ( empty( $invoice ) ) { |
|
| 2104 | +function wpinv_invoice_print_payment_info($invoice) { |
|
| 2105 | + if (empty($invoice)) { |
|
| 2106 | 2106 | return NULL; |
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
| 2109 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
| 2110 | 2110 | ?> |
| 2111 | 2111 | <div class="row wpinv-payments"> |
| 2112 | 2112 | <div class="col-sm-12"> |
@@ -2118,43 +2118,43 @@ discard block |
||
| 2118 | 2118 | } |
| 2119 | 2119 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
| 2120 | 2120 | |
| 2121 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 2122 | - if ( empty( $note ) ) { |
|
| 2121 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 2122 | + if (empty($note)) { |
|
| 2123 | 2123 | return NULL; |
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | - if ( is_int( $note ) ) { |
|
| 2127 | - $note = get_comment( $note ); |
|
| 2126 | + if (is_int($note)) { |
|
| 2127 | + $note = get_comment($note); |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 2130 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 2131 | 2131 | return NULL; |
| 2132 | 2132 | } |
| 2133 | 2133 | |
| 2134 | - $note_classes = array( 'note' ); |
|
| 2135 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 2134 | + $note_classes = array('note'); |
|
| 2135 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 2136 | 2136 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 2137 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 2138 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 2137 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 2138 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 2139 | 2139 | |
| 2140 | 2140 | ob_start(); |
| 2141 | 2141 | ?> |
| 2142 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
| 2142 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
| 2143 | 2143 | <div class="note_content"> |
| 2144 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 2144 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 2145 | 2145 | </div> |
| 2146 | 2146 | <p class="meta"> |
| 2147 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
| 2148 | - <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?> |
|
| 2149 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 2147 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
| 2148 | + <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?> |
|
| 2149 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 2150 | 2150 | <?php } ?> |
| 2151 | 2151 | </p> |
| 2152 | 2152 | </li> |
| 2153 | 2153 | <?php |
| 2154 | 2154 | $note_content = ob_get_clean(); |
| 2155 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 2155 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 2156 | 2156 | |
| 2157 | - if ( $echo ) { |
|
| 2157 | + if ($echo) { |
|
| 2158 | 2158 | echo $note_content; |
| 2159 | 2159 | } else { |
| 2160 | 2160 | return $note_content; |
@@ -2164,43 +2164,43 @@ discard block |
||
| 2164 | 2164 | function wpinv_invalid_invoice_content() { |
| 2165 | 2165 | global $post; |
| 2166 | 2166 | |
| 2167 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 2167 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 2168 | 2168 | |
| 2169 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 2170 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 2171 | - if ( is_user_logged_in() ) { |
|
| 2172 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2173 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2174 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 2169 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 2170 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 2171 | + if (is_user_logged_in()) { |
|
| 2172 | + if (wpinv_require_login_to_checkout()) { |
|
| 2173 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2174 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | } |
| 2177 | 2177 | } else { |
| 2178 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2179 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2180 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 2178 | + if (wpinv_require_login_to_checkout()) { |
|
| 2179 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2180 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | } |
| 2183 | 2183 | } |
| 2184 | 2184 | } else { |
| 2185 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 2185 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 2186 | 2186 | } |
| 2187 | 2187 | ?> |
| 2188 | 2188 | <div class="row wpinv-row-invalid"> |
| 2189 | 2189 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 2190 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 2190 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 2191 | 2191 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 2192 | 2192 | </div> |
| 2193 | 2193 | </div> |
| 2194 | 2194 | <?php |
| 2195 | 2195 | } |
| 2196 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 2196 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 2197 | 2197 | |
| 2198 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2199 | -function wpinv_force_company_name_field(){ |
|
| 2198 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2199 | +function wpinv_force_company_name_field() { |
|
| 2200 | 2200 | $invoice = wpinv_get_invoice_cart(); |
| 2201 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
| 2202 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 2203 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
| 2201 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
| 2202 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 2203 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
| 2204 | 2204 | ?> |
| 2205 | 2205 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 2206 | 2206 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2226,21 +2226,21 @@ discard block |
||
| 2226 | 2226 | * @return string |
| 2227 | 2227 | */ |
| 2228 | 2228 | function wpinv_get_policy_text() { |
| 2229 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 2229 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 2230 | 2230 | |
| 2231 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 2231 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 2232 | 2232 | |
| 2233 | - if(!$privacy_page_id){ |
|
| 2234 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 2233 | + if (!$privacy_page_id) { |
|
| 2234 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 2237 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 2238 | 2238 | |
| 2239 | 2239 | $find_replace = array( |
| 2240 | 2240 | '[wpinv_privacy_policy]' => $privacy_link, |
| 2241 | 2241 | ); |
| 2242 | 2242 | |
| 2243 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 2243 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 2244 | 2244 | |
| 2245 | 2245 | return wp_kses_post(wpautop($privacy_text)); |
| 2246 | 2246 | } |
@@ -2249,25 +2249,25 @@ discard block |
||
| 2249 | 2249 | /** |
| 2250 | 2250 | * Allows the user to set their own price for an invoice item |
| 2251 | 2251 | */ |
| 2252 | -function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) { |
|
| 2252 | +function wpinv_checkout_cart_item_name_your_price($cart_item, $key) { |
|
| 2253 | 2253 | |
| 2254 | 2254 | //Ensure we have an item id |
| 2255 | - if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) { |
|
| 2255 | + if (!is_array($cart_item) || empty($cart_item['id'])) { |
|
| 2256 | 2256 | return; |
| 2257 | 2257 | } |
| 2258 | 2258 | |
| 2259 | 2259 | //Fetch the item |
| 2260 | 2260 | $item_id = $cart_item['id']; |
| 2261 | - $item = new WPInv_Item( $item_id ); |
|
| 2261 | + $item = new WPInv_Item($item_id); |
|
| 2262 | 2262 | |
| 2263 | - if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) { |
|
| 2263 | + if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) { |
|
| 2264 | 2264 | return; |
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | 2267 | //Fetch the dynamic pricing "strings" |
| 2268 | - $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) ); |
|
| 2269 | - $minimum_price_text = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) ); |
|
| 2270 | - $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) ); |
|
| 2268 | + $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing'))); |
|
| 2269 | + $minimum_price_text = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing'))); |
|
| 2270 | + $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing'))); |
|
| 2271 | 2271 | |
| 2272 | 2272 | //Display a "name_your_price" button |
| 2273 | 2273 | echo " — <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>"; |
@@ -2276,7 +2276,7 @@ discard block |
||
| 2276 | 2276 | echo '<div class="name-your-price-miniform">'; |
| 2277 | 2277 | |
| 2278 | 2278 | //Maybe display the recommended price |
| 2279 | - if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) { |
|
| 2279 | + if ($item->get_price() > 0 && !empty($suggested_price_text)) { |
|
| 2280 | 2280 | $suggested_price = $item->get_the_price(); |
| 2281 | 2281 | echo "<div>$suggested_price_text — $suggested_price</div>"; |
| 2282 | 2282 | } |
@@ -2284,198 +2284,198 @@ discard block |
||
| 2284 | 2284 | //Display the update price form |
| 2285 | 2285 | $symbol = wpinv_currency_symbol(); |
| 2286 | 2286 | $position = wpinv_currency_position(); |
| 2287 | - $minimum = esc_attr( $item->get_minimum_price() ); |
|
| 2288 | - $price = esc_attr( $cart_item['item_price'] ); |
|
| 2289 | - $update = esc_attr__( "Update", 'invoicing' ); |
|
| 2287 | + $minimum = esc_attr($item->get_minimum_price()); |
|
| 2288 | + $price = esc_attr($cart_item['item_price']); |
|
| 2289 | + $update = esc_attr__("Update", 'invoicing'); |
|
| 2290 | 2290 | |
| 2291 | 2291 | //Ensure it supports dynamic prici |
| 2292 | - if( $price < $minimum ) { |
|
| 2292 | + if ($price < $minimum) { |
|
| 2293 | 2293 | $price = $minimum; |
| 2294 | 2294 | } |
| 2295 | 2295 | |
| 2296 | 2296 | echo '<label>'; |
| 2297 | 2297 | echo $position != 'right' ? $symbol . ' ' : ''; |
| 2298 | 2298 | echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />"; |
| 2299 | - echo $position == 'right' ? ' ' . $symbol : '' ; |
|
| 2299 | + echo $position == 'right' ? ' ' . $symbol : ''; |
|
| 2300 | 2300 | echo "</label>"; |
| 2301 | 2301 | echo "<input type='hidden' value='$item_id' class='wpi-field-item' />"; |
| 2302 | 2302 | echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>"; |
| 2303 | 2303 | |
| 2304 | 2304 | //Maybe display the minimum price |
| 2305 | - if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) { |
|
| 2306 | - $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) ); |
|
| 2305 | + if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) { |
|
| 2306 | + $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price())); |
|
| 2307 | 2307 | echo "<div>$minimum_price_text — $minimum_price</div>"; |
| 2308 | 2308 | } |
| 2309 | 2309 | |
| 2310 | 2310 | echo "</div>"; |
| 2311 | 2311 | |
| 2312 | 2312 | } |
| 2313 | -add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 ); |
|
| 2313 | +add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2); |
|
| 2314 | 2314 | |
| 2315 | 2315 | function wpinv_oxygen_fix_conflict() { |
| 2316 | 2316 | global $ct_ignore_post_types; |
| 2317 | 2317 | |
| 2318 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 2318 | + if (!is_array($ct_ignore_post_types)) { |
|
| 2319 | 2319 | $ct_ignore_post_types = array(); |
| 2320 | 2320 | } |
| 2321 | 2321 | |
| 2322 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
| 2322 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
| 2323 | 2323 | |
| 2324 | - foreach ( $post_types as $post_type ) { |
|
| 2324 | + foreach ($post_types as $post_type) { |
|
| 2325 | 2325 | $ct_ignore_post_types[] = $post_type; |
| 2326 | 2326 | |
| 2327 | 2327 | // Ignore post type |
| 2328 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 2328 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 2329 | 2329 | } |
| 2330 | 2330 | |
| 2331 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 2332 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 2331 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 2332 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 2333 | 2333 | } |
| 2334 | 2334 | |
| 2335 | 2335 | /** |
| 2336 | 2336 | * Helper function to display a payment form on the frontend. |
| 2337 | 2337 | */ |
| 2338 | -function getpaid_display_payment_form( $form ) { |
|
| 2338 | +function getpaid_display_payment_form($form) { |
|
| 2339 | 2339 | global $invoicing; |
| 2340 | 2340 | |
| 2341 | 2341 | // Ensure that it is published. |
| 2342 | - if ( 'publish' != get_post_status( $form ) ) { |
|
| 2342 | + if ('publish' != get_post_status($form)) { |
|
| 2343 | 2343 | return aui()->alert( |
| 2344 | 2344 | array( |
| 2345 | 2345 | 'type' => 'warning', |
| 2346 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 2346 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
| 2347 | 2347 | ) |
| 2348 | 2348 | ); |
| 2349 | 2349 | } |
| 2350 | 2350 | |
| 2351 | 2351 | // Get the form. |
| 2352 | - $form = new GetPaid_Payment_Form( $form ); |
|
| 2353 | - $html = wpinv_get_template_html( 'payment-forms/form.php', compact( 'form' ) ); |
|
| 2354 | - return str_replace( 'sr-only', '', $html ); |
|
| 2352 | + $form = new GetPaid_Payment_Form($form); |
|
| 2353 | + $html = wpinv_get_template_html('payment-forms/form.php', compact('form')); |
|
| 2354 | + return str_replace('sr-only', '', $html); |
|
| 2355 | 2355 | |
| 2356 | 2356 | } |
| 2357 | 2357 | |
| 2358 | 2358 | /** |
| 2359 | 2359 | * Helper function to display a item payment form on the frontend. |
| 2360 | 2360 | */ |
| 2361 | -function getpaid_display_item_payment_form( $items ) { |
|
| 2361 | +function getpaid_display_item_payment_form($items) { |
|
| 2362 | 2362 | global $invoicing; |
| 2363 | 2363 | |
| 2364 | - foreach ( array_keys( $items ) as $id ) { |
|
| 2365 | - if ( 'publish' != get_post_status( $id ) ) { |
|
| 2366 | - unset( $items[ $id ] ); |
|
| 2364 | + foreach (array_keys($items) as $id) { |
|
| 2365 | + if ('publish' != get_post_status($id)) { |
|
| 2366 | + unset($items[$id]); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | } |
| 2369 | 2369 | |
| 2370 | - if ( empty( $items ) ) { |
|
| 2370 | + if (empty($items)) { |
|
| 2371 | 2371 | return aui()->alert( |
| 2372 | 2372 | array( |
| 2373 | 2373 | 'type' => 'warning', |
| 2374 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 2374 | + 'content' => __('No published items found', 'invoicing'), |
|
| 2375 | 2375 | ) |
| 2376 | 2376 | ); |
| 2377 | 2377 | } |
| 2378 | 2378 | |
| 2379 | - $item_key = getpaid_convert_items_to_string( $items ); |
|
| 2379 | + $item_key = getpaid_convert_items_to_string($items); |
|
| 2380 | 2380 | |
| 2381 | 2381 | // Get the form elements and items. |
| 2382 | 2382 | $form = wpinv_get_default_payment_form(); |
| 2383 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
| 2384 | - $items = $invoicing->form_elements->convert_normal_items( $items ); |
|
| 2383 | + $elements = $invoicing->form_elements->get_form_elements($form); |
|
| 2384 | + $items = $invoicing->form_elements->convert_normal_items($items); |
|
| 2385 | 2385 | |
| 2386 | 2386 | ob_start(); |
| 2387 | 2387 | echo "<form class='wpinv_payment_form'>"; |
| 2388 | - do_action( 'wpinv_payment_form_top' ); |
|
| 2388 | + do_action('wpinv_payment_form_top'); |
|
| 2389 | 2389 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
| 2390 | 2390 | echo "<input type='hidden' name='form_items' value='$item_key'/>"; |
| 2391 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 2392 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
| 2391 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
| 2392 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
| 2393 | 2393 | |
| 2394 | - foreach ( $elements as $element ) { |
|
| 2395 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
| 2396 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
| 2394 | + foreach ($elements as $element) { |
|
| 2395 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form); |
|
| 2396 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form); |
|
| 2397 | 2397 | } |
| 2398 | 2398 | |
| 2399 | 2399 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
| 2400 | - do_action( 'wpinv_payment_form_bottom' ); |
|
| 2400 | + do_action('wpinv_payment_form_bottom'); |
|
| 2401 | 2401 | echo '</form>'; |
| 2402 | 2402 | |
| 2403 | 2403 | $content = ob_get_clean(); |
| 2404 | - return str_replace( 'sr-only', '', $content ); |
|
| 2404 | + return str_replace('sr-only', '', $content); |
|
| 2405 | 2405 | } |
| 2406 | 2406 | |
| 2407 | 2407 | /** |
| 2408 | 2408 | * Helper function to display an invoice payment form on the frontend. |
| 2409 | 2409 | */ |
| 2410 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 2410 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 2411 | 2411 | global $invoicing; |
| 2412 | 2412 | |
| 2413 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 2413 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 2414 | 2414 | |
| 2415 | - if ( empty( $invoice ) ) { |
|
| 2415 | + if (empty($invoice)) { |
|
| 2416 | 2416 | return aui()->alert( |
| 2417 | 2417 | array( |
| 2418 | 2418 | 'type' => 'warning', |
| 2419 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 2419 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 2420 | 2420 | ) |
| 2421 | 2421 | ); |
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | - if ( $invoice->is_paid() ) { |
|
| 2424 | + if ($invoice->is_paid()) { |
|
| 2425 | 2425 | return aui()->alert( |
| 2426 | 2426 | array( |
| 2427 | 2427 | 'type' => 'warning', |
| 2428 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 2428 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 2429 | 2429 | ) |
| 2430 | 2430 | ); |
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | // Get the form elements and items. |
| 2434 | - $form = wpinv_get_default_payment_form(); |
|
| 2435 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
| 2436 | - $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
| 2434 | + $form = wpinv_get_default_payment_form(); |
|
| 2435 | + $elements = $invoicing->form_elements->get_form_elements($form); |
|
| 2436 | + $items = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice); |
|
| 2437 | 2437 | |
| 2438 | 2438 | ob_start(); |
| 2439 | 2439 | echo "<form class='wpinv_payment_form'>"; |
| 2440 | - do_action( 'wpinv_payment_form_top' ); |
|
| 2440 | + do_action('wpinv_payment_form_top'); |
|
| 2441 | 2441 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
| 2442 | 2442 | echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>"; |
| 2443 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 2444 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
| 2443 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
| 2444 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
| 2445 | 2445 | |
| 2446 | - foreach ( $elements as $element ) { |
|
| 2447 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
| 2448 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
| 2446 | + foreach ($elements as $element) { |
|
| 2447 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form); |
|
| 2448 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form); |
|
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | 2451 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
| 2452 | - do_action( 'wpinv_payment_form_bottom' ); |
|
| 2452 | + do_action('wpinv_payment_form_bottom'); |
|
| 2453 | 2453 | echo '</form>'; |
| 2454 | 2454 | |
| 2455 | 2455 | $content = ob_get_clean(); |
| 2456 | - return str_replace( 'sr-only', '', $content ); |
|
| 2456 | + return str_replace('sr-only', '', $content); |
|
| 2457 | 2457 | } |
| 2458 | 2458 | |
| 2459 | 2459 | /** |
| 2460 | 2460 | * Helper function to convert item string to array. |
| 2461 | 2461 | */ |
| 2462 | -function getpaid_convert_items_to_array( $items ) { |
|
| 2463 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 2462 | +function getpaid_convert_items_to_array($items) { |
|
| 2463 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 2464 | 2464 | $prepared = array(); |
| 2465 | 2465 | |
| 2466 | - foreach ( $items as $item ) { |
|
| 2467 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 2466 | + foreach ($items as $item) { |
|
| 2467 | + $data = array_map('trim', explode('|', $item)); |
|
| 2468 | 2468 | |
| 2469 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 2469 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 2470 | 2470 | continue; |
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | $quantity = 1; |
| 2474 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 2474 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 2475 | 2475 | $quantity = $data[1]; |
| 2476 | 2476 | } |
| 2477 | 2477 | |
| 2478 | - $prepared[ $data[0] ] = $quantity; |
|
| 2478 | + $prepared[$data[0]] = $quantity; |
|
| 2479 | 2479 | |
| 2480 | 2480 | } |
| 2481 | 2481 | |
@@ -2485,13 +2485,13 @@ discard block |
||
| 2485 | 2485 | /** |
| 2486 | 2486 | * Helper function to convert item array to string. |
| 2487 | 2487 | */ |
| 2488 | -function getpaid_convert_items_to_string( $items ) { |
|
| 2488 | +function getpaid_convert_items_to_string($items) { |
|
| 2489 | 2489 | $prepared = array(); |
| 2490 | 2490 | |
| 2491 | - foreach ( $items as $item => $quantity ) { |
|
| 2491 | + foreach ($items as $item => $quantity) { |
|
| 2492 | 2492 | $prepared[] = "$item|$quantity"; |
| 2493 | 2493 | } |
| 2494 | - return implode( ',', $prepared ); |
|
| 2494 | + return implode(',', $prepared); |
|
| 2495 | 2495 | } |
| 2496 | 2496 | |
| 2497 | 2497 | /** |
@@ -2499,22 +2499,22 @@ discard block |
||
| 2499 | 2499 | * |
| 2500 | 2500 | * Provide a label and one of $form, $items or $invoice. |
| 2501 | 2501 | */ |
| 2502 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 2503 | - $label = sanitize_text_field( $label ); |
|
| 2502 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 2503 | + $label = sanitize_text_field($label); |
|
| 2504 | 2504 | $nonce = wp_create_nonce('getpaid_ajax_form'); |
| 2505 | 2505 | |
| 2506 | - if ( ! empty( $form ) ) { |
|
| 2507 | - $form = esc_attr( $form ); |
|
| 2506 | + if (!empty($form)) { |
|
| 2507 | + $form = esc_attr($form); |
|
| 2508 | 2508 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
| 2509 | 2509 | } |
| 2510 | 2510 | |
| 2511 | - if ( ! empty( $items ) ) { |
|
| 2512 | - $items = esc_attr( $items ); |
|
| 2511 | + if (!empty($items)) { |
|
| 2512 | + $items = esc_attr($items); |
|
| 2513 | 2513 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
| 2514 | 2514 | } |
| 2515 | 2515 | |
| 2516 | - if ( ! empty( $invoice ) ) { |
|
| 2517 | - $invoice = esc_attr( $invoice ); |
|
| 2516 | + if (!empty($invoice)) { |
|
| 2517 | + $invoice = esc_attr($invoice); |
|
| 2518 | 2518 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; |
| 2519 | 2519 | } |
| 2520 | 2520 | |
@@ -2525,15 +2525,15 @@ discard block |
||
| 2525 | 2525 | * |
| 2526 | 2526 | * @param WPInv_Invoice $invoice |
| 2527 | 2527 | */ |
| 2528 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 2529 | - if ( empty( $invoice->description ) ) { |
|
| 2528 | +function getpaid_the_invoice_description($invoice) { |
|
| 2529 | + if (empty($invoice->description)) { |
|
| 2530 | 2530 | return; |
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | - $description = wp_kses_post( $invoice->description ); |
|
| 2533 | + $description = wp_kses_post($invoice->description); |
|
| 2534 | 2534 | echo "<div style='color: #616161; font-size: 90%; margin-bottom: 20px;'><em>$description</em></div>"; |
| 2535 | 2535 | } |
| 2536 | -add_action( 'wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description' ); |
|
| 2536 | +add_action('wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description'); |
|
| 2537 | 2537 | |
| 2538 | 2538 | /** |
| 2539 | 2539 | * Render element on a form. |
@@ -2541,41 +2541,41 @@ discard block |
||
| 2541 | 2541 | * @param array $element |
| 2542 | 2542 | * @param GetPaid_Payment_Form $form |
| 2543 | 2543 | */ |
| 2544 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 2544 | +function getpaid_payment_form_element($element, $form) { |
|
| 2545 | 2545 | |
| 2546 | 2546 | // Set up the args. |
| 2547 | - $element_type = trim( $element['type'] ); |
|
| 2547 | + $element_type = trim($element['type']); |
|
| 2548 | 2548 | $element['form'] = $form; |
| 2549 | - extract( $element ); |
|
| 2549 | + extract($element); |
|
| 2550 | 2550 | |
| 2551 | 2551 | // Try to locate the appropriate template. |
| 2552 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 2552 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 2553 | 2553 | |
| 2554 | 2554 | // Abort if this is not our element. |
| 2555 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 2555 | + if (empty($located) || !file_exists($located)) { |
|
| 2556 | 2556 | return; |
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | 2559 | // Generate the class and id of the element. |
| 2560 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 2561 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 2560 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 2561 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 2562 | 2562 | |
| 2563 | 2563 | // Echo the opening wrapper. |
| 2564 | 2564 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
| 2565 | 2565 | |
| 2566 | 2566 | // Fires before displaying a given element type's content. |
| 2567 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 2567 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 2568 | 2568 | |
| 2569 | 2569 | // Include the template for the element. |
| 2570 | 2570 | include $located; |
| 2571 | 2571 | |
| 2572 | 2572 | // Fires after displaying a given element type's content. |
| 2573 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 2573 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 2574 | 2574 | |
| 2575 | 2575 | // Echo the closing wrapper. |
| 2576 | 2576 | echo '</div>'; |
| 2577 | 2577 | } |
| 2578 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 2578 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 2579 | 2579 | |
| 2580 | 2580 | /** |
| 2581 | 2581 | * Shows a list of gateways that support recurring payments. |
@@ -2583,16 +2583,16 @@ discard block |
||
| 2583 | 2583 | function wpinv_get_recurring_gateways_text() { |
| 2584 | 2584 | $gateways = array(); |
| 2585 | 2585 | |
| 2586 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 2587 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 2588 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 2586 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 2587 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 2588 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 2589 | 2589 | } |
| 2590 | 2590 | } |
| 2591 | 2591 | |
| 2592 | - if ( empty( $gateways ) ) { |
|
| 2593 | - return "<span class='form-text text-danger'>" . __( 'No active gateway supports subscription payments.', 'invoicing' ) ."</span>"; |
|
| 2592 | + if (empty($gateways)) { |
|
| 2593 | + return "<span class='form-text text-danger'>" . __('No active gateway supports subscription payments.', 'invoicing') . "</span>"; |
|
| 2594 | 2594 | } |
| 2595 | 2595 | |
| 2596 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
| 2596 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
| 2597 | 2597 | |
| 2598 | 2598 | } |
@@ -7,18 +7,18 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Fetch the invoice. |
| 13 | -$invoice = new WPInv_Invoice( $GLOBALS['post'] ); |
|
| 13 | +$invoice = new WPInv_Invoice($GLOBALS['post']); |
|
| 14 | 14 | |
| 15 | 15 | // Abort if it does not exist. |
| 16 | -if ( $invoice->get_id() == 0 ) { |
|
| 16 | +if ($invoice->get_id() == 0) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | // Fires before printing an invoice. |
| 21 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); |
|
| 21 | +do_action('wpinv_invoice_print_before_display', $invoice); |
|
| 22 | 22 | |
| 23 | 23 | ?><!DOCTYPE html> |
| 24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | <head> |
| 29 | 29 | |
| 30 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 30 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 31 | 31 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 32 | 32 | |
| 33 | 33 | <meta name="robots" content="noindex,nofollow"> |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | <title><?php wp_title() ?></title> |
| 38 | 38 | |
| 39 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
| 39 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
| 40 | 40 | |
| 41 | 41 | </head> |
| 42 | 42 | |
| 43 | 43 | <body class="body wpinv wpinv-print"> |
| 44 | 44 | |
| 45 | - <?php do_action( 'getpaid_invoice', $invoice ); ?> |
|
| 45 | + <?php do_action('getpaid_invoice', $invoice); ?> |
|
| 46 | 46 | |
| 47 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
| 47 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
| 48 | 48 | |
| 49 | 49 | </body> |
| 50 | 50 | |
@@ -7,25 +7,25 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Totals rows. |
| 13 | 13 | $totals = apply_filters( |
| 14 | 14 | 'getpaid_payment_form_cart_table_totals', |
| 15 | 15 | array( |
| 16 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 17 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 18 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 19 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 16 | + 'tax' => __('Tax', 'invoicing'), |
|
| 17 | + 'discount' => __('Discount', 'invoicing'), |
|
| 18 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 19 | + 'total' => __('Total', 'invoicing'), |
|
| 20 | 20 | ), |
| 21 | 21 | $form |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | -if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) { |
|
| 25 | - unset( $totals['tax'] ); |
|
| 24 | +if (!wpinv_use_taxes() && isset($totals['tax'])) { |
|
| 25 | + unset($totals['tax']); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals ); |
|
| 28 | +do_action('getpaid_before_payment_form_cart_totals', $form, $totals); |
|
| 29 | 29 | |
| 30 | 30 | $tax = 0; |
| 31 | 31 | $sub_total = 0; |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | $discount = 0; |
| 34 | 34 | |
| 35 | 35 | // Calculate totals. |
| 36 | -foreach ( $form->get_items() as $item ) { |
|
| 36 | +foreach ($form->get_items() as $item) { |
|
| 37 | 37 | $amount = $item->get_price(); |
| 38 | 38 | |
| 39 | 39 | // Include the tax. |
| 40 | - if ( wpinv_use_taxes() ) { |
|
| 41 | - $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, $item->get_id() ); |
|
| 40 | + if (wpinv_use_taxes()) { |
|
| 41 | + $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, $item->get_id()); |
|
| 42 | 42 | |
| 43 | - if ( wpinv_prices_include_tax() ) { |
|
| 44 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
| 43 | + if (wpinv_prices_include_tax()) { |
|
| 44 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
| 45 | 45 | $item_tax = $amount - $pre_tax; |
| 46 | 46 | } else { |
| 47 | 47 | $pre_tax = $amount; |
@@ -53,41 +53,41 @@ discard block |
||
| 53 | 53 | $total = $sub_total + $tax; |
| 54 | 54 | |
| 55 | 55 | } else { |
| 56 | - $total = $total + $amount; |
|
| 56 | + $total = $total + $amount; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | ?> |
| 62 | 62 | <div class='border-top getpaid-payment-form-items-cart-totals'> |
| 63 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
| 64 | - <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr( $key ); ?>"> |
|
| 63 | + <?php foreach ($totals as $key => $label) : ?> |
|
| 64 | + <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr($key); ?>"> |
|
| 65 | 65 | <div class="row"> |
| 66 | 66 | <div class="col-12 offset-sm-6 col-sm-4"> |
| 67 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 67 | + <?php echo sanitize_text_field($label); ?> |
|
| 68 | 68 | </div> |
| 69 | - <div class="col-12 col-sm-2 getpaid-form-cart-totals-total-<?php echo esc_attr( $key ); ?>"> |
|
| 69 | + <div class="col-12 col-sm-2 getpaid-form-cart-totals-total-<?php echo esc_attr($key); ?>"> |
|
| 70 | 70 | <?php |
| 71 | - do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
| 71 | + do_action("getpaid_payment_form_cart_totals_$key", $form); |
|
| 72 | 72 | |
| 73 | 73 | // Total tax. |
| 74 | - if ( 'tax' == $key ) { |
|
| 75 | - echo wpinv_price( wpinv_format_amount( $tax ) ); |
|
| 74 | + if ('tax' == $key) { |
|
| 75 | + echo wpinv_price(wpinv_format_amount($tax)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Total discount. |
| 79 | - if ( 'discount' == $key ) { |
|
| 80 | - echo wpinv_price( wpinv_format_amount( $discount ) ); |
|
| 79 | + if ('discount' == $key) { |
|
| 80 | + echo wpinv_price(wpinv_format_amount($discount)); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Sub total. |
| 84 | - if ( 'subtotal' == $key ) { |
|
| 85 | - echo wpinv_price( wpinv_format_amount( $sub_total ) ); |
|
| 84 | + if ('subtotal' == $key) { |
|
| 85 | + echo wpinv_price(wpinv_format_amount($sub_total)); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Total. |
| 89 | - if ( 'total' == $key ) { |
|
| 90 | - echo wpinv_price( wpinv_format_amount( $total ) ); |
|
| 89 | + if ('total' == $key) { |
|
| 90 | + echo wpinv_price(wpinv_format_amount($total)); |
|
| 91 | 91 | } |
| 92 | 92 | ?> |
| 93 | 93 | </div> |
@@ -97,4 +97,4 @@ discard block |
||
| 97 | 97 | </div> |
| 98 | 98 | |
| 99 | 99 | <?php |
| 100 | -do_action( 'getpaid_payment_form_cart_totals', $form, $totals ); |
|
| 100 | +do_action('getpaid_payment_form_cart_totals', $form, $totals); |
|
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -18,22 +18,22 @@ discard block |
||
| 18 | 18 | <?php |
| 19 | 19 | |
| 20 | 20 | // Fires when printing the header. |
| 21 | - do_action( 'getpaid_invoice_header', $invoice ); |
|
| 21 | + do_action('getpaid_invoice_header', $invoice); |
|
| 22 | 22 | |
| 23 | 23 | // Print the opening wrapper. |
| 24 | 24 | echo '<div class="container bg-white border mt-4 mb-4 p-4 position-relative flex-grow-1">'; |
| 25 | 25 | |
| 26 | 26 | // Fires when printing the invoice details. |
| 27 | - do_action( 'getpaid_invoice_details', $invoice ); |
|
| 27 | + do_action('getpaid_invoice_details', $invoice); |
|
| 28 | 28 | |
| 29 | 29 | // Fires when printing the invoice line items. |
| 30 | - do_action( 'getpaid_invoice_line_items', $invoice ); |
|
| 30 | + do_action('getpaid_invoice_line_items', $invoice); |
|
| 31 | 31 | |
| 32 | 32 | // Print the closing wrapper. |
| 33 | 33 | echo '</div>'; |
| 34 | 34 | |
| 35 | 35 | // Fires when printing the invoice footer. |
| 36 | - do_action( 'getpaid_invoice_footer', $invoice ); |
|
| 36 | + do_action('getpaid_invoice_footer', $invoice); |
|
| 37 | 37 | |
| 38 | 38 | ?> |
| 39 | 39 | |
@@ -8,37 +8,37 @@ discard block |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | // Totals rows. |
| 14 | 14 | $totals = apply_filters( |
| 15 | 15 | 'getpaid_invoice_line_totals', |
| 16 | 16 | array( |
| 17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 18 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 19 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 20 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 18 | + 'tax' => __('Tax', 'invoicing'), |
|
| 19 | + 'discount' => __('Discount', 'invoicing'), |
|
| 20 | + 'total' => __('Total', 'invoicing'), |
|
| 21 | 21 | ), |
| 22 | 22 | $invoice |
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | -if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) { |
|
| 26 | - unset( $totals['tax'] ); |
|
| 25 | +if (!wpinv_use_taxes() && isset($totals['tax'])) { |
|
| 26 | + unset($totals['tax']); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals ); |
|
| 29 | +do_action('getpaid_before_invoice_line_totals', $invoice, $totals); |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | <div class='border-top getpaid-invoice-line-totals'> |
| 33 | 33 | |
| 34 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
| 34 | + <?php foreach ($totals as $key => $label) : ?> |
|
| 35 | 35 | |
| 36 | - <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>"> |
|
| 36 | + <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>"> |
|
| 37 | 37 | |
| 38 | 38 | <div class="row"> |
| 39 | 39 | |
| 40 | 40 | <div class="col-12 offset-sm-6 col-sm-4 getpaid-invoice-line-totals-label"> |
| 41 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 41 | + <?php echo sanitize_text_field($label); ?> |
|
| 42 | 42 | </div> |
| 43 | 43 | |
| 44 | 44 | <div class="col-12 col-sm-2 getpaid-invoice-line-totals-value"> |
@@ -46,26 +46,26 @@ discard block |
||
| 46 | 46 | <?php |
| 47 | 47 | |
| 48 | 48 | // Fires when printing a cart total. |
| 49 | - do_action( "getpaid_invoice_cart_totals_$key", $invoice ); |
|
| 49 | + do_action("getpaid_invoice_cart_totals_$key", $invoice); |
|
| 50 | 50 | |
| 51 | 51 | // Total tax. |
| 52 | - if ( 'tax' == $key ) { |
|
| 53 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
| 52 | + if ('tax' == $key) { |
|
| 53 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Total discount. |
| 57 | - if ( 'discount' == $key ) { |
|
| 58 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
| 57 | + if ('discount' == $key) { |
|
| 58 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Sub total. |
| 62 | - if ( 'subtotal' == $key ) { |
|
| 63 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
| 62 | + if ('subtotal' == $key) { |
|
| 63 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Total. |
| 67 | - if ( 'total' == $key ) { |
|
| 68 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
| 67 | + if ('total' == $key) { |
|
| 68 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | ?> |
@@ -80,4 +80,4 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | </div> <!-- end .getpaid-invoice-line-totals --> |
| 82 | 82 | |
| 83 | -<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?> |
|
| 83 | +<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?> |
|
@@ -7,50 +7,50 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | - <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?> |
|
| 14 | + <?php do_action('getpaid_before_invoice_meta', $invoice); ?> |
|
| 15 | 15 | <div class="getpaid-invoice-meta-data"> |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?> |
|
| 18 | + <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?> |
|
| 19 | 19 | <table class="table table-bordered"> |
| 20 | 20 | <tbody> |
| 21 | 21 | |
| 22 | - <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?> |
|
| 23 | - <?php foreach ( $meta as $key => $data ) : ?> |
|
| 22 | + <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?> |
|
| 23 | + <?php foreach ($meta as $key => $data) : ?> |
|
| 24 | 24 | |
| 25 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
| 25 | + <?php if (!empty($data['value'])) : ?> |
|
| 26 | 26 | |
| 27 | - <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?> |
|
| 27 | + <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?> |
|
| 28 | 28 | |
| 29 | - <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 29 | + <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 30 | 30 | |
| 31 | 31 | <th> |
| 32 | - <?php echo sanitize_text_field( $data['label'] ); ?> |
|
| 32 | + <?php echo sanitize_text_field($data['label']); ?> |
|
| 33 | 33 | </th> |
| 34 | 34 | |
| 35 | 35 | <td> |
| 36 | - <?php echo wp_kses_post( $data['value'] ); ?> |
|
| 36 | + <?php echo wp_kses_post($data['value']); ?> |
|
| 37 | 37 | </td> |
| 38 | 38 | |
| 39 | 39 | </tr> |
| 40 | 40 | |
| 41 | - <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?> |
|
| 41 | + <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?> |
|
| 42 | 42 | |
| 43 | 43 | <?php endif; ?> |
| 44 | 44 | |
| 45 | 45 | <?php endforeach; ?> |
| 46 | - <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?> |
|
| 46 | + <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?> |
|
| 47 | 47 | |
| 48 | 48 | </tbody> |
| 49 | 49 | </table> |
| 50 | - <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?> |
|
| 50 | + <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?> |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | </div> |
| 54 | - <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?> |
|
| 54 | + <?php do_action('getpaid_after_invoice_meta', $invoice); ?> |
|
| 55 | 55 | |
| 56 | 56 | <?php |