@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | class WPInv_Invoice extends GetPaid_Data { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Which data store to load. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 17 | + * Which data store to load. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | 21 | protected $data_store_name = 'invoice'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * This is the name of this object type. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 24 | + * This is the name of this object type. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $object_type = 'invoice'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.19 |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $data = array( |
|
| 37 | - 'parent_id' => 0, |
|
| 38 | - 'status' => 'wpi-pending', |
|
| 39 | - 'version' => '', |
|
| 40 | - 'date_created' => null, |
|
| 31 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.19 |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $data = array( |
|
| 37 | + 'parent_id' => 0, |
|
| 38 | + 'status' => 'wpi-pending', |
|
| 39 | + 'version' => '', |
|
| 40 | + 'date_created' => null, |
|
| 41 | 41 | 'date_modified' => null, |
| 42 | 42 | 'due_date' => null, |
| 43 | 43 | 'completed_date' => null, |
@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | 'transaction_id' => '', |
| 80 | 80 | 'currency' => '', |
| 81 | 81 | 'disable_taxes' => false, |
| 82 | - 'subscription_id' => null, |
|
| 83 | - 'is_viewed' => false, |
|
| 84 | - 'email_cc' => '', |
|
| 85 | - 'template' => 'quantity', // hours, amount only |
|
| 82 | + 'subscription_id' => null, |
|
| 83 | + 'is_viewed' => false, |
|
| 84 | + 'email_cc' => '', |
|
| 85 | + 'template' => 'quantity', // hours, amount only |
|
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Stores meta in cache for future reads. |
|
| 90 | - * |
|
| 91 | - * A group must be set to to enable caching. |
|
| 92 | - * |
|
| 93 | - * @var string |
|
| 94 | - */ |
|
| 95 | - protected $cache_group = 'getpaid_invoices'; |
|
| 89 | + * Stores meta in cache for future reads. |
|
| 90 | + * |
|
| 91 | + * A group must be set to to enable caching. |
|
| 92 | + * |
|
| 93 | + * @var string |
|
| 94 | + */ |
|
| 95 | + protected $cache_group = 'getpaid_invoices'; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Stores a reference to the original WP_Post object |
@@ -106,104 +106,104 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @var int |
| 108 | 108 | */ |
| 109 | - protected $recurring_item = null; |
|
| 109 | + protected $recurring_item = null; |
|
| 110 | 110 | |
| 111 | - /** |
|
| 111 | + /** |
|
| 112 | 112 | * Stores an array of item totals. |
| 113 | - * |
|
| 114 | - * e.g $totals['discount'] = array( |
|
| 115 | - * 'initial' => 10, |
|
| 116 | - * 'recurring' => 10, |
|
| 117 | - * ) |
|
| 113 | + * |
|
| 114 | + * e.g $totals['discount'] = array( |
|
| 115 | + * 'initial' => 10, |
|
| 116 | + * 'recurring' => 10, |
|
| 117 | + * ) |
|
| 118 | 118 | * |
| 119 | 119 | * @var array |
| 120 | 120 | */ |
| 121 | - protected $totals = array(); |
|
| 121 | + protected $totals = array(); |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Stores the status transition information. |
|
| 125 | - * |
|
| 126 | - * @since 1.0.19 |
|
| 127 | - * @var bool |
|
| 128 | - */ |
|
| 129 | - protected $status_transition = false; |
|
| 123 | + /** |
|
| 124 | + * Stores the status transition information. |
|
| 125 | + * |
|
| 126 | + * @since 1.0.19 |
|
| 127 | + * @var bool |
|
| 128 | + */ |
|
| 129 | + protected $status_transition = false; |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 133 | - * |
|
| 134 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 135 | - */ |
|
| 132 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 133 | + * |
|
| 134 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 135 | + */ |
|
| 136 | 136 | public function __construct( $invoice = false ) { |
| 137 | 137 | |
| 138 | 138 | parent::__construct( $invoice ); |
| 139 | 139 | |
| 140 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 141 | - $this->set_id( $invoice ); |
|
| 142 | - } elseif ( $invoice instanceof self ) { |
|
| 143 | - $this->set_id( $invoice->get_id() ); |
|
| 144 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 145 | - $this->set_id( $invoice->ID ); |
|
| 146 | - } elseif ( is_array( $invoice ) ) { |
|
| 147 | - $this->set_props( $invoice ); |
|
| 148 | - |
|
| 149 | - if ( isset( $invoice['ID'] ) ) { |
|
| 150 | - $this->set_id( $invoice['ID'] ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 154 | - $this->set_id( $invoice_id ); |
|
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - }else { |
|
| 160 | - $this->set_object_read( true ); |
|
| 161 | - } |
|
| 140 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 141 | + $this->set_id( $invoice ); |
|
| 142 | + } elseif ( $invoice instanceof self ) { |
|
| 143 | + $this->set_id( $invoice->get_id() ); |
|
| 144 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 145 | + $this->set_id( $invoice->ID ); |
|
| 146 | + } elseif ( is_array( $invoice ) ) { |
|
| 147 | + $this->set_props( $invoice ); |
|
| 148 | + |
|
| 149 | + if ( isset( $invoice['ID'] ) ) { |
|
| 150 | + $this->set_id( $invoice['ID'] ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 154 | + $this->set_id( $invoice_id ); |
|
| 155 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 156 | + $this->set_id( $invoice_id ); |
|
| 157 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 158 | + $this->set_id( $invoice_id ); |
|
| 159 | + }else { |
|
| 160 | + $this->set_object_read( true ); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | // Load the datastore. |
| 164 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 164 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 165 | 165 | |
| 166 | - if ( $this->get_id() > 0 ) { |
|
| 166 | + if ( $this->get_id() > 0 ) { |
|
| 167 | 167 | $this->post = get_post( $this->get_id() ); |
| 168 | 168 | $this->ID = $this->get_id(); |
| 169 | - $this->data_store->read( $this ); |
|
| 169 | + $this->data_store->read( $this ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * Given an invoice key/number, it returns its id. |
|
| 176 | - * |
|
| 177 | - * |
|
| 178 | - * @static |
|
| 179 | - * @param string $value The invoice key or number |
|
| 180 | - * @param string $field Either key, transaction_id or number. |
|
| 181 | - * @since 1.0.15 |
|
| 182 | - * @return int |
|
| 183 | - */ |
|
| 184 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 175 | + * Given an invoice key/number, it returns its id. |
|
| 176 | + * |
|
| 177 | + * |
|
| 178 | + * @static |
|
| 179 | + * @param string $value The invoice key or number |
|
| 180 | + * @param string $field Either key, transaction_id or number. |
|
| 181 | + * @since 1.0.15 |
|
| 182 | + * @return int |
|
| 183 | + */ |
|
| 184 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 185 | 185 | global $wpdb; |
| 186 | 186 | |
| 187 | - // Trim the value. |
|
| 188 | - $value = trim( $value ); |
|
| 187 | + // Trim the value. |
|
| 188 | + $value = trim( $value ); |
|
| 189 | 189 | |
| 190 | - if ( empty( $value ) ) { |
|
| 191 | - return 0; |
|
| 192 | - } |
|
| 190 | + if ( empty( $value ) ) { |
|
| 191 | + return 0; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | // Valid fields. |
| 195 | 195 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 196 | 196 | |
| 197 | - // Ensure a field has been passed. |
|
| 198 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 199 | - return 0; |
|
| 200 | - } |
|
| 197 | + // Ensure a field has been passed. |
|
| 198 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 199 | + return 0; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - // Maybe retrieve from the cache. |
|
| 203 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 204 | - if ( ! empty( $invoice_id ) ) { |
|
| 205 | - return $invoice_id; |
|
| 206 | - } |
|
| 202 | + // Maybe retrieve from the cache. |
|
| 203 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 204 | + if ( ! empty( $invoice_id ) ) { |
|
| 205 | + return $invoice_id; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | // Fetch from the db. |
| 209 | 209 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - if ( empty( $invoice_id ) ) { |
|
| 215 | - return 0; |
|
| 216 | - } |
|
| 214 | + if ( empty( $invoice_id ) ) { |
|
| 215 | + return 0; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - // Update the cache with our data |
|
| 219 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 218 | + // Update the cache with our data |
|
| 219 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 220 | 220 | |
| 221 | - return $invoice_id; |
|
| 221 | + return $invoice_id; |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -244,73 +244,73 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | - * Get parent invoice ID. |
|
| 248 | - * |
|
| 249 | - * @since 1.0.19 |
|
| 250 | - * @param string $context View or edit context. |
|
| 251 | - * @return int |
|
| 252 | - */ |
|
| 253 | - public function get_parent_id( $context = 'view' ) { |
|
| 254 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 247 | + * Get parent invoice ID. |
|
| 248 | + * |
|
| 249 | + * @since 1.0.19 |
|
| 250 | + * @param string $context View or edit context. |
|
| 251 | + * @return int |
|
| 252 | + */ |
|
| 253 | + public function get_parent_id( $context = 'view' ) { |
|
| 254 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Get parent invoice. |
|
| 259 | - * |
|
| 260 | - * @since 1.0.19 |
|
| 261 | - * @return WPInv_Invoice |
|
| 262 | - */ |
|
| 258 | + * Get parent invoice. |
|
| 259 | + * |
|
| 260 | + * @since 1.0.19 |
|
| 261 | + * @return WPInv_Invoice |
|
| 262 | + */ |
|
| 263 | 263 | public function get_parent_payment() { |
| 264 | 264 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | - * Alias for self::get_parent_payment(). |
|
| 269 | - * |
|
| 270 | - * @since 1.0.19 |
|
| 271 | - * @return WPInv_Invoice |
|
| 272 | - */ |
|
| 268 | + * Alias for self::get_parent_payment(). |
|
| 269 | + * |
|
| 270 | + * @since 1.0.19 |
|
| 271 | + * @return WPInv_Invoice |
|
| 272 | + */ |
|
| 273 | 273 | public function get_parent() { |
| 274 | 274 | return $this->get_parent_payment(); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | - * Get invoice status. |
|
| 279 | - * |
|
| 280 | - * @since 1.0.19 |
|
| 281 | - * @param string $context View or edit context. |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 284 | - public function get_status( $context = 'view' ) { |
|
| 285 | - return $this->get_prop( 'status', $context ); |
|
| 286 | - } |
|
| 278 | + * Get invoice status. |
|
| 279 | + * |
|
| 280 | + * @since 1.0.19 |
|
| 281 | + * @param string $context View or edit context. |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | + public function get_status( $context = 'view' ) { |
|
| 285 | + return $this->get_prop( 'status', $context ); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - /** |
|
| 289 | - * Retrieves an array of possible invoice statuses. |
|
| 290 | - * |
|
| 291 | - * @since 1.0.19 |
|
| 292 | - * @return array |
|
| 293 | - */ |
|
| 294 | - public function get_all_statuses() { |
|
| 295 | - |
|
| 296 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 297 | - |
|
| 298 | - // For backwards compatibility. |
|
| 299 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 288 | + /** |
|
| 289 | + * Retrieves an array of possible invoice statuses. |
|
| 290 | + * |
|
| 291 | + * @since 1.0.19 |
|
| 292 | + * @return array |
|
| 293 | + */ |
|
| 294 | + public function get_all_statuses() { |
|
| 295 | + |
|
| 296 | + $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 297 | + |
|
| 298 | + // For backwards compatibility. |
|
| 299 | + if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 300 | 300 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 301 | - } |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - return $statuses; |
|
| 303 | + return $statuses; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * Get invoice status nice name. |
|
| 308 | - * |
|
| 309 | - * @since 1.0.19 |
|
| 310 | - * @return string |
|
| 311 | - */ |
|
| 307 | + * Get invoice status nice name. |
|
| 308 | + * |
|
| 309 | + * @since 1.0.19 |
|
| 310 | + * @return string |
|
| 311 | + */ |
|
| 312 | 312 | public function get_status_nicename() { |
| 313 | - $statuses = $this->get_all_statuses(); |
|
| 313 | + $statuses = $this->get_all_statuses(); |
|
| 314 | 314 | |
| 315 | 315 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 316 | 316 | |
@@ -318,20 +318,20 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | - * Get plugin version when the invoice was created. |
|
| 322 | - * |
|
| 323 | - * @since 1.0.19 |
|
| 324 | - * @param string $context View or edit context. |
|
| 325 | - * @return string |
|
| 326 | - */ |
|
| 327 | - public function get_version( $context = 'view' ) { |
|
| 328 | - return $this->get_prop( 'version', $context ); |
|
| 329 | - } |
|
| 321 | + * Get plugin version when the invoice was created. |
|
| 322 | + * |
|
| 323 | + * @since 1.0.19 |
|
| 324 | + * @param string $context View or edit context. |
|
| 325 | + * @return string |
|
| 326 | + */ |
|
| 327 | + public function get_version( $context = 'view' ) { |
|
| 328 | + return $this->get_prop( 'version', $context ); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * @deprecated |
|
| 333 | - */ |
|
| 334 | - public function get_invoice_date( $formatted = true ) { |
|
| 331 | + /** |
|
| 332 | + * @deprecated |
|
| 333 | + */ |
|
| 334 | + public function get_invoice_date( $formatted = true ) { |
|
| 335 | 335 | $date_completed = $this->get_date_completed(); |
| 336 | 336 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 337 | 337 | |
@@ -348,187 +348,187 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
| 351 | - * Get date when the invoice was created. |
|
| 352 | - * |
|
| 353 | - * @since 1.0.19 |
|
| 354 | - * @param string $context View or edit context. |
|
| 355 | - * @return string |
|
| 356 | - */ |
|
| 357 | - public function get_date_created( $context = 'view' ) { |
|
| 358 | - return $this->get_prop( 'date_created', $context ); |
|
| 359 | - } |
|
| 351 | + * Get date when the invoice was created. |
|
| 352 | + * |
|
| 353 | + * @since 1.0.19 |
|
| 354 | + * @param string $context View or edit context. |
|
| 355 | + * @return string |
|
| 356 | + */ |
|
| 357 | + public function get_date_created( $context = 'view' ) { |
|
| 358 | + return $this->get_prop( 'date_created', $context ); |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Alias for self::get_date_created(). |
|
| 363 | - * |
|
| 364 | - * @since 1.0.19 |
|
| 365 | - * @param string $context View or edit context. |
|
| 366 | - * @return string |
|
| 367 | - */ |
|
| 368 | - public function get_created_date( $context = 'view' ) { |
|
| 369 | - return $this->get_date_created( $context ); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Get GMT date when the invoice was created. |
|
| 374 | - * |
|
| 375 | - * @since 1.0.19 |
|
| 376 | - * @param string $context View or edit context. |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 361 | + /** |
|
| 362 | + * Alias for self::get_date_created(). |
|
| 363 | + * |
|
| 364 | + * @since 1.0.19 |
|
| 365 | + * @param string $context View or edit context. |
|
| 366 | + * @return string |
|
| 367 | + */ |
|
| 368 | + public function get_created_date( $context = 'view' ) { |
|
| 369 | + return $this->get_date_created( $context ); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Get GMT date when the invoice was created. |
|
| 374 | + * |
|
| 375 | + * @since 1.0.19 |
|
| 376 | + * @param string $context View or edit context. |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 380 | 380 | $date = $this->get_date_created( $context ); |
| 381 | 381 | |
| 382 | 382 | if ( $date ) { |
| 383 | 383 | $date = get_gmt_from_date( $date ); |
| 384 | 384 | } |
| 385 | - return $date; |
|
| 385 | + return $date; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | - * Get date when the invoice was last modified. |
|
| 390 | - * |
|
| 391 | - * @since 1.0.19 |
|
| 392 | - * @param string $context View or edit context. |
|
| 393 | - * @return string |
|
| 394 | - */ |
|
| 395 | - public function get_date_modified( $context = 'view' ) { |
|
| 396 | - return $this->get_prop( 'date_modified', $context ); |
|
| 397 | - } |
|
| 389 | + * Get date when the invoice was last modified. |
|
| 390 | + * |
|
| 391 | + * @since 1.0.19 |
|
| 392 | + * @param string $context View or edit context. |
|
| 393 | + * @return string |
|
| 394 | + */ |
|
| 395 | + public function get_date_modified( $context = 'view' ) { |
|
| 396 | + return $this->get_prop( 'date_modified', $context ); |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Alias for self::get_date_modified(). |
|
| 401 | - * |
|
| 402 | - * @since 1.0.19 |
|
| 403 | - * @param string $context View or edit context. |
|
| 404 | - * @return string |
|
| 405 | - */ |
|
| 406 | - public function get_modified_date( $context = 'view' ) { |
|
| 407 | - return $this->get_date_modified( $context ); |
|
| 399 | + /** |
|
| 400 | + * Alias for self::get_date_modified(). |
|
| 401 | + * |
|
| 402 | + * @since 1.0.19 |
|
| 403 | + * @param string $context View or edit context. |
|
| 404 | + * @return string |
|
| 405 | + */ |
|
| 406 | + public function get_modified_date( $context = 'view' ) { |
|
| 407 | + return $this->get_date_modified( $context ); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | - * Get GMT date when the invoice was last modified. |
|
| 412 | - * |
|
| 413 | - * @since 1.0.19 |
|
| 414 | - * @param string $context View or edit context. |
|
| 415 | - * @return string |
|
| 416 | - */ |
|
| 417 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 411 | + * Get GMT date when the invoice was last modified. |
|
| 412 | + * |
|
| 413 | + * @since 1.0.19 |
|
| 414 | + * @param string $context View or edit context. |
|
| 415 | + * @return string |
|
| 416 | + */ |
|
| 417 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 418 | 418 | $date = $this->get_date_modified( $context ); |
| 419 | 419 | |
| 420 | 420 | if ( $date ) { |
| 421 | 421 | $date = get_gmt_from_date( $date ); |
| 422 | 422 | } |
| 423 | - return $date; |
|
| 423 | + return $date; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | - * Get the invoice due date. |
|
| 428 | - * |
|
| 429 | - * @since 1.0.19 |
|
| 430 | - * @param string $context View or edit context. |
|
| 431 | - * @return string |
|
| 432 | - */ |
|
| 433 | - public function get_due_date( $context = 'view' ) { |
|
| 434 | - return $this->get_prop( 'due_date', $context ); |
|
| 427 | + * Get the invoice due date. |
|
| 428 | + * |
|
| 429 | + * @since 1.0.19 |
|
| 430 | + * @param string $context View or edit context. |
|
| 431 | + * @return string |
|
| 432 | + */ |
|
| 433 | + public function get_due_date( $context = 'view' ) { |
|
| 434 | + return $this->get_prop( 'due_date', $context ); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
| 438 | - * Alias for self::get_due_date(). |
|
| 439 | - * |
|
| 440 | - * @since 1.0.19 |
|
| 441 | - * @param string $context View or edit context. |
|
| 442 | - * @return string |
|
| 443 | - */ |
|
| 444 | - public function get_date_due( $context = 'view' ) { |
|
| 445 | - return $this->get_due_date( $context ); |
|
| 438 | + * Alias for self::get_due_date(). |
|
| 439 | + * |
|
| 440 | + * @since 1.0.19 |
|
| 441 | + * @param string $context View or edit context. |
|
| 442 | + * @return string |
|
| 443 | + */ |
|
| 444 | + public function get_date_due( $context = 'view' ) { |
|
| 445 | + return $this->get_due_date( $context ); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | - * Get the invoice GMT due date. |
|
| 450 | - * |
|
| 451 | - * @since 1.0.19 |
|
| 452 | - * @param string $context View or edit context. |
|
| 453 | - * @return string |
|
| 454 | - */ |
|
| 455 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 449 | + * Get the invoice GMT due date. |
|
| 450 | + * |
|
| 451 | + * @since 1.0.19 |
|
| 452 | + * @param string $context View or edit context. |
|
| 453 | + * @return string |
|
| 454 | + */ |
|
| 455 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 456 | 456 | $date = $this->get_due_date( $context ); |
| 457 | 457 | |
| 458 | 458 | if ( $date ) { |
| 459 | 459 | $date = get_gmt_from_date( $date ); |
| 460 | 460 | } |
| 461 | - return $date; |
|
| 461 | + return $date; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
| 465 | - * Alias for self::get_due_date_gmt(). |
|
| 466 | - * |
|
| 467 | - * @since 1.0.19 |
|
| 468 | - * @param string $context View or edit context. |
|
| 469 | - * @return string |
|
| 470 | - */ |
|
| 471 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 472 | - return $this->get_due_date_gmt( $context ); |
|
| 465 | + * Alias for self::get_due_date_gmt(). |
|
| 466 | + * |
|
| 467 | + * @since 1.0.19 |
|
| 468 | + * @param string $context View or edit context. |
|
| 469 | + * @return string |
|
| 470 | + */ |
|
| 471 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 472 | + return $this->get_due_date_gmt( $context ); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | - * Get date when the invoice was completed. |
|
| 477 | - * |
|
| 478 | - * @since 1.0.19 |
|
| 479 | - * @param string $context View or edit context. |
|
| 480 | - * @return string |
|
| 481 | - */ |
|
| 482 | - public function get_completed_date( $context = 'view' ) { |
|
| 483 | - return $this->get_prop( 'completed_date', $context ); |
|
| 476 | + * Get date when the invoice was completed. |
|
| 477 | + * |
|
| 478 | + * @since 1.0.19 |
|
| 479 | + * @param string $context View or edit context. |
|
| 480 | + * @return string |
|
| 481 | + */ |
|
| 482 | + public function get_completed_date( $context = 'view' ) { |
|
| 483 | + return $this->get_prop( 'completed_date', $context ); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
| 487 | - * Alias for self::get_completed_date(). |
|
| 488 | - * |
|
| 489 | - * @since 1.0.19 |
|
| 490 | - * @param string $context View or edit context. |
|
| 491 | - * @return string |
|
| 492 | - */ |
|
| 493 | - public function get_date_completed( $context = 'view' ) { |
|
| 494 | - return $this->get_completed_date( $context ); |
|
| 487 | + * Alias for self::get_completed_date(). |
|
| 488 | + * |
|
| 489 | + * @since 1.0.19 |
|
| 490 | + * @param string $context View or edit context. |
|
| 491 | + * @return string |
|
| 492 | + */ |
|
| 493 | + public function get_date_completed( $context = 'view' ) { |
|
| 494 | + return $this->get_completed_date( $context ); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | - * Get GMT date when the invoice was was completed. |
|
| 499 | - * |
|
| 500 | - * @since 1.0.19 |
|
| 501 | - * @param string $context View or edit context. |
|
| 502 | - * @return string |
|
| 503 | - */ |
|
| 504 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 498 | + * Get GMT date when the invoice was was completed. |
|
| 499 | + * |
|
| 500 | + * @since 1.0.19 |
|
| 501 | + * @param string $context View or edit context. |
|
| 502 | + * @return string |
|
| 503 | + */ |
|
| 504 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 505 | 505 | $date = $this->get_completed_date( $context ); |
| 506 | 506 | |
| 507 | 507 | if ( $date ) { |
| 508 | 508 | $date = get_gmt_from_date( $date ); |
| 509 | 509 | } |
| 510 | - return $date; |
|
| 510 | + return $date; |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
| 514 | - * Alias for self::get_completed_date_gmt(). |
|
| 515 | - * |
|
| 516 | - * @since 1.0.19 |
|
| 517 | - * @param string $context View or edit context. |
|
| 518 | - * @return string |
|
| 519 | - */ |
|
| 520 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 521 | - return $this->get_completed_date_gmt( $context ); |
|
| 514 | + * Alias for self::get_completed_date_gmt(). |
|
| 515 | + * |
|
| 516 | + * @since 1.0.19 |
|
| 517 | + * @param string $context View or edit context. |
|
| 518 | + * @return string |
|
| 519 | + */ |
|
| 520 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 521 | + return $this->get_completed_date_gmt( $context ); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
| 525 | - * Get the invoice number. |
|
| 526 | - * |
|
| 527 | - * @since 1.0.19 |
|
| 528 | - * @param string $context View or edit context. |
|
| 529 | - * @return string |
|
| 530 | - */ |
|
| 531 | - public function get_number( $context = 'view' ) { |
|
| 525 | + * Get the invoice number. |
|
| 526 | + * |
|
| 527 | + * @since 1.0.19 |
|
| 528 | + * @param string $context View or edit context. |
|
| 529 | + * @return string |
|
| 530 | + */ |
|
| 531 | + public function get_number( $context = 'view' ) { |
|
| 532 | 532 | $number = $this->get_prop( 'number', $context ); |
| 533 | 533 | |
| 534 | 534 | if ( empty( $number ) ) { |
@@ -536,17 +536,17 @@ discard block |
||
| 536 | 536 | $this->set_number( $number ); |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - return $number; |
|
| 539 | + return $number; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
| 543 | - * Get the invoice key. |
|
| 544 | - * |
|
| 545 | - * @since 1.0.19 |
|
| 546 | - * @param string $context View or edit context. |
|
| 547 | - * @return string |
|
| 548 | - */ |
|
| 549 | - public function get_key( $context = 'view' ) { |
|
| 543 | + * Get the invoice key. |
|
| 544 | + * |
|
| 545 | + * @since 1.0.19 |
|
| 546 | + * @param string $context View or edit context. |
|
| 547 | + * @return string |
|
| 548 | + */ |
|
| 549 | + public function get_key( $context = 'view' ) { |
|
| 550 | 550 | $key = $this->get_prop( 'key', $context ); |
| 551 | 551 | |
| 552 | 552 | if ( empty( $key ) ) { |
@@ -554,24 +554,24 @@ discard block |
||
| 554 | 554 | $this->set_key( $key ); |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - return $key; |
|
| 557 | + return $key; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
| 561 | - * Get the invoice type. |
|
| 562 | - * |
|
| 563 | - * @since 1.0.19 |
|
| 564 | - * @param string $context View or edit context. |
|
| 565 | - * @return string |
|
| 566 | - */ |
|
| 567 | - public function get_type( $context = 'view' ) { |
|
| 561 | + * Get the invoice type. |
|
| 562 | + * |
|
| 563 | + * @since 1.0.19 |
|
| 564 | + * @param string $context View or edit context. |
|
| 565 | + * @return string |
|
| 566 | + */ |
|
| 567 | + public function get_type( $context = 'view' ) { |
|
| 568 | 568 | return $this->get_prop( 'type', $context ); |
| 569 | - } |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - /** |
|
| 572 | - * @deprecated |
|
| 573 | - */ |
|
| 574 | - public function get_invoice_quote_type( $post_id ) { |
|
| 571 | + /** |
|
| 572 | + * @deprecated |
|
| 573 | + */ |
|
| 574 | + public function get_invoice_quote_type( $post_id ) { |
|
| 575 | 575 | if ( empty( $post_id ) ) { |
| 576 | 576 | return ''; |
| 577 | 577 | } |
@@ -588,35 +588,35 @@ discard block |
||
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
| 591 | - * Get the invoice post type. |
|
| 592 | - * |
|
| 593 | - * @since 1.0.19 |
|
| 594 | - * @param string $context View or edit context. |
|
| 595 | - * @return string |
|
| 596 | - */ |
|
| 597 | - public function get_post_type( $context = 'view' ) { |
|
| 591 | + * Get the invoice post type. |
|
| 592 | + * |
|
| 593 | + * @since 1.0.19 |
|
| 594 | + * @param string $context View or edit context. |
|
| 595 | + * @return string |
|
| 596 | + */ |
|
| 597 | + public function get_post_type( $context = 'view' ) { |
|
| 598 | 598 | return $this->get_prop( 'post_type', $context ); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | - * Get the invoice mode. |
|
| 603 | - * |
|
| 604 | - * @since 1.0.19 |
|
| 605 | - * @param string $context View or edit context. |
|
| 606 | - * @return string |
|
| 607 | - */ |
|
| 608 | - public function get_mode( $context = 'view' ) { |
|
| 602 | + * Get the invoice mode. |
|
| 603 | + * |
|
| 604 | + * @since 1.0.19 |
|
| 605 | + * @param string $context View or edit context. |
|
| 606 | + * @return string |
|
| 607 | + */ |
|
| 608 | + public function get_mode( $context = 'view' ) { |
|
| 609 | 609 | return $this->get_prop( 'mode', $context ); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
| 613 | - * Get the invoice path. |
|
| 614 | - * |
|
| 615 | - * @since 1.0.19 |
|
| 616 | - * @param string $context View or edit context. |
|
| 617 | - * @return string |
|
| 618 | - */ |
|
| 619 | - public function get_path( $context = 'view' ) { |
|
| 613 | + * Get the invoice path. |
|
| 614 | + * |
|
| 615 | + * @since 1.0.19 |
|
| 616 | + * @param string $context View or edit context. |
|
| 617 | + * @return string |
|
| 618 | + */ |
|
| 619 | + public function get_path( $context = 'view' ) { |
|
| 620 | 620 | $path = $this->get_prop( 'path', $context ); |
| 621 | 621 | |
| 622 | 622 | if ( empty( $path ) ) { |
@@ -624,73 +624,73 @@ discard block |
||
| 624 | 624 | $path = sanitize_title( $prefix . $this->get_id() ); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - return $path; |
|
| 627 | + return $path; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
| 631 | - * Get the invoice name/title. |
|
| 632 | - * |
|
| 633 | - * @since 1.0.19 |
|
| 634 | - * @param string $context View or edit context. |
|
| 635 | - * @return string |
|
| 636 | - */ |
|
| 637 | - public function get_name( $context = 'view' ) { |
|
| 631 | + * Get the invoice name/title. |
|
| 632 | + * |
|
| 633 | + * @since 1.0.19 |
|
| 634 | + * @param string $context View or edit context. |
|
| 635 | + * @return string |
|
| 636 | + */ |
|
| 637 | + public function get_name( $context = 'view' ) { |
|
| 638 | 638 | $name = $this->get_prop( 'title', $context ); |
| 639 | 639 | |
| 640 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 640 | + return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | - * Alias of self::get_name(). |
|
| 645 | - * |
|
| 646 | - * @since 1.0.19 |
|
| 647 | - * @param string $context View or edit context. |
|
| 648 | - * @return string |
|
| 649 | - */ |
|
| 650 | - public function get_title( $context = 'view' ) { |
|
| 651 | - return $this->get_name( $context ); |
|
| 644 | + * Alias of self::get_name(). |
|
| 645 | + * |
|
| 646 | + * @since 1.0.19 |
|
| 647 | + * @param string $context View or edit context. |
|
| 648 | + * @return string |
|
| 649 | + */ |
|
| 650 | + public function get_title( $context = 'view' ) { |
|
| 651 | + return $this->get_name( $context ); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
| 655 | - * Get the invoice description. |
|
| 656 | - * |
|
| 657 | - * @since 1.0.19 |
|
| 658 | - * @param string $context View or edit context. |
|
| 659 | - * @return string |
|
| 660 | - */ |
|
| 661 | - public function get_description( $context = 'view' ) { |
|
| 662 | - return $this->get_prop( 'description', $context ); |
|
| 655 | + * Get the invoice description. |
|
| 656 | + * |
|
| 657 | + * @since 1.0.19 |
|
| 658 | + * @param string $context View or edit context. |
|
| 659 | + * @return string |
|
| 660 | + */ |
|
| 661 | + public function get_description( $context = 'view' ) { |
|
| 662 | + return $this->get_prop( 'description', $context ); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | - * Alias of self::get_description(). |
|
| 667 | - * |
|
| 668 | - * @since 1.0.19 |
|
| 669 | - * @param string $context View or edit context. |
|
| 670 | - * @return string |
|
| 671 | - */ |
|
| 672 | - public function get_excerpt( $context = 'view' ) { |
|
| 673 | - return $this->get_description( $context ); |
|
| 666 | + * Alias of self::get_description(). |
|
| 667 | + * |
|
| 668 | + * @since 1.0.19 |
|
| 669 | + * @param string $context View or edit context. |
|
| 670 | + * @return string |
|
| 671 | + */ |
|
| 672 | + public function get_excerpt( $context = 'view' ) { |
|
| 673 | + return $this->get_description( $context ); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * Alias of self::get_description(). |
|
| 678 | - * |
|
| 679 | - * @since 1.0.19 |
|
| 680 | - * @param string $context View or edit context. |
|
| 681 | - * @return string |
|
| 682 | - */ |
|
| 683 | - public function get_summary( $context = 'view' ) { |
|
| 684 | - return $this->get_description( $context ); |
|
| 677 | + * Alias of self::get_description(). |
|
| 678 | + * |
|
| 679 | + * @since 1.0.19 |
|
| 680 | + * @param string $context View or edit context. |
|
| 681 | + * @return string |
|
| 682 | + */ |
|
| 683 | + public function get_summary( $context = 'view' ) { |
|
| 684 | + return $this->get_description( $context ); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
| 688 | - * Returns the user info. |
|
| 689 | - * |
|
| 690 | - * @since 1.0.19 |
|
| 688 | + * Returns the user info. |
|
| 689 | + * |
|
| 690 | + * @since 1.0.19 |
|
| 691 | 691 | * @param string $context View or edit context. |
| 692 | - * @return array |
|
| 693 | - */ |
|
| 692 | + * @return array |
|
| 693 | + */ |
|
| 694 | 694 | public function get_user_info( $context = 'view' ) { |
| 695 | 695 | |
| 696 | 696 | $user_info = array( |
@@ -707,605 +707,605 @@ discard block |
||
| 707 | 707 | 'company' => $this->get_company( $context ), |
| 708 | 708 | 'vat_number' => $this->get_vat_number( $context ), |
| 709 | 709 | 'discount' => $this->get_discount_code( $context ), |
| 710 | - ); |
|
| 710 | + ); |
|
| 711 | 711 | |
| 712 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 712 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 713 | 713 | |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | - * Get the customer id. |
|
| 718 | - * |
|
| 719 | - * @since 1.0.19 |
|
| 720 | - * @param string $context View or edit context. |
|
| 721 | - * @return int |
|
| 722 | - */ |
|
| 723 | - public function get_author( $context = 'view' ) { |
|
| 724 | - return (int) $this->get_prop( 'author', $context ); |
|
| 717 | + * Get the customer id. |
|
| 718 | + * |
|
| 719 | + * @since 1.0.19 |
|
| 720 | + * @param string $context View or edit context. |
|
| 721 | + * @return int |
|
| 722 | + */ |
|
| 723 | + public function get_author( $context = 'view' ) { |
|
| 724 | + return (int) $this->get_prop( 'author', $context ); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * Alias of self::get_author(). |
|
| 729 | - * |
|
| 730 | - * @since 1.0.19 |
|
| 731 | - * @param string $context View or edit context. |
|
| 732 | - * @return int |
|
| 733 | - */ |
|
| 734 | - public function get_user_id( $context = 'view' ) { |
|
| 735 | - return $this->get_author( $context ); |
|
| 728 | + * Alias of self::get_author(). |
|
| 729 | + * |
|
| 730 | + * @since 1.0.19 |
|
| 731 | + * @param string $context View or edit context. |
|
| 732 | + * @return int |
|
| 733 | + */ |
|
| 734 | + public function get_user_id( $context = 'view' ) { |
|
| 735 | + return $this->get_author( $context ); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - /** |
|
| 739 | - * Alias of self::get_author(). |
|
| 740 | - * |
|
| 741 | - * @since 1.0.19 |
|
| 742 | - * @param string $context View or edit context. |
|
| 743 | - * @return int |
|
| 744 | - */ |
|
| 745 | - public function get_customer_id( $context = 'view' ) { |
|
| 746 | - return $this->get_author( $context ); |
|
| 738 | + /** |
|
| 739 | + * Alias of self::get_author(). |
|
| 740 | + * |
|
| 741 | + * @since 1.0.19 |
|
| 742 | + * @param string $context View or edit context. |
|
| 743 | + * @return int |
|
| 744 | + */ |
|
| 745 | + public function get_customer_id( $context = 'view' ) { |
|
| 746 | + return $this->get_author( $context ); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
| 750 | - * Get the customer's ip. |
|
| 751 | - * |
|
| 752 | - * @since 1.0.19 |
|
| 753 | - * @param string $context View or edit context. |
|
| 754 | - * @return string |
|
| 755 | - */ |
|
| 756 | - public function get_ip( $context = 'view' ) { |
|
| 757 | - return $this->get_prop( 'user_ip', $context ); |
|
| 750 | + * Get the customer's ip. |
|
| 751 | + * |
|
| 752 | + * @since 1.0.19 |
|
| 753 | + * @param string $context View or edit context. |
|
| 754 | + * @return string |
|
| 755 | + */ |
|
| 756 | + public function get_ip( $context = 'view' ) { |
|
| 757 | + return $this->get_prop( 'user_ip', $context ); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * Alias of self::get_ip(). |
|
| 762 | - * |
|
| 763 | - * @since 1.0.19 |
|
| 764 | - * @param string $context View or edit context. |
|
| 765 | - * @return string |
|
| 766 | - */ |
|
| 767 | - public function get_user_ip( $context = 'view' ) { |
|
| 768 | - return $this->get_ip( $context ); |
|
| 761 | + * Alias of self::get_ip(). |
|
| 762 | + * |
|
| 763 | + * @since 1.0.19 |
|
| 764 | + * @param string $context View or edit context. |
|
| 765 | + * @return string |
|
| 766 | + */ |
|
| 767 | + public function get_user_ip( $context = 'view' ) { |
|
| 768 | + return $this->get_ip( $context ); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - /** |
|
| 772 | - * Alias of self::get_ip(). |
|
| 773 | - * |
|
| 774 | - * @since 1.0.19 |
|
| 775 | - * @param string $context View or edit context. |
|
| 776 | - * @return string |
|
| 777 | - */ |
|
| 778 | - public function get_customer_ip( $context = 'view' ) { |
|
| 779 | - return $this->get_ip( $context ); |
|
| 771 | + /** |
|
| 772 | + * Alias of self::get_ip(). |
|
| 773 | + * |
|
| 774 | + * @since 1.0.19 |
|
| 775 | + * @param string $context View or edit context. |
|
| 776 | + * @return string |
|
| 777 | + */ |
|
| 778 | + public function get_customer_ip( $context = 'view' ) { |
|
| 779 | + return $this->get_ip( $context ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | - * Get the customer's first name. |
|
| 784 | - * |
|
| 785 | - * @since 1.0.19 |
|
| 786 | - * @param string $context View or edit context. |
|
| 787 | - * @return string |
|
| 788 | - */ |
|
| 789 | - public function get_first_name( $context = 'view' ) { |
|
| 790 | - return $this->get_prop( 'first_name', $context ); |
|
| 783 | + * Get the customer's first name. |
|
| 784 | + * |
|
| 785 | + * @since 1.0.19 |
|
| 786 | + * @param string $context View or edit context. |
|
| 787 | + * @return string |
|
| 788 | + */ |
|
| 789 | + public function get_first_name( $context = 'view' ) { |
|
| 790 | + return $this->get_prop( 'first_name', $context ); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
| 794 | - * Alias of self::get_first_name(). |
|
| 795 | - * |
|
| 796 | - * @since 1.0.19 |
|
| 797 | - * @param string $context View or edit context. |
|
| 798 | - * @return int |
|
| 799 | - */ |
|
| 800 | - public function get_user_first_name( $context = 'view' ) { |
|
| 801 | - return $this->get_first_name( $context ); |
|
| 794 | + * Alias of self::get_first_name(). |
|
| 795 | + * |
|
| 796 | + * @since 1.0.19 |
|
| 797 | + * @param string $context View or edit context. |
|
| 798 | + * @return int |
|
| 799 | + */ |
|
| 800 | + public function get_user_first_name( $context = 'view' ) { |
|
| 801 | + return $this->get_first_name( $context ); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - /** |
|
| 805 | - * Alias of self::get_first_name(). |
|
| 806 | - * |
|
| 807 | - * @since 1.0.19 |
|
| 808 | - * @param string $context View or edit context. |
|
| 809 | - * @return int |
|
| 810 | - */ |
|
| 811 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 812 | - return $this->get_first_name( $context ); |
|
| 804 | + /** |
|
| 805 | + * Alias of self::get_first_name(). |
|
| 806 | + * |
|
| 807 | + * @since 1.0.19 |
|
| 808 | + * @param string $context View or edit context. |
|
| 809 | + * @return int |
|
| 810 | + */ |
|
| 811 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 812 | + return $this->get_first_name( $context ); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Get the customer's last name. |
|
| 817 | - * |
|
| 818 | - * @since 1.0.19 |
|
| 819 | - * @param string $context View or edit context. |
|
| 820 | - * @return string |
|
| 821 | - */ |
|
| 822 | - public function get_last_name( $context = 'view' ) { |
|
| 823 | - return $this->get_prop( 'last_name', $context ); |
|
| 816 | + * Get the customer's last name. |
|
| 817 | + * |
|
| 818 | + * @since 1.0.19 |
|
| 819 | + * @param string $context View or edit context. |
|
| 820 | + * @return string |
|
| 821 | + */ |
|
| 822 | + public function get_last_name( $context = 'view' ) { |
|
| 823 | + return $this->get_prop( 'last_name', $context ); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
| 827 | - * Alias of self::get_last_name(). |
|
| 828 | - * |
|
| 829 | - * @since 1.0.19 |
|
| 830 | - * @param string $context View or edit context. |
|
| 831 | - * @return int |
|
| 832 | - */ |
|
| 833 | - public function get_user_last_name( $context = 'view' ) { |
|
| 834 | - return $this->get_last_name( $context ); |
|
| 827 | + * Alias of self::get_last_name(). |
|
| 828 | + * |
|
| 829 | + * @since 1.0.19 |
|
| 830 | + * @param string $context View or edit context. |
|
| 831 | + * @return int |
|
| 832 | + */ |
|
| 833 | + public function get_user_last_name( $context = 'view' ) { |
|
| 834 | + return $this->get_last_name( $context ); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
| 838 | - * Alias of self::get_last_name(). |
|
| 839 | - * |
|
| 840 | - * @since 1.0.19 |
|
| 841 | - * @param string $context View or edit context. |
|
| 842 | - * @return int |
|
| 843 | - */ |
|
| 844 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 845 | - return $this->get_last_name( $context ); |
|
| 838 | + * Alias of self::get_last_name(). |
|
| 839 | + * |
|
| 840 | + * @since 1.0.19 |
|
| 841 | + * @param string $context View or edit context. |
|
| 842 | + * @return int |
|
| 843 | + */ |
|
| 844 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 845 | + return $this->get_last_name( $context ); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
| 849 | - * Get the customer's full name. |
|
| 850 | - * |
|
| 851 | - * @since 1.0.19 |
|
| 852 | - * @param string $context View or edit context. |
|
| 853 | - * @return string |
|
| 854 | - */ |
|
| 855 | - public function get_full_name( $context = 'view' ) { |
|
| 856 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 849 | + * Get the customer's full name. |
|
| 850 | + * |
|
| 851 | + * @since 1.0.19 |
|
| 852 | + * @param string $context View or edit context. |
|
| 853 | + * @return string |
|
| 854 | + */ |
|
| 855 | + public function get_full_name( $context = 'view' ) { |
|
| 856 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
| 860 | - * Alias of self::get_full_name(). |
|
| 861 | - * |
|
| 862 | - * @since 1.0.19 |
|
| 863 | - * @param string $context View or edit context. |
|
| 864 | - * @return int |
|
| 865 | - */ |
|
| 866 | - public function get_user_full_name( $context = 'view' ) { |
|
| 867 | - return $this->get_full_name( $context ); |
|
| 860 | + * Alias of self::get_full_name(). |
|
| 861 | + * |
|
| 862 | + * @since 1.0.19 |
|
| 863 | + * @param string $context View or edit context. |
|
| 864 | + * @return int |
|
| 865 | + */ |
|
| 866 | + public function get_user_full_name( $context = 'view' ) { |
|
| 867 | + return $this->get_full_name( $context ); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
| 871 | - * Alias of self::get_full_name(). |
|
| 872 | - * |
|
| 873 | - * @since 1.0.19 |
|
| 874 | - * @param string $context View or edit context. |
|
| 875 | - * @return int |
|
| 876 | - */ |
|
| 877 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 878 | - return $this->get_full_name( $context ); |
|
| 871 | + * Alias of self::get_full_name(). |
|
| 872 | + * |
|
| 873 | + * @since 1.0.19 |
|
| 874 | + * @param string $context View or edit context. |
|
| 875 | + * @return int |
|
| 876 | + */ |
|
| 877 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 878 | + return $this->get_full_name( $context ); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | - * Get the customer's phone number. |
|
| 883 | - * |
|
| 884 | - * @since 1.0.19 |
|
| 885 | - * @param string $context View or edit context. |
|
| 886 | - * @return string |
|
| 887 | - */ |
|
| 888 | - public function get_phone( $context = 'view' ) { |
|
| 889 | - return $this->get_prop( 'phone', $context ); |
|
| 882 | + * Get the customer's phone number. |
|
| 883 | + * |
|
| 884 | + * @since 1.0.19 |
|
| 885 | + * @param string $context View or edit context. |
|
| 886 | + * @return string |
|
| 887 | + */ |
|
| 888 | + public function get_phone( $context = 'view' ) { |
|
| 889 | + return $this->get_prop( 'phone', $context ); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /** |
| 893 | - * Alias of self::get_phone(). |
|
| 894 | - * |
|
| 895 | - * @since 1.0.19 |
|
| 896 | - * @param string $context View or edit context. |
|
| 897 | - * @return int |
|
| 898 | - */ |
|
| 899 | - public function get_phone_number( $context = 'view' ) { |
|
| 900 | - return $this->get_phone( $context ); |
|
| 893 | + * Alias of self::get_phone(). |
|
| 894 | + * |
|
| 895 | + * @since 1.0.19 |
|
| 896 | + * @param string $context View or edit context. |
|
| 897 | + * @return int |
|
| 898 | + */ |
|
| 899 | + public function get_phone_number( $context = 'view' ) { |
|
| 900 | + return $this->get_phone( $context ); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
| 904 | - * Alias of self::get_phone(). |
|
| 905 | - * |
|
| 906 | - * @since 1.0.19 |
|
| 907 | - * @param string $context View or edit context. |
|
| 908 | - * @return int |
|
| 909 | - */ |
|
| 910 | - public function get_user_phone( $context = 'view' ) { |
|
| 911 | - return $this->get_phone( $context ); |
|
| 904 | + * Alias of self::get_phone(). |
|
| 905 | + * |
|
| 906 | + * @since 1.0.19 |
|
| 907 | + * @param string $context View or edit context. |
|
| 908 | + * @return int |
|
| 909 | + */ |
|
| 910 | + public function get_user_phone( $context = 'view' ) { |
|
| 911 | + return $this->get_phone( $context ); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
| 915 | - * Alias of self::get_phone(). |
|
| 916 | - * |
|
| 917 | - * @since 1.0.19 |
|
| 918 | - * @param string $context View or edit context. |
|
| 919 | - * @return int |
|
| 920 | - */ |
|
| 921 | - public function get_customer_phone( $context = 'view' ) { |
|
| 922 | - return $this->get_phone( $context ); |
|
| 915 | + * Alias of self::get_phone(). |
|
| 916 | + * |
|
| 917 | + * @since 1.0.19 |
|
| 918 | + * @param string $context View or edit context. |
|
| 919 | + * @return int |
|
| 920 | + */ |
|
| 921 | + public function get_customer_phone( $context = 'view' ) { |
|
| 922 | + return $this->get_phone( $context ); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
| 926 | - * Get the customer's email address. |
|
| 927 | - * |
|
| 928 | - * @since 1.0.19 |
|
| 929 | - * @param string $context View or edit context. |
|
| 930 | - * @return string |
|
| 931 | - */ |
|
| 932 | - public function get_email( $context = 'view' ) { |
|
| 933 | - return $this->get_prop( 'email', $context ); |
|
| 926 | + * Get the customer's email address. |
|
| 927 | + * |
|
| 928 | + * @since 1.0.19 |
|
| 929 | + * @param string $context View or edit context. |
|
| 930 | + * @return string |
|
| 931 | + */ |
|
| 932 | + public function get_email( $context = 'view' ) { |
|
| 933 | + return $this->get_prop( 'email', $context ); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
| 937 | - * Alias of self::get_email(). |
|
| 938 | - * |
|
| 939 | - * @since 1.0.19 |
|
| 940 | - * @param string $context View or edit context. |
|
| 941 | - * @return string |
|
| 942 | - */ |
|
| 943 | - public function get_email_address( $context = 'view' ) { |
|
| 944 | - return $this->get_email( $context ); |
|
| 937 | + * Alias of self::get_email(). |
|
| 938 | + * |
|
| 939 | + * @since 1.0.19 |
|
| 940 | + * @param string $context View or edit context. |
|
| 941 | + * @return string |
|
| 942 | + */ |
|
| 943 | + public function get_email_address( $context = 'view' ) { |
|
| 944 | + return $this->get_email( $context ); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | /** |
| 948 | - * Alias of self::get_email(). |
|
| 949 | - * |
|
| 950 | - * @since 1.0.19 |
|
| 951 | - * @param string $context View or edit context. |
|
| 952 | - * @return int |
|
| 953 | - */ |
|
| 954 | - public function get_user_email( $context = 'view' ) { |
|
| 955 | - return $this->get_email( $context ); |
|
| 948 | + * Alias of self::get_email(). |
|
| 949 | + * |
|
| 950 | + * @since 1.0.19 |
|
| 951 | + * @param string $context View or edit context. |
|
| 952 | + * @return int |
|
| 953 | + */ |
|
| 954 | + public function get_user_email( $context = 'view' ) { |
|
| 955 | + return $this->get_email( $context ); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | /** |
| 959 | - * Alias of self::get_email(). |
|
| 960 | - * |
|
| 961 | - * @since 1.0.19 |
|
| 962 | - * @param string $context View or edit context. |
|
| 963 | - * @return int |
|
| 964 | - */ |
|
| 965 | - public function get_customer_email( $context = 'view' ) { |
|
| 966 | - return $this->get_email( $context ); |
|
| 959 | + * Alias of self::get_email(). |
|
| 960 | + * |
|
| 961 | + * @since 1.0.19 |
|
| 962 | + * @param string $context View or edit context. |
|
| 963 | + * @return int |
|
| 964 | + */ |
|
| 965 | + public function get_customer_email( $context = 'view' ) { |
|
| 966 | + return $this->get_email( $context ); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
| 970 | - * Get the customer's country. |
|
| 971 | - * |
|
| 972 | - * @since 1.0.19 |
|
| 973 | - * @param string $context View or edit context. |
|
| 974 | - * @return string |
|
| 975 | - */ |
|
| 976 | - public function get_country( $context = 'view' ) { |
|
| 977 | - $country = $this->get_prop( 'country', $context ); |
|
| 978 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 970 | + * Get the customer's country. |
|
| 971 | + * |
|
| 972 | + * @since 1.0.19 |
|
| 973 | + * @param string $context View or edit context. |
|
| 974 | + * @return string |
|
| 975 | + */ |
|
| 976 | + public function get_country( $context = 'view' ) { |
|
| 977 | + $country = $this->get_prop( 'country', $context ); |
|
| 978 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | /** |
| 982 | - * Alias of self::get_country(). |
|
| 983 | - * |
|
| 984 | - * @since 1.0.19 |
|
| 985 | - * @param string $context View or edit context. |
|
| 986 | - * @return int |
|
| 987 | - */ |
|
| 988 | - public function get_user_country( $context = 'view' ) { |
|
| 989 | - return $this->get_country( $context ); |
|
| 982 | + * Alias of self::get_country(). |
|
| 983 | + * |
|
| 984 | + * @since 1.0.19 |
|
| 985 | + * @param string $context View or edit context. |
|
| 986 | + * @return int |
|
| 987 | + */ |
|
| 988 | + public function get_user_country( $context = 'view' ) { |
|
| 989 | + return $this->get_country( $context ); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
| 993 | - * Alias of self::get_country(). |
|
| 994 | - * |
|
| 995 | - * @since 1.0.19 |
|
| 996 | - * @param string $context View or edit context. |
|
| 997 | - * @return int |
|
| 998 | - */ |
|
| 999 | - public function get_customer_country( $context = 'view' ) { |
|
| 1000 | - return $this->get_country( $context ); |
|
| 993 | + * Alias of self::get_country(). |
|
| 994 | + * |
|
| 995 | + * @since 1.0.19 |
|
| 996 | + * @param string $context View or edit context. |
|
| 997 | + * @return int |
|
| 998 | + */ |
|
| 999 | + public function get_customer_country( $context = 'view' ) { |
|
| 1000 | + return $this->get_country( $context ); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | /** |
| 1004 | - * Get the customer's state. |
|
| 1005 | - * |
|
| 1006 | - * @since 1.0.19 |
|
| 1007 | - * @param string $context View or edit context. |
|
| 1008 | - * @return string |
|
| 1009 | - */ |
|
| 1010 | - public function get_state( $context = 'view' ) { |
|
| 1011 | - $state = $this->get_prop( 'state', $context ); |
|
| 1012 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1004 | + * Get the customer's state. |
|
| 1005 | + * |
|
| 1006 | + * @since 1.0.19 |
|
| 1007 | + * @param string $context View or edit context. |
|
| 1008 | + * @return string |
|
| 1009 | + */ |
|
| 1010 | + public function get_state( $context = 'view' ) { |
|
| 1011 | + $state = $this->get_prop( 'state', $context ); |
|
| 1012 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /** |
| 1016 | - * Alias of self::get_state(). |
|
| 1017 | - * |
|
| 1018 | - * @since 1.0.19 |
|
| 1019 | - * @param string $context View or edit context. |
|
| 1020 | - * @return int |
|
| 1021 | - */ |
|
| 1022 | - public function get_user_state( $context = 'view' ) { |
|
| 1023 | - return $this->get_state( $context ); |
|
| 1016 | + * Alias of self::get_state(). |
|
| 1017 | + * |
|
| 1018 | + * @since 1.0.19 |
|
| 1019 | + * @param string $context View or edit context. |
|
| 1020 | + * @return int |
|
| 1021 | + */ |
|
| 1022 | + public function get_user_state( $context = 'view' ) { |
|
| 1023 | + return $this->get_state( $context ); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
| 1027 | - * Alias of self::get_state(). |
|
| 1028 | - * |
|
| 1029 | - * @since 1.0.19 |
|
| 1030 | - * @param string $context View or edit context. |
|
| 1031 | - * @return int |
|
| 1032 | - */ |
|
| 1033 | - public function get_customer_state( $context = 'view' ) { |
|
| 1034 | - return $this->get_state( $context ); |
|
| 1027 | + * Alias of self::get_state(). |
|
| 1028 | + * |
|
| 1029 | + * @since 1.0.19 |
|
| 1030 | + * @param string $context View or edit context. |
|
| 1031 | + * @return int |
|
| 1032 | + */ |
|
| 1033 | + public function get_customer_state( $context = 'view' ) { |
|
| 1034 | + return $this->get_state( $context ); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
| 1038 | - * Get the customer's city. |
|
| 1039 | - * |
|
| 1040 | - * @since 1.0.19 |
|
| 1041 | - * @param string $context View or edit context. |
|
| 1042 | - * @return string |
|
| 1043 | - */ |
|
| 1044 | - public function get_city( $context = 'view' ) { |
|
| 1045 | - return $this->get_prop( 'city', $context ); |
|
| 1038 | + * Get the customer's city. |
|
| 1039 | + * |
|
| 1040 | + * @since 1.0.19 |
|
| 1041 | + * @param string $context View or edit context. |
|
| 1042 | + * @return string |
|
| 1043 | + */ |
|
| 1044 | + public function get_city( $context = 'view' ) { |
|
| 1045 | + return $this->get_prop( 'city', $context ); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
| 1049 | - * Alias of self::get_city(). |
|
| 1050 | - * |
|
| 1051 | - * @since 1.0.19 |
|
| 1052 | - * @param string $context View or edit context. |
|
| 1053 | - * @return string |
|
| 1054 | - */ |
|
| 1055 | - public function get_user_city( $context = 'view' ) { |
|
| 1056 | - return $this->get_city( $context ); |
|
| 1049 | + * Alias of self::get_city(). |
|
| 1050 | + * |
|
| 1051 | + * @since 1.0.19 |
|
| 1052 | + * @param string $context View or edit context. |
|
| 1053 | + * @return string |
|
| 1054 | + */ |
|
| 1055 | + public function get_user_city( $context = 'view' ) { |
|
| 1056 | + return $this->get_city( $context ); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
| 1060 | - * Alias of self::get_city(). |
|
| 1061 | - * |
|
| 1062 | - * @since 1.0.19 |
|
| 1063 | - * @param string $context View or edit context. |
|
| 1064 | - * @return string |
|
| 1065 | - */ |
|
| 1066 | - public function get_customer_city( $context = 'view' ) { |
|
| 1067 | - return $this->get_city( $context ); |
|
| 1060 | + * Alias of self::get_city(). |
|
| 1061 | + * |
|
| 1062 | + * @since 1.0.19 |
|
| 1063 | + * @param string $context View or edit context. |
|
| 1064 | + * @return string |
|
| 1065 | + */ |
|
| 1066 | + public function get_customer_city( $context = 'view' ) { |
|
| 1067 | + return $this->get_city( $context ); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
| 1071 | - * Get the customer's zip. |
|
| 1072 | - * |
|
| 1073 | - * @since 1.0.19 |
|
| 1074 | - * @param string $context View or edit context. |
|
| 1075 | - * @return string |
|
| 1076 | - */ |
|
| 1077 | - public function get_zip( $context = 'view' ) { |
|
| 1078 | - return $this->get_prop( 'zip', $context ); |
|
| 1071 | + * Get the customer's zip. |
|
| 1072 | + * |
|
| 1073 | + * @since 1.0.19 |
|
| 1074 | + * @param string $context View or edit context. |
|
| 1075 | + * @return string |
|
| 1076 | + */ |
|
| 1077 | + public function get_zip( $context = 'view' ) { |
|
| 1078 | + return $this->get_prop( 'zip', $context ); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
| 1082 | - * Alias of self::get_zip(). |
|
| 1083 | - * |
|
| 1084 | - * @since 1.0.19 |
|
| 1085 | - * @param string $context View or edit context. |
|
| 1086 | - * @return string |
|
| 1087 | - */ |
|
| 1088 | - public function get_user_zip( $context = 'view' ) { |
|
| 1089 | - return $this->get_zip( $context ); |
|
| 1082 | + * Alias of self::get_zip(). |
|
| 1083 | + * |
|
| 1084 | + * @since 1.0.19 |
|
| 1085 | + * @param string $context View or edit context. |
|
| 1086 | + * @return string |
|
| 1087 | + */ |
|
| 1088 | + public function get_user_zip( $context = 'view' ) { |
|
| 1089 | + return $this->get_zip( $context ); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
| 1093 | - * Alias of self::get_zip(). |
|
| 1094 | - * |
|
| 1095 | - * @since 1.0.19 |
|
| 1096 | - * @param string $context View or edit context. |
|
| 1097 | - * @return string |
|
| 1098 | - */ |
|
| 1099 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1100 | - return $this->get_zip( $context ); |
|
| 1093 | + * Alias of self::get_zip(). |
|
| 1094 | + * |
|
| 1095 | + * @since 1.0.19 |
|
| 1096 | + * @param string $context View or edit context. |
|
| 1097 | + * @return string |
|
| 1098 | + */ |
|
| 1099 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1100 | + return $this->get_zip( $context ); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
| 1104 | - * Get the customer's company. |
|
| 1105 | - * |
|
| 1106 | - * @since 1.0.19 |
|
| 1107 | - * @param string $context View or edit context. |
|
| 1108 | - * @return string |
|
| 1109 | - */ |
|
| 1110 | - public function get_company( $context = 'view' ) { |
|
| 1111 | - return $this->get_prop( 'company', $context ); |
|
| 1104 | + * Get the customer's company. |
|
| 1105 | + * |
|
| 1106 | + * @since 1.0.19 |
|
| 1107 | + * @param string $context View or edit context. |
|
| 1108 | + * @return string |
|
| 1109 | + */ |
|
| 1110 | + public function get_company( $context = 'view' ) { |
|
| 1111 | + return $this->get_prop( 'company', $context ); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
| 1115 | - * Alias of self::get_company(). |
|
| 1116 | - * |
|
| 1117 | - * @since 1.0.19 |
|
| 1118 | - * @param string $context View or edit context. |
|
| 1119 | - * @return string |
|
| 1120 | - */ |
|
| 1121 | - public function get_user_company( $context = 'view' ) { |
|
| 1122 | - return $this->get_company( $context ); |
|
| 1115 | + * Alias of self::get_company(). |
|
| 1116 | + * |
|
| 1117 | + * @since 1.0.19 |
|
| 1118 | + * @param string $context View or edit context. |
|
| 1119 | + * @return string |
|
| 1120 | + */ |
|
| 1121 | + public function get_user_company( $context = 'view' ) { |
|
| 1122 | + return $this->get_company( $context ); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
| 1126 | - * Alias of self::get_company(). |
|
| 1127 | - * |
|
| 1128 | - * @since 1.0.19 |
|
| 1129 | - * @param string $context View or edit context. |
|
| 1130 | - * @return string |
|
| 1131 | - */ |
|
| 1132 | - public function get_customer_company( $context = 'view' ) { |
|
| 1133 | - return $this->get_company( $context ); |
|
| 1126 | + * Alias of self::get_company(). |
|
| 1127 | + * |
|
| 1128 | + * @since 1.0.19 |
|
| 1129 | + * @param string $context View or edit context. |
|
| 1130 | + * @return string |
|
| 1131 | + */ |
|
| 1132 | + public function get_customer_company( $context = 'view' ) { |
|
| 1133 | + return $this->get_company( $context ); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | /** |
| 1137 | - * Get the customer's vat number. |
|
| 1138 | - * |
|
| 1139 | - * @since 1.0.19 |
|
| 1140 | - * @param string $context View or edit context. |
|
| 1141 | - * @return string |
|
| 1142 | - */ |
|
| 1143 | - public function get_vat_number( $context = 'view' ) { |
|
| 1144 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1137 | + * Get the customer's vat number. |
|
| 1138 | + * |
|
| 1139 | + * @since 1.0.19 |
|
| 1140 | + * @param string $context View or edit context. |
|
| 1141 | + * @return string |
|
| 1142 | + */ |
|
| 1143 | + public function get_vat_number( $context = 'view' ) { |
|
| 1144 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
| 1148 | - * Alias of self::get_vat_number(). |
|
| 1149 | - * |
|
| 1150 | - * @since 1.0.19 |
|
| 1151 | - * @param string $context View or edit context. |
|
| 1152 | - * @return string |
|
| 1153 | - */ |
|
| 1154 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1155 | - return $this->get_vat_number( $context ); |
|
| 1148 | + * Alias of self::get_vat_number(). |
|
| 1149 | + * |
|
| 1150 | + * @since 1.0.19 |
|
| 1151 | + * @param string $context View or edit context. |
|
| 1152 | + * @return string |
|
| 1153 | + */ |
|
| 1154 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1155 | + return $this->get_vat_number( $context ); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
| 1159 | - * Alias of self::get_vat_number(). |
|
| 1160 | - * |
|
| 1161 | - * @since 1.0.19 |
|
| 1162 | - * @param string $context View or edit context. |
|
| 1163 | - * @return string |
|
| 1164 | - */ |
|
| 1165 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1166 | - return $this->get_vat_number( $context ); |
|
| 1167 | - } |
|
| 1168 | - |
|
| 1159 | + * Alias of self::get_vat_number(). |
|
| 1160 | + * |
|
| 1161 | + * @since 1.0.19 |
|
| 1162 | + * @param string $context View or edit context. |
|
| 1163 | + * @return string |
|
| 1164 | + */ |
|
| 1165 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1166 | + return $this->get_vat_number( $context ); |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + /** |
|
| 1170 | + * Get the customer's vat rate. |
|
| 1171 | + * |
|
| 1172 | + * @since 1.0.19 |
|
| 1173 | + * @param string $context View or edit context. |
|
| 1174 | + * @return string |
|
| 1175 | + */ |
|
| 1176 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1177 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1169 | 1180 | /** |
| 1170 | - * Get the customer's vat rate. |
|
| 1171 | - * |
|
| 1172 | - * @since 1.0.19 |
|
| 1173 | - * @param string $context View or edit context. |
|
| 1174 | - * @return string |
|
| 1175 | - */ |
|
| 1176 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1177 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1181 | + * Alias of self::get_vat_rate(). |
|
| 1182 | + * |
|
| 1183 | + * @since 1.0.19 |
|
| 1184 | + * @param string $context View or edit context. |
|
| 1185 | + * @return string |
|
| 1186 | + */ |
|
| 1187 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1188 | + return $this->get_vat_rate( $context ); |
|
| 1178 | 1189 | } |
| 1179 | 1190 | |
| 1180 | 1191 | /** |
| 1181 | - * Alias of self::get_vat_rate(). |
|
| 1182 | - * |
|
| 1183 | - * @since 1.0.19 |
|
| 1184 | - * @param string $context View or edit context. |
|
| 1185 | - * @return string |
|
| 1186 | - */ |
|
| 1187 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1188 | - return $this->get_vat_rate( $context ); |
|
| 1192 | + * Alias of self::get_vat_rate(). |
|
| 1193 | + * |
|
| 1194 | + * @since 1.0.19 |
|
| 1195 | + * @param string $context View or edit context. |
|
| 1196 | + * @return string |
|
| 1197 | + */ |
|
| 1198 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1199 | + return $this->get_vat_rate( $context ); |
|
| 1189 | 1200 | } |
| 1190 | 1201 | |
| 1191 | 1202 | /** |
| 1192 | - * Alias of self::get_vat_rate(). |
|
| 1193 | - * |
|
| 1194 | - * @since 1.0.19 |
|
| 1195 | - * @param string $context View or edit context. |
|
| 1196 | - * @return string |
|
| 1197 | - */ |
|
| 1198 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1199 | - return $this->get_vat_rate( $context ); |
|
| 1203 | + * Get the customer's address. |
|
| 1204 | + * |
|
| 1205 | + * @since 1.0.19 |
|
| 1206 | + * @param string $context View or edit context. |
|
| 1207 | + * @return string |
|
| 1208 | + */ |
|
| 1209 | + public function get_address( $context = 'view' ) { |
|
| 1210 | + return $this->get_prop( 'address', $context ); |
|
| 1200 | 1211 | } |
| 1201 | 1212 | |
| 1202 | 1213 | /** |
| 1203 | - * Get the customer's address. |
|
| 1204 | - * |
|
| 1205 | - * @since 1.0.19 |
|
| 1206 | - * @param string $context View or edit context. |
|
| 1207 | - * @return string |
|
| 1208 | - */ |
|
| 1209 | - public function get_address( $context = 'view' ) { |
|
| 1210 | - return $this->get_prop( 'address', $context ); |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * Alias of self::get_address(). |
|
| 1215 | - * |
|
| 1216 | - * @since 1.0.19 |
|
| 1217 | - * @param string $context View or edit context. |
|
| 1218 | - * @return string |
|
| 1219 | - */ |
|
| 1220 | - public function get_user_address( $context = 'view' ) { |
|
| 1221 | - return $this->get_address( $context ); |
|
| 1222 | - } |
|
| 1223 | - |
|
| 1224 | - /** |
|
| 1225 | - * Alias of self::get_address(). |
|
| 1226 | - * |
|
| 1227 | - * @since 1.0.19 |
|
| 1228 | - * @param string $context View or edit context. |
|
| 1229 | - * @return string |
|
| 1230 | - */ |
|
| 1231 | - public function get_customer_address( $context = 'view' ) { |
|
| 1232 | - return $this->get_address( $context ); |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Get whether the customer has viewed the invoice or not. |
|
| 1237 | - * |
|
| 1238 | - * @since 1.0.19 |
|
| 1239 | - * @param string $context View or edit context. |
|
| 1240 | - * @return bool |
|
| 1241 | - */ |
|
| 1242 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1243 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - /** |
|
| 1247 | - * Get other recipients for invoice communications. |
|
| 1248 | - * |
|
| 1249 | - * @since 1.0.19 |
|
| 1250 | - * @param string $context View or edit context. |
|
| 1251 | - * @return bool |
|
| 1252 | - */ |
|
| 1253 | - public function get_email_cc( $context = 'view' ) { |
|
| 1254 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - /** |
|
| 1258 | - * Get invoice template. |
|
| 1259 | - * |
|
| 1260 | - * @since 1.0.19 |
|
| 1261 | - * @param string $context View or edit context. |
|
| 1262 | - * @return bool |
|
| 1263 | - */ |
|
| 1264 | - public function get_template( $context = 'view' ) { |
|
| 1265 | - return $this->get_prop( 'template', $context ); |
|
| 1266 | - } |
|
| 1267 | - |
|
| 1268 | - /** |
|
| 1269 | - * Get whether the customer has confirmed their address. |
|
| 1270 | - * |
|
| 1271 | - * @since 1.0.19 |
|
| 1272 | - * @param string $context View or edit context. |
|
| 1273 | - * @return bool |
|
| 1274 | - */ |
|
| 1275 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1276 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1277 | - } |
|
| 1278 | - |
|
| 1279 | - /** |
|
| 1280 | - * Alias of self::get_address_confirmed(). |
|
| 1281 | - * |
|
| 1282 | - * @since 1.0.19 |
|
| 1283 | - * @param string $context View or edit context. |
|
| 1284 | - * @return bool |
|
| 1285 | - */ |
|
| 1286 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1287 | - return $this->get_address_confirmed( $context ); |
|
| 1288 | - } |
|
| 1289 | - |
|
| 1290 | - /** |
|
| 1291 | - * Alias of self::get_address(). |
|
| 1292 | - * |
|
| 1293 | - * @since 1.0.19 |
|
| 1294 | - * @param string $context View or edit context. |
|
| 1295 | - * @return bool |
|
| 1296 | - */ |
|
| 1297 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1298 | - return $this->get_address_confirmed( $context ); |
|
| 1299 | - } |
|
| 1300 | - |
|
| 1301 | - /** |
|
| 1302 | - * Get the invoice subtotal. |
|
| 1303 | - * |
|
| 1304 | - * @since 1.0.19 |
|
| 1305 | - * @param string $context View or edit context. |
|
| 1306 | - * @return float |
|
| 1307 | - */ |
|
| 1308 | - public function get_subtotal( $context = 'view' ) { |
|
| 1214 | + * Alias of self::get_address(). |
|
| 1215 | + * |
|
| 1216 | + * @since 1.0.19 |
|
| 1217 | + * @param string $context View or edit context. |
|
| 1218 | + * @return string |
|
| 1219 | + */ |
|
| 1220 | + public function get_user_address( $context = 'view' ) { |
|
| 1221 | + return $this->get_address( $context ); |
|
| 1222 | + } |
|
| 1223 | + |
|
| 1224 | + /** |
|
| 1225 | + * Alias of self::get_address(). |
|
| 1226 | + * |
|
| 1227 | + * @since 1.0.19 |
|
| 1228 | + * @param string $context View or edit context. |
|
| 1229 | + * @return string |
|
| 1230 | + */ |
|
| 1231 | + public function get_customer_address( $context = 'view' ) { |
|
| 1232 | + return $this->get_address( $context ); |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * Get whether the customer has viewed the invoice or not. |
|
| 1237 | + * |
|
| 1238 | + * @since 1.0.19 |
|
| 1239 | + * @param string $context View or edit context. |
|
| 1240 | + * @return bool |
|
| 1241 | + */ |
|
| 1242 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1243 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + /** |
|
| 1247 | + * Get other recipients for invoice communications. |
|
| 1248 | + * |
|
| 1249 | + * @since 1.0.19 |
|
| 1250 | + * @param string $context View or edit context. |
|
| 1251 | + * @return bool |
|
| 1252 | + */ |
|
| 1253 | + public function get_email_cc( $context = 'view' ) { |
|
| 1254 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + /** |
|
| 1258 | + * Get invoice template. |
|
| 1259 | + * |
|
| 1260 | + * @since 1.0.19 |
|
| 1261 | + * @param string $context View or edit context. |
|
| 1262 | + * @return bool |
|
| 1263 | + */ |
|
| 1264 | + public function get_template( $context = 'view' ) { |
|
| 1265 | + return $this->get_prop( 'template', $context ); |
|
| 1266 | + } |
|
| 1267 | + |
|
| 1268 | + /** |
|
| 1269 | + * Get whether the customer has confirmed their address. |
|
| 1270 | + * |
|
| 1271 | + * @since 1.0.19 |
|
| 1272 | + * @param string $context View or edit context. |
|
| 1273 | + * @return bool |
|
| 1274 | + */ |
|
| 1275 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1276 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1277 | + } |
|
| 1278 | + |
|
| 1279 | + /** |
|
| 1280 | + * Alias of self::get_address_confirmed(). |
|
| 1281 | + * |
|
| 1282 | + * @since 1.0.19 |
|
| 1283 | + * @param string $context View or edit context. |
|
| 1284 | + * @return bool |
|
| 1285 | + */ |
|
| 1286 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1287 | + return $this->get_address_confirmed( $context ); |
|
| 1288 | + } |
|
| 1289 | + |
|
| 1290 | + /** |
|
| 1291 | + * Alias of self::get_address(). |
|
| 1292 | + * |
|
| 1293 | + * @since 1.0.19 |
|
| 1294 | + * @param string $context View or edit context. |
|
| 1295 | + * @return bool |
|
| 1296 | + */ |
|
| 1297 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1298 | + return $this->get_address_confirmed( $context ); |
|
| 1299 | + } |
|
| 1300 | + |
|
| 1301 | + /** |
|
| 1302 | + * Get the invoice subtotal. |
|
| 1303 | + * |
|
| 1304 | + * @since 1.0.19 |
|
| 1305 | + * @param string $context View or edit context. |
|
| 1306 | + * @return float |
|
| 1307 | + */ |
|
| 1308 | + public function get_subtotal( $context = 'view' ) { |
|
| 1309 | 1309 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1310 | 1310 | |
| 1311 | 1311 | // Backwards compatibility. |
@@ -1317,165 +1317,165 @@ discard block |
||
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | /** |
| 1320 | - * Get the invoice discount total. |
|
| 1321 | - * |
|
| 1322 | - * @since 1.0.19 |
|
| 1323 | - * @param string $context View or edit context. |
|
| 1324 | - * @return float |
|
| 1325 | - */ |
|
| 1326 | - public function get_total_discount( $context = 'view' ) { |
|
| 1327 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1320 | + * Get the invoice discount total. |
|
| 1321 | + * |
|
| 1322 | + * @since 1.0.19 |
|
| 1323 | + * @param string $context View or edit context. |
|
| 1324 | + * @return float |
|
| 1325 | + */ |
|
| 1326 | + public function get_total_discount( $context = 'view' ) { |
|
| 1327 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
| 1331 | - * Get the invoice tax total. |
|
| 1332 | - * |
|
| 1333 | - * @since 1.0.19 |
|
| 1334 | - * @param string $context View or edit context. |
|
| 1335 | - * @return float |
|
| 1336 | - */ |
|
| 1337 | - public function get_total_tax( $context = 'view' ) { |
|
| 1338 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1339 | - } |
|
| 1331 | + * Get the invoice tax total. |
|
| 1332 | + * |
|
| 1333 | + * @since 1.0.19 |
|
| 1334 | + * @param string $context View or edit context. |
|
| 1335 | + * @return float |
|
| 1336 | + */ |
|
| 1337 | + public function get_total_tax( $context = 'view' ) { |
|
| 1338 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1339 | + } |
|
| 1340 | 1340 | |
| 1341 | - /** |
|
| 1342 | - * @deprecated |
|
| 1343 | - */ |
|
| 1344 | - public function get_final_tax( $currency = false ) { |
|
| 1345 | - $tax = $this->get_total_tax(); |
|
| 1341 | + /** |
|
| 1342 | + * @deprecated |
|
| 1343 | + */ |
|
| 1344 | + public function get_final_tax( $currency = false ) { |
|
| 1345 | + $tax = $this->get_total_tax(); |
|
| 1346 | 1346 | |
| 1347 | 1347 | if ( $currency ) { |
| 1348 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1348 | + return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | return $tax; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | /** |
| 1355 | - * Get the invoice fees total. |
|
| 1356 | - * |
|
| 1357 | - * @since 1.0.19 |
|
| 1358 | - * @param string $context View or edit context. |
|
| 1359 | - * @return float |
|
| 1360 | - */ |
|
| 1361 | - public function get_total_fees( $context = 'view' ) { |
|
| 1362 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1355 | + * Get the invoice fees total. |
|
| 1356 | + * |
|
| 1357 | + * @since 1.0.19 |
|
| 1358 | + * @param string $context View or edit context. |
|
| 1359 | + * @return float |
|
| 1360 | + */ |
|
| 1361 | + public function get_total_fees( $context = 'view' ) { |
|
| 1362 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | /** |
| 1366 | - * Alias for self::get_total_fees(). |
|
| 1367 | - * |
|
| 1368 | - * @since 1.0.19 |
|
| 1369 | - * @param string $context View or edit context. |
|
| 1370 | - * @return float |
|
| 1371 | - */ |
|
| 1372 | - public function get_fees_total( $context = 'view' ) { |
|
| 1373 | - return $this->get_total_fees( $context ); |
|
| 1366 | + * Alias for self::get_total_fees(). |
|
| 1367 | + * |
|
| 1368 | + * @since 1.0.19 |
|
| 1369 | + * @param string $context View or edit context. |
|
| 1370 | + * @return float |
|
| 1371 | + */ |
|
| 1372 | + public function get_fees_total( $context = 'view' ) { |
|
| 1373 | + return $this->get_total_fees( $context ); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
| 1377 | - * Get the invoice total. |
|
| 1378 | - * |
|
| 1379 | - * @since 1.0.19 |
|
| 1377 | + * Get the invoice total. |
|
| 1378 | + * |
|
| 1379 | + * @since 1.0.19 |
|
| 1380 | 1380 | * @return float |
| 1381 | - */ |
|
| 1382 | - public function get_total() { |
|
| 1383 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1384 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1385 | - } |
|
| 1381 | + */ |
|
| 1382 | + public function get_total() { |
|
| 1383 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1384 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1385 | + } |
|
| 1386 | 1386 | |
| 1387 | - /** |
|
| 1388 | - * Get the invoice totals. |
|
| 1389 | - * |
|
| 1390 | - * @since 1.0.19 |
|
| 1387 | + /** |
|
| 1388 | + * Get the invoice totals. |
|
| 1389 | + * |
|
| 1390 | + * @since 1.0.19 |
|
| 1391 | 1391 | * @return float |
| 1392 | - */ |
|
| 1393 | - public function get_totals() { |
|
| 1394 | - return $this->totals; |
|
| 1392 | + */ |
|
| 1393 | + public function get_totals() { |
|
| 1394 | + return $this->totals; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
| 1398 | - * Get the initial invoice total. |
|
| 1399 | - * |
|
| 1400 | - * @since 1.0.19 |
|
| 1398 | + * Get the initial invoice total. |
|
| 1399 | + * |
|
| 1400 | + * @since 1.0.19 |
|
| 1401 | 1401 | * @param string $context View or edit context. |
| 1402 | 1402 | * @return float |
| 1403 | - */ |
|
| 1403 | + */ |
|
| 1404 | 1404 | public function get_initial_total() { |
| 1405 | 1405 | |
| 1406 | - if ( empty( $this->totals ) ) { |
|
| 1407 | - $this->recalculate_total(); |
|
| 1408 | - } |
|
| 1406 | + if ( empty( $this->totals ) ) { |
|
| 1407 | + $this->recalculate_total(); |
|
| 1408 | + } |
|
| 1409 | 1409 | |
| 1410 | - $tax = $this->totals['tax']['initial']; |
|
| 1411 | - $fee = $this->totals['fee']['initial']; |
|
| 1412 | - $discount = $this->totals['discount']['initial']; |
|
| 1413 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1414 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1410 | + $tax = $this->totals['tax']['initial']; |
|
| 1411 | + $fee = $this->totals['fee']['initial']; |
|
| 1412 | + $discount = $this->totals['discount']['initial']; |
|
| 1413 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1414 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1415 | 1415 | |
| 1416 | - if ( 0 > $total ) { |
|
| 1417 | - $total = 0; |
|
| 1418 | - } |
|
| 1416 | + if ( 0 > $total ) { |
|
| 1417 | + $total = 0; |
|
| 1418 | + } |
|
| 1419 | 1419 | |
| 1420 | 1420 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1421 | - } |
|
| 1421 | + } |
|
| 1422 | 1422 | |
| 1423 | - /** |
|
| 1424 | - * Get the recurring invoice total. |
|
| 1425 | - * |
|
| 1426 | - * @since 1.0.19 |
|
| 1423 | + /** |
|
| 1424 | + * Get the recurring invoice total. |
|
| 1425 | + * |
|
| 1426 | + * @since 1.0.19 |
|
| 1427 | 1427 | * @param string $context View or edit context. |
| 1428 | 1428 | * @return float |
| 1429 | - */ |
|
| 1429 | + */ |
|
| 1430 | 1430 | public function get_recurring_total() { |
| 1431 | 1431 | |
| 1432 | - if ( empty( $this->totals ) ) { |
|
| 1433 | - $this->recalculate_total(); |
|
| 1434 | - } |
|
| 1432 | + if ( empty( $this->totals ) ) { |
|
| 1433 | + $this->recalculate_total(); |
|
| 1434 | + } |
|
| 1435 | 1435 | |
| 1436 | - $tax = $this->totals['tax']['recurring']; |
|
| 1437 | - $fee = $this->totals['fee']['recurring']; |
|
| 1438 | - $discount = $this->totals['discount']['recurring']; |
|
| 1439 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1440 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1436 | + $tax = $this->totals['tax']['recurring']; |
|
| 1437 | + $fee = $this->totals['fee']['recurring']; |
|
| 1438 | + $discount = $this->totals['discount']['recurring']; |
|
| 1439 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1440 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1441 | 1441 | |
| 1442 | - if ( 0 > $total ) { |
|
| 1443 | - $total = 0; |
|
| 1444 | - } |
|
| 1442 | + if ( 0 > $total ) { |
|
| 1443 | + $total = 0; |
|
| 1444 | + } |
|
| 1445 | 1445 | |
| 1446 | 1446 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1447 | - } |
|
| 1447 | + } |
|
| 1448 | 1448 | |
| 1449 | - /** |
|
| 1450 | - * Returns recurring payment details. |
|
| 1451 | - * |
|
| 1452 | - * @since 1.0.19 |
|
| 1449 | + /** |
|
| 1450 | + * Returns recurring payment details. |
|
| 1451 | + * |
|
| 1452 | + * @since 1.0.19 |
|
| 1453 | 1453 | * @param string $field Optionally provide a field to return. |
| 1454 | - * @param string $currency Whether to include the currency. |
|
| 1454 | + * @param string $currency Whether to include the currency. |
|
| 1455 | 1455 | * @return float |
| 1456 | - */ |
|
| 1456 | + */ |
|
| 1457 | 1457 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1458 | 1458 | |
| 1459 | - // Maybe recalculate totals. |
|
| 1460 | - if ( empty( $this->totals ) ) { |
|
| 1461 | - $this->recalculate_total(); |
|
| 1462 | - } |
|
| 1459 | + // Maybe recalculate totals. |
|
| 1460 | + if ( empty( $this->totals ) ) { |
|
| 1461 | + $this->recalculate_total(); |
|
| 1462 | + } |
|
| 1463 | 1463 | |
| 1464 | - // Prepare recurring totals. |
|
| 1464 | + // Prepare recurring totals. |
|
| 1465 | 1465 | $data = apply_filters( |
| 1466 | - 'wpinv_get_invoice_recurring_details', |
|
| 1467 | - array( |
|
| 1468 | - 'cart_details' => $this->get_cart_details(), |
|
| 1469 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1470 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1471 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1472 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1473 | - 'total' => $this->get_recurring_total(), |
|
| 1474 | - ), |
|
| 1475 | - $this, |
|
| 1476 | - $field, |
|
| 1477 | - $currency |
|
| 1478 | - ); |
|
| 1466 | + 'wpinv_get_invoice_recurring_details', |
|
| 1467 | + array( |
|
| 1468 | + 'cart_details' => $this->get_cart_details(), |
|
| 1469 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1470 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1471 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1472 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1473 | + 'total' => $this->get_recurring_total(), |
|
| 1474 | + ), |
|
| 1475 | + $this, |
|
| 1476 | + $field, |
|
| 1477 | + $currency |
|
| 1478 | + ); |
|
| 1479 | 1479 | |
| 1480 | 1480 | if ( isset( $data[$field] ) ) { |
| 1481 | 1481 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1485,145 +1485,145 @@ discard block |
||
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | /** |
| 1488 | - * Get the invoice fees. |
|
| 1489 | - * |
|
| 1490 | - * @since 1.0.19 |
|
| 1491 | - * @param string $context View or edit context. |
|
| 1492 | - * @return array |
|
| 1493 | - */ |
|
| 1494 | - public function get_fees( $context = 'view' ) { |
|
| 1495 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1488 | + * Get the invoice fees. |
|
| 1489 | + * |
|
| 1490 | + * @since 1.0.19 |
|
| 1491 | + * @param string $context View or edit context. |
|
| 1492 | + * @return array |
|
| 1493 | + */ |
|
| 1494 | + public function get_fees( $context = 'view' ) { |
|
| 1495 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 | /** |
| 1499 | - * Get the invoice discounts. |
|
| 1500 | - * |
|
| 1501 | - * @since 1.0.19 |
|
| 1502 | - * @param string $context View or edit context. |
|
| 1503 | - * @return array |
|
| 1504 | - */ |
|
| 1505 | - public function get_discounts( $context = 'view' ) { |
|
| 1506 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1499 | + * Get the invoice discounts. |
|
| 1500 | + * |
|
| 1501 | + * @since 1.0.19 |
|
| 1502 | + * @param string $context View or edit context. |
|
| 1503 | + * @return array |
|
| 1504 | + */ |
|
| 1505 | + public function get_discounts( $context = 'view' ) { |
|
| 1506 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | /** |
| 1510 | - * Get the invoice taxes. |
|
| 1511 | - * |
|
| 1512 | - * @since 1.0.19 |
|
| 1513 | - * @param string $context View or edit context. |
|
| 1514 | - * @return array |
|
| 1515 | - */ |
|
| 1516 | - public function get_taxes( $context = 'view' ) { |
|
| 1517 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1510 | + * Get the invoice taxes. |
|
| 1511 | + * |
|
| 1512 | + * @since 1.0.19 |
|
| 1513 | + * @param string $context View or edit context. |
|
| 1514 | + * @return array |
|
| 1515 | + */ |
|
| 1516 | + public function get_taxes( $context = 'view' ) { |
|
| 1517 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | /** |
| 1521 | - * Get the invoice items. |
|
| 1522 | - * |
|
| 1523 | - * @since 1.0.19 |
|
| 1524 | - * @param string $context View or edit context. |
|
| 1525 | - * @return GetPaid_Form_Item[] |
|
| 1526 | - */ |
|
| 1527 | - public function get_items( $context = 'view' ) { |
|
| 1521 | + * Get the invoice items. |
|
| 1522 | + * |
|
| 1523 | + * @since 1.0.19 |
|
| 1524 | + * @param string $context View or edit context. |
|
| 1525 | + * @return GetPaid_Form_Item[] |
|
| 1526 | + */ |
|
| 1527 | + public function get_items( $context = 'view' ) { |
|
| 1528 | 1528 | return $this->get_prop( 'items', $context ); |
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | /** |
| 1532 | - * Get the invoice's payment form. |
|
| 1533 | - * |
|
| 1534 | - * @since 1.0.19 |
|
| 1535 | - * @param string $context View or edit context. |
|
| 1536 | - * @return int |
|
| 1537 | - */ |
|
| 1538 | - public function get_payment_form( $context = 'view' ) { |
|
| 1539 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1532 | + * Get the invoice's payment form. |
|
| 1533 | + * |
|
| 1534 | + * @since 1.0.19 |
|
| 1535 | + * @param string $context View or edit context. |
|
| 1536 | + * @return int |
|
| 1537 | + */ |
|
| 1538 | + public function get_payment_form( $context = 'view' ) { |
|
| 1539 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | /** |
| 1543 | - * Get the invoice's submission id. |
|
| 1544 | - * |
|
| 1545 | - * @since 1.0.19 |
|
| 1546 | - * @param string $context View or edit context. |
|
| 1547 | - * @return string |
|
| 1548 | - */ |
|
| 1549 | - public function get_submission_id( $context = 'view' ) { |
|
| 1550 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1543 | + * Get the invoice's submission id. |
|
| 1544 | + * |
|
| 1545 | + * @since 1.0.19 |
|
| 1546 | + * @param string $context View or edit context. |
|
| 1547 | + * @return string |
|
| 1548 | + */ |
|
| 1549 | + public function get_submission_id( $context = 'view' ) { |
|
| 1550 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | /** |
| 1554 | - * Get the invoice's discount code. |
|
| 1555 | - * |
|
| 1556 | - * @since 1.0.19 |
|
| 1557 | - * @param string $context View or edit context. |
|
| 1558 | - * @return string |
|
| 1559 | - */ |
|
| 1560 | - public function get_discount_code( $context = 'view' ) { |
|
| 1561 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1554 | + * Get the invoice's discount code. |
|
| 1555 | + * |
|
| 1556 | + * @since 1.0.19 |
|
| 1557 | + * @param string $context View or edit context. |
|
| 1558 | + * @return string |
|
| 1559 | + */ |
|
| 1560 | + public function get_discount_code( $context = 'view' ) { |
|
| 1561 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | /** |
| 1565 | - * Get the invoice's gateway. |
|
| 1566 | - * |
|
| 1567 | - * @since 1.0.19 |
|
| 1568 | - * @param string $context View or edit context. |
|
| 1569 | - * @return string |
|
| 1570 | - */ |
|
| 1571 | - public function get_gateway( $context = 'view' ) { |
|
| 1572 | - return $this->get_prop( 'gateway', $context ); |
|
| 1565 | + * Get the invoice's gateway. |
|
| 1566 | + * |
|
| 1567 | + * @since 1.0.19 |
|
| 1568 | + * @param string $context View or edit context. |
|
| 1569 | + * @return string |
|
| 1570 | + */ |
|
| 1571 | + public function get_gateway( $context = 'view' ) { |
|
| 1572 | + return $this->get_prop( 'gateway', $context ); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | /** |
| 1576 | - * Get the invoice's gateway display title. |
|
| 1577 | - * |
|
| 1578 | - * @since 1.0.19 |
|
| 1579 | - * @return string |
|
| 1580 | - */ |
|
| 1576 | + * Get the invoice's gateway display title. |
|
| 1577 | + * |
|
| 1578 | + * @since 1.0.19 |
|
| 1579 | + * @return string |
|
| 1580 | + */ |
|
| 1581 | 1581 | public function get_gateway_title() { |
| 1582 | 1582 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1583 | 1583 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | /** |
| 1587 | - * Get the invoice's transaction id. |
|
| 1588 | - * |
|
| 1589 | - * @since 1.0.19 |
|
| 1590 | - * @param string $context View or edit context. |
|
| 1591 | - * @return string |
|
| 1592 | - */ |
|
| 1593 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1594 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1587 | + * Get the invoice's transaction id. |
|
| 1588 | + * |
|
| 1589 | + * @since 1.0.19 |
|
| 1590 | + * @param string $context View or edit context. |
|
| 1591 | + * @return string |
|
| 1592 | + */ |
|
| 1593 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1594 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
| 1598 | - * Get the invoice's currency. |
|
| 1599 | - * |
|
| 1600 | - * @since 1.0.19 |
|
| 1601 | - * @param string $context View or edit context. |
|
| 1602 | - * @return string |
|
| 1603 | - */ |
|
| 1604 | - public function get_currency( $context = 'view' ) { |
|
| 1598 | + * Get the invoice's currency. |
|
| 1599 | + * |
|
| 1600 | + * @since 1.0.19 |
|
| 1601 | + * @param string $context View or edit context. |
|
| 1602 | + * @return string |
|
| 1603 | + */ |
|
| 1604 | + public function get_currency( $context = 'view' ) { |
|
| 1605 | 1605 | $currency = $this->get_prop( 'currency', $context ); |
| 1606 | 1606 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | /** |
| 1610 | - * Checks if we are charging taxes for this invoice. |
|
| 1611 | - * |
|
| 1612 | - * @since 1.0.19 |
|
| 1613 | - * @param string $context View or edit context. |
|
| 1614 | - * @return bool |
|
| 1615 | - */ |
|
| 1616 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1610 | + * Checks if we are charging taxes for this invoice. |
|
| 1611 | + * |
|
| 1612 | + * @since 1.0.19 |
|
| 1613 | + * @param string $context View or edit context. |
|
| 1614 | + * @return bool |
|
| 1615 | + */ |
|
| 1616 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1617 | 1617 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | 1620 | /** |
| 1621 | - * Retrieves the remote subscription id for an invoice. |
|
| 1622 | - * |
|
| 1623 | - * @since 1.0.19 |
|
| 1624 | - * @param string $context View or edit context. |
|
| 1625 | - * @return int |
|
| 1626 | - */ |
|
| 1621 | + * Retrieves the remote subscription id for an invoice. |
|
| 1622 | + * |
|
| 1623 | + * @since 1.0.19 |
|
| 1624 | + * @param string $context View or edit context. |
|
| 1625 | + * @return int |
|
| 1626 | + */ |
|
| 1627 | 1627 | public function get_subscription_id( $context = 'view' ) { |
| 1628 | 1628 | $subscription_id = $this->get_prop( 'subscription_id', $context ); |
| 1629 | 1629 | |
@@ -1636,12 +1636,12 @@ discard block |
||
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | /** |
| 1639 | - * Retrieves the payment meta for an invoice. |
|
| 1640 | - * |
|
| 1641 | - * @since 1.0.19 |
|
| 1642 | - * @param string $context View or edit context. |
|
| 1643 | - * @return array |
|
| 1644 | - */ |
|
| 1639 | + * Retrieves the payment meta for an invoice. |
|
| 1640 | + * |
|
| 1641 | + * @since 1.0.19 |
|
| 1642 | + * @param string $context View or edit context. |
|
| 1643 | + * @return array |
|
| 1644 | + */ |
|
| 1645 | 1645 | public function get_payment_meta( $context = 'view' ) { |
| 1646 | 1646 | |
| 1647 | 1647 | return array( |
@@ -1661,11 +1661,11 @@ discard block |
||
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | /** |
| 1664 | - * Retrieves the cart details for an invoice. |
|
| 1665 | - * |
|
| 1666 | - * @since 1.0.19 |
|
| 1667 | - * @return array |
|
| 1668 | - */ |
|
| 1664 | + * Retrieves the cart details for an invoice. |
|
| 1665 | + * |
|
| 1666 | + * @since 1.0.19 |
|
| 1667 | + * @return array |
|
| 1668 | + */ |
|
| 1669 | 1669 | public function get_cart_details() { |
| 1670 | 1670 | $items = $this->get_items(); |
| 1671 | 1671 | $cart_details = array(); |
@@ -1675,16 +1675,16 @@ discard block |
||
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | 1677 | return $cart_details; |
| 1678 | - } |
|
| 1678 | + } |
|
| 1679 | 1679 | |
| 1680 | - /** |
|
| 1681 | - * Retrieves the recurring item. |
|
| 1682 | - * |
|
| 1683 | - * @return null|GetPaid_Form_Item|int |
|
| 1684 | - */ |
|
| 1685 | - public function get_recurring( $object = false ) { |
|
| 1680 | + /** |
|
| 1681 | + * Retrieves the recurring item. |
|
| 1682 | + * |
|
| 1683 | + * @return null|GetPaid_Form_Item|int |
|
| 1684 | + */ |
|
| 1685 | + public function get_recurring( $object = false ) { |
|
| 1686 | 1686 | |
| 1687 | - // Are we returning an object? |
|
| 1687 | + // Are we returning an object? |
|
| 1688 | 1688 | if ( $object ) { |
| 1689 | 1689 | return $this->get_item( $this->recurring_item ); |
| 1690 | 1690 | } |
@@ -1692,100 +1692,100 @@ discard block |
||
| 1692 | 1692 | return $this->recurring_item; |
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | - /** |
|
| 1696 | - * Retrieves the subscription name. |
|
| 1697 | - * |
|
| 1698 | - * @since 1.0.19 |
|
| 1699 | - * @return string |
|
| 1700 | - */ |
|
| 1701 | - public function get_subscription_name() { |
|
| 1695 | + /** |
|
| 1696 | + * Retrieves the subscription name. |
|
| 1697 | + * |
|
| 1698 | + * @since 1.0.19 |
|
| 1699 | + * @return string |
|
| 1700 | + */ |
|
| 1701 | + public function get_subscription_name() { |
|
| 1702 | 1702 | |
| 1703 | - // Retrieve the recurring name |
|
| 1703 | + // Retrieve the recurring name |
|
| 1704 | 1704 | $item = $this->get_recurring( true ); |
| 1705 | 1705 | |
| 1706 | - // Abort if it does not exist. |
|
| 1706 | + // Abort if it does not exist. |
|
| 1707 | 1707 | if ( empty( $item ) ) { |
| 1708 | 1708 | return ''; |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | - // Return the item name. |
|
| 1711 | + // Return the item name. |
|
| 1712 | 1712 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1713 | - } |
|
| 1714 | - |
|
| 1715 | - /** |
|
| 1716 | - * Retrieves the view url. |
|
| 1717 | - * |
|
| 1718 | - * @since 1.0.19 |
|
| 1719 | - * @return string |
|
| 1720 | - */ |
|
| 1721 | - public function get_view_url() { |
|
| 1713 | + } |
|
| 1714 | + |
|
| 1715 | + /** |
|
| 1716 | + * Retrieves the view url. |
|
| 1717 | + * |
|
| 1718 | + * @since 1.0.19 |
|
| 1719 | + * @return string |
|
| 1720 | + */ |
|
| 1721 | + public function get_view_url() { |
|
| 1722 | 1722 | $invoice_url = get_permalink( $this->get_id() ); |
| 1723 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1723 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1724 | 1724 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1725 | - } |
|
| 1725 | + } |
|
| 1726 | 1726 | |
| 1727 | - /** |
|
| 1728 | - * Retrieves the payment url. |
|
| 1729 | - * |
|
| 1730 | - * @since 1.0.19 |
|
| 1731 | - * @return string |
|
| 1732 | - */ |
|
| 1733 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1727 | + /** |
|
| 1728 | + * Retrieves the payment url. |
|
| 1729 | + * |
|
| 1730 | + * @since 1.0.19 |
|
| 1731 | + * @return string |
|
| 1732 | + */ |
|
| 1733 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1734 | 1734 | |
| 1735 | - // Retrieve the checkout url. |
|
| 1735 | + // Retrieve the checkout url. |
|
| 1736 | 1736 | $pay_url = wpinv_get_checkout_uri(); |
| 1737 | 1737 | |
| 1738 | - // Maybe force ssl. |
|
| 1738 | + // Maybe force ssl. |
|
| 1739 | 1739 | if ( is_ssl() ) { |
| 1740 | 1740 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | - // Add the invoice key. |
|
| 1744 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1743 | + // Add the invoice key. |
|
| 1744 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1745 | 1745 | |
| 1746 | - // (Maybe?) add a secret |
|
| 1746 | + // (Maybe?) add a secret |
|
| 1747 | 1747 | if ( $secret ) { |
| 1748 | 1748 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1752 | - } |
|
| 1752 | + } |
|
| 1753 | 1753 | |
| 1754 | - /** |
|
| 1755 | - * Retrieves the receipt url. |
|
| 1756 | - * |
|
| 1757 | - * @since 1.0.19 |
|
| 1758 | - * @return string |
|
| 1759 | - */ |
|
| 1760 | - public function get_receipt_url() { |
|
| 1761 | - |
|
| 1762 | - // Retrieve the checkout url. |
|
| 1754 | + /** |
|
| 1755 | + * Retrieves the receipt url. |
|
| 1756 | + * |
|
| 1757 | + * @since 1.0.19 |
|
| 1758 | + * @return string |
|
| 1759 | + */ |
|
| 1760 | + public function get_receipt_url() { |
|
| 1761 | + |
|
| 1762 | + // Retrieve the checkout url. |
|
| 1763 | 1763 | $receipt_url = wpinv_get_success_page_uri(); |
| 1764 | 1764 | |
| 1765 | - // Maybe force ssl. |
|
| 1765 | + // Maybe force ssl. |
|
| 1766 | 1766 | if ( is_ssl() ) { |
| 1767 | 1767 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | - // Add the invoice key. |
|
| 1771 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1770 | + // Add the invoice key. |
|
| 1771 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1772 | 1772 | |
| 1773 | 1773 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | 1776 | /** |
| 1777 | - * Magic method for accessing invoice properties. |
|
| 1778 | - * |
|
| 1779 | - * @since 1.0.15 |
|
| 1780 | - * @access public |
|
| 1781 | - * |
|
| 1782 | - * @param string $key Discount data to retrieve |
|
| 1783 | - * @param string $context View or edit context. |
|
| 1784 | - * @return mixed Value of the given invoice property (if set). |
|
| 1785 | - */ |
|
| 1786 | - public function get( $key, $context = 'view' ) { |
|
| 1777 | + * Magic method for accessing invoice properties. |
|
| 1778 | + * |
|
| 1779 | + * @since 1.0.15 |
|
| 1780 | + * @access public |
|
| 1781 | + * |
|
| 1782 | + * @param string $key Discount data to retrieve |
|
| 1783 | + * @param string $context View or edit context. |
|
| 1784 | + * @return mixed Value of the given invoice property (if set). |
|
| 1785 | + */ |
|
| 1786 | + public function get( $key, $context = 'view' ) { |
|
| 1787 | 1787 | return $this->get_prop( $key, $context ); |
| 1788 | - } |
|
| 1788 | + } |
|
| 1789 | 1789 | |
| 1790 | 1790 | /* |
| 1791 | 1791 | |-------------------------------------------------------------------------- |
@@ -1798,131 +1798,131 @@ discard block |
||
| 1798 | 1798 | */ |
| 1799 | 1799 | |
| 1800 | 1800 | /** |
| 1801 | - * Magic method for setting invoice properties. |
|
| 1802 | - * |
|
| 1803 | - * @since 1.0.19 |
|
| 1804 | - * @access public |
|
| 1805 | - * |
|
| 1806 | - * @param string $key Discount data to retrieve |
|
| 1807 | - * @param mixed $value new value. |
|
| 1808 | - * @return mixed Value of the given invoice property (if set). |
|
| 1809 | - */ |
|
| 1810 | - public function set( $key, $value ) { |
|
| 1801 | + * Magic method for setting invoice properties. |
|
| 1802 | + * |
|
| 1803 | + * @since 1.0.19 |
|
| 1804 | + * @access public |
|
| 1805 | + * |
|
| 1806 | + * @param string $key Discount data to retrieve |
|
| 1807 | + * @param mixed $value new value. |
|
| 1808 | + * @return mixed Value of the given invoice property (if set). |
|
| 1809 | + */ |
|
| 1810 | + public function set( $key, $value ) { |
|
| 1811 | 1811 | |
| 1812 | 1812 | $setter = "set_$key"; |
| 1813 | 1813 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1814 | 1814 | $this->{$setter}( $value ); |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | - } |
|
| 1817 | + } |
|
| 1818 | 1818 | |
| 1819 | - /** |
|
| 1820 | - * Sets item status. |
|
| 1821 | - * |
|
| 1822 | - * @since 1.0.19 |
|
| 1823 | - * @param string $new_status New status. |
|
| 1824 | - * @param string $note Optional note to add. |
|
| 1825 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1826 | - * @return array details of change. |
|
| 1827 | - */ |
|
| 1828 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1829 | - $old_status = $this->get_status(); |
|
| 1819 | + /** |
|
| 1820 | + * Sets item status. |
|
| 1821 | + * |
|
| 1822 | + * @since 1.0.19 |
|
| 1823 | + * @param string $new_status New status. |
|
| 1824 | + * @param string $note Optional note to add. |
|
| 1825 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1826 | + * @return array details of change. |
|
| 1827 | + */ |
|
| 1828 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1829 | + $old_status = $this->get_status(); |
|
| 1830 | 1830 | |
| 1831 | - $statuses = $this->get_all_statuses(); |
|
| 1831 | + $statuses = $this->get_all_statuses(); |
|
| 1832 | 1832 | |
| 1833 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1834 | - unset( $statuses[ 'draft' ] ); |
|
| 1835 | - } |
|
| 1833 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1834 | + unset( $statuses[ 'draft' ] ); |
|
| 1835 | + } |
|
| 1836 | 1836 | |
| 1837 | 1837 | |
| 1838 | - $this->set_prop( 'status', $new_status ); |
|
| 1838 | + $this->set_prop( 'status', $new_status ); |
|
| 1839 | 1839 | |
| 1840 | - // If setting the status, ensure it's set to a valid status. |
|
| 1841 | - if ( true === $this->object_read ) { |
|
| 1840 | + // If setting the status, ensure it's set to a valid status. |
|
| 1841 | + if ( true === $this->object_read ) { |
|
| 1842 | 1842 | |
| 1843 | - // Only allow valid new status. |
|
| 1844 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1845 | - $new_status = 'wpi-pending'; |
|
| 1846 | - } |
|
| 1843 | + // Only allow valid new status. |
|
| 1844 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1845 | + $new_status = 'wpi-pending'; |
|
| 1846 | + } |
|
| 1847 | 1847 | |
| 1848 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1849 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1850 | - $old_status = 'wpi-pending'; |
|
| 1851 | - } |
|
| 1848 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1849 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1850 | + $old_status = 'wpi-pending'; |
|
| 1851 | + } |
|
| 1852 | 1852 | |
| 1853 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1854 | - if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) { |
|
| 1855 | - $old_status = 'wpi-pending'; |
|
| 1856 | - } |
|
| 1853 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1854 | + if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) { |
|
| 1855 | + $old_status = 'wpi-pending'; |
|
| 1856 | + } |
|
| 1857 | 1857 | |
| 1858 | - } |
|
| 1858 | + } |
|
| 1859 | 1859 | |
| 1860 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1861 | - $this->status_transition = array( |
|
| 1862 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1863 | - 'to' => $new_status, |
|
| 1864 | - 'note' => $note, |
|
| 1865 | - 'manual' => (bool) $manual_update, |
|
| 1866 | - ); |
|
| 1860 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1861 | + $this->status_transition = array( |
|
| 1862 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1863 | + 'to' => $new_status, |
|
| 1864 | + 'note' => $note, |
|
| 1865 | + 'manual' => (bool) $manual_update, |
|
| 1866 | + ); |
|
| 1867 | 1867 | |
| 1868 | - if ( $manual_update ) { |
|
| 1869 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1870 | - } |
|
| 1868 | + if ( $manual_update ) { |
|
| 1869 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1870 | + } |
|
| 1871 | 1871 | |
| 1872 | - $this->maybe_set_date_paid(); |
|
| 1872 | + $this->maybe_set_date_paid(); |
|
| 1873 | 1873 | |
| 1874 | - } |
|
| 1874 | + } |
|
| 1875 | 1875 | |
| 1876 | - return array( |
|
| 1877 | - 'from' => $old_status, |
|
| 1878 | - 'to' => $new_status, |
|
| 1879 | - ); |
|
| 1880 | - } |
|
| 1876 | + return array( |
|
| 1877 | + 'from' => $old_status, |
|
| 1878 | + 'to' => $new_status, |
|
| 1879 | + ); |
|
| 1880 | + } |
|
| 1881 | 1881 | |
| 1882 | - /** |
|
| 1883 | - * Maybe set date paid. |
|
| 1884 | - * |
|
| 1885 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 1886 | - * order status. |
|
| 1887 | - * |
|
| 1888 | - * @since 1.0.19 |
|
| 1889 | - */ |
|
| 1890 | - public function maybe_set_date_paid() { |
|
| 1882 | + /** |
|
| 1883 | + * Maybe set date paid. |
|
| 1884 | + * |
|
| 1885 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 1886 | + * order status. |
|
| 1887 | + * |
|
| 1888 | + * @since 1.0.19 |
|
| 1889 | + */ |
|
| 1890 | + public function maybe_set_date_paid() { |
|
| 1891 | 1891 | |
| 1892 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1893 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1894 | - } |
|
| 1895 | - } |
|
| 1892 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1893 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1894 | + } |
|
| 1895 | + } |
|
| 1896 | 1896 | |
| 1897 | 1897 | /** |
| 1898 | - * Set parent invoice ID. |
|
| 1899 | - * |
|
| 1900 | - * @since 1.0.19 |
|
| 1901 | - */ |
|
| 1902 | - public function set_parent_id( $value ) { |
|
| 1903 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1904 | - return; |
|
| 1905 | - } |
|
| 1906 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1898 | + * Set parent invoice ID. |
|
| 1899 | + * |
|
| 1900 | + * @since 1.0.19 |
|
| 1901 | + */ |
|
| 1902 | + public function set_parent_id( $value ) { |
|
| 1903 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1904 | + return; |
|
| 1905 | + } |
|
| 1906 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | 1909 | /** |
| 1910 | - * Set plugin version when the invoice was created. |
|
| 1911 | - * |
|
| 1912 | - * @since 1.0.19 |
|
| 1913 | - */ |
|
| 1914 | - public function set_version( $value ) { |
|
| 1915 | - $this->set_prop( 'version', $value ); |
|
| 1910 | + * Set plugin version when the invoice was created. |
|
| 1911 | + * |
|
| 1912 | + * @since 1.0.19 |
|
| 1913 | + */ |
|
| 1914 | + public function set_version( $value ) { |
|
| 1915 | + $this->set_prop( 'version', $value ); |
|
| 1916 | 1916 | } |
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * Set date when the invoice was created. |
|
| 1920 | - * |
|
| 1921 | - * @since 1.0.19 |
|
| 1922 | - * @param string $value Value to set. |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * Set date when the invoice was created. |
|
| 1920 | + * |
|
| 1921 | + * @since 1.0.19 |
|
| 1922 | + * @param string $value Value to set. |
|
| 1923 | 1923 | * @return bool Whether or not the date was set. |
| 1924 | - */ |
|
| 1925 | - public function set_date_created( $value ) { |
|
| 1924 | + */ |
|
| 1925 | + public function set_date_created( $value ) { |
|
| 1926 | 1926 | $date = strtotime( $value ); |
| 1927 | 1927 | |
| 1928 | 1928 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1935,13 +1935,13 @@ discard block |
||
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | 1937 | /** |
| 1938 | - * Set date invoice due date. |
|
| 1939 | - * |
|
| 1940 | - * @since 1.0.19 |
|
| 1941 | - * @param string $value Value to set. |
|
| 1938 | + * Set date invoice due date. |
|
| 1939 | + * |
|
| 1940 | + * @since 1.0.19 |
|
| 1941 | + * @param string $value Value to set. |
|
| 1942 | 1942 | * @return bool Whether or not the date was set. |
| 1943 | - */ |
|
| 1944 | - public function set_due_date( $value ) { |
|
| 1943 | + */ |
|
| 1944 | + public function set_due_date( $value ) { |
|
| 1945 | 1945 | $date = strtotime( $value ); |
| 1946 | 1946 | |
| 1947 | 1947 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1949,29 +1949,29 @@ discard block |
||
| 1949 | 1949 | return true; |
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | - $this->set_prop( 'due_date', '' ); |
|
| 1952 | + $this->set_prop( 'due_date', '' ); |
|
| 1953 | 1953 | return false; |
| 1954 | 1954 | |
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | 1957 | /** |
| 1958 | - * Alias of self::set_due_date(). |
|
| 1959 | - * |
|
| 1960 | - * @since 1.0.19 |
|
| 1961 | - * @param string $value New name. |
|
| 1962 | - */ |
|
| 1963 | - public function set_date_due( $value ) { |
|
| 1964 | - $this->set_due_date( $value ); |
|
| 1958 | + * Alias of self::set_due_date(). |
|
| 1959 | + * |
|
| 1960 | + * @since 1.0.19 |
|
| 1961 | + * @param string $value New name. |
|
| 1962 | + */ |
|
| 1963 | + public function set_date_due( $value ) { |
|
| 1964 | + $this->set_due_date( $value ); |
|
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | /** |
| 1968 | - * Set date invoice was completed. |
|
| 1969 | - * |
|
| 1970 | - * @since 1.0.19 |
|
| 1971 | - * @param string $value Value to set. |
|
| 1968 | + * Set date invoice was completed. |
|
| 1969 | + * |
|
| 1970 | + * @since 1.0.19 |
|
| 1971 | + * @param string $value Value to set. |
|
| 1972 | 1972 | * @return bool Whether or not the date was set. |
| 1973 | - */ |
|
| 1974 | - public function set_completed_date( $value ) { |
|
| 1973 | + */ |
|
| 1974 | + public function set_completed_date( $value ) { |
|
| 1975 | 1975 | $date = strtotime( $value ); |
| 1976 | 1976 | |
| 1977 | 1977 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1979,29 +1979,29 @@ discard block |
||
| 1979 | 1979 | return true; |
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - $this->set_prop( 'completed_date', '' ); |
|
| 1982 | + $this->set_prop( 'completed_date', '' ); |
|
| 1983 | 1983 | return false; |
| 1984 | 1984 | |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | /** |
| 1988 | - * Alias of self::set_completed_date(). |
|
| 1989 | - * |
|
| 1990 | - * @since 1.0.19 |
|
| 1991 | - * @param string $value New name. |
|
| 1992 | - */ |
|
| 1993 | - public function set_date_completed( $value ) { |
|
| 1994 | - $this->set_completed_date( $value ); |
|
| 1988 | + * Alias of self::set_completed_date(). |
|
| 1989 | + * |
|
| 1990 | + * @since 1.0.19 |
|
| 1991 | + * @param string $value New name. |
|
| 1992 | + */ |
|
| 1993 | + public function set_date_completed( $value ) { |
|
| 1994 | + $this->set_completed_date( $value ); |
|
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | 1997 | /** |
| 1998 | - * Set date when the invoice was last modified. |
|
| 1999 | - * |
|
| 2000 | - * @since 1.0.19 |
|
| 2001 | - * @param string $value Value to set. |
|
| 1998 | + * Set date when the invoice was last modified. |
|
| 1999 | + * |
|
| 2000 | + * @since 1.0.19 |
|
| 2001 | + * @param string $value Value to set. |
|
| 2002 | 2002 | * @return bool Whether or not the date was set. |
| 2003 | - */ |
|
| 2004 | - public function set_date_modified( $value ) { |
|
| 2003 | + */ |
|
| 2004 | + public function set_date_modified( $value ) { |
|
| 2005 | 2005 | $date = strtotime( $value ); |
| 2006 | 2006 | |
| 2007 | 2007 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2009,706 +2009,706 @@ discard block |
||
| 2009 | 2009 | return true; |
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | - $this->set_prop( 'date_modified', '' ); |
|
| 2012 | + $this->set_prop( 'date_modified', '' ); |
|
| 2013 | 2013 | return false; |
| 2014 | 2014 | |
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | 2017 | /** |
| 2018 | - * Set the invoice number. |
|
| 2019 | - * |
|
| 2020 | - * @since 1.0.19 |
|
| 2021 | - * @param string $value New number. |
|
| 2022 | - */ |
|
| 2023 | - public function set_number( $value ) { |
|
| 2018 | + * Set the invoice number. |
|
| 2019 | + * |
|
| 2020 | + * @since 1.0.19 |
|
| 2021 | + * @param string $value New number. |
|
| 2022 | + */ |
|
| 2023 | + public function set_number( $value ) { |
|
| 2024 | 2024 | $number = sanitize_text_field( $value ); |
| 2025 | - $this->set_prop( 'number', $number ); |
|
| 2025 | + $this->set_prop( 'number', $number ); |
|
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | /** |
| 2029 | - * Set the invoice type. |
|
| 2030 | - * |
|
| 2031 | - * @since 1.0.19 |
|
| 2032 | - * @param string $value Type. |
|
| 2033 | - */ |
|
| 2034 | - public function set_type( $value ) { |
|
| 2029 | + * Set the invoice type. |
|
| 2030 | + * |
|
| 2031 | + * @since 1.0.19 |
|
| 2032 | + * @param string $value Type. |
|
| 2033 | + */ |
|
| 2034 | + public function set_type( $value ) { |
|
| 2035 | 2035 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2036 | - $this->set_prop( 'type', $type ); |
|
| 2037 | - } |
|
| 2036 | + $this->set_prop( 'type', $type ); |
|
| 2037 | + } |
|
| 2038 | 2038 | |
| 2039 | 2039 | /** |
| 2040 | - * Set the invoice post type. |
|
| 2041 | - * |
|
| 2042 | - * @since 1.0.19 |
|
| 2043 | - * @param string $value Post type. |
|
| 2044 | - */ |
|
| 2045 | - public function set_post_type( $value ) { |
|
| 2040 | + * Set the invoice post type. |
|
| 2041 | + * |
|
| 2042 | + * @since 1.0.19 |
|
| 2043 | + * @param string $value Post type. |
|
| 2044 | + */ |
|
| 2045 | + public function set_post_type( $value ) { |
|
| 2046 | 2046 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2047 | - $this->set_type( $value ); |
|
| 2047 | + $this->set_type( $value ); |
|
| 2048 | 2048 | $this->set_prop( 'post_type', $value ); |
| 2049 | 2049 | } |
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | 2052 | /** |
| 2053 | - * Set the invoice key. |
|
| 2054 | - * |
|
| 2055 | - * @since 1.0.19 |
|
| 2056 | - * @param string $value New key. |
|
| 2057 | - */ |
|
| 2058 | - public function set_key( $value ) { |
|
| 2053 | + * Set the invoice key. |
|
| 2054 | + * |
|
| 2055 | + * @since 1.0.19 |
|
| 2056 | + * @param string $value New key. |
|
| 2057 | + */ |
|
| 2058 | + public function set_key( $value ) { |
|
| 2059 | 2059 | $key = sanitize_text_field( $value ); |
| 2060 | - $this->set_prop( 'key', $key ); |
|
| 2060 | + $this->set_prop( 'key', $key ); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | /** |
| 2064 | - * Set the invoice mode. |
|
| 2065 | - * |
|
| 2066 | - * @since 1.0.19 |
|
| 2067 | - * @param string $value mode. |
|
| 2068 | - */ |
|
| 2069 | - public function set_mode( $value ) { |
|
| 2064 | + * Set the invoice mode. |
|
| 2065 | + * |
|
| 2066 | + * @since 1.0.19 |
|
| 2067 | + * @param string $value mode. |
|
| 2068 | + */ |
|
| 2069 | + public function set_mode( $value ) { |
|
| 2070 | 2070 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
| 2071 | 2071 | $this->set_prop( 'value', $value ); |
| 2072 | 2072 | } |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | 2075 | /** |
| 2076 | - * Set the invoice path. |
|
| 2077 | - * |
|
| 2078 | - * @since 1.0.19 |
|
| 2079 | - * @param string $value path. |
|
| 2080 | - */ |
|
| 2081 | - public function set_path( $value ) { |
|
| 2076 | + * Set the invoice path. |
|
| 2077 | + * |
|
| 2078 | + * @since 1.0.19 |
|
| 2079 | + * @param string $value path. |
|
| 2080 | + */ |
|
| 2081 | + public function set_path( $value ) { |
|
| 2082 | 2082 | $this->set_prop( 'path', $value ); |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | /** |
| 2086 | - * Set the invoice name. |
|
| 2087 | - * |
|
| 2088 | - * @since 1.0.19 |
|
| 2089 | - * @param string $value New name. |
|
| 2090 | - */ |
|
| 2091 | - public function set_name( $value ) { |
|
| 2086 | + * Set the invoice name. |
|
| 2087 | + * |
|
| 2088 | + * @since 1.0.19 |
|
| 2089 | + * @param string $value New name. |
|
| 2090 | + */ |
|
| 2091 | + public function set_name( $value ) { |
|
| 2092 | 2092 | $name = sanitize_text_field( $value ); |
| 2093 | - $this->set_prop( 'name', $name ); |
|
| 2093 | + $this->set_prop( 'name', $name ); |
|
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | 2096 | /** |
| 2097 | - * Alias of self::set_name(). |
|
| 2098 | - * |
|
| 2099 | - * @since 1.0.19 |
|
| 2100 | - * @param string $value New name. |
|
| 2101 | - */ |
|
| 2102 | - public function set_title( $value ) { |
|
| 2103 | - $this->set_name( $value ); |
|
| 2097 | + * Alias of self::set_name(). |
|
| 2098 | + * |
|
| 2099 | + * @since 1.0.19 |
|
| 2100 | + * @param string $value New name. |
|
| 2101 | + */ |
|
| 2102 | + public function set_title( $value ) { |
|
| 2103 | + $this->set_name( $value ); |
|
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | 2106 | /** |
| 2107 | - * Set the invoice description. |
|
| 2108 | - * |
|
| 2109 | - * @since 1.0.19 |
|
| 2110 | - * @param string $value New description. |
|
| 2111 | - */ |
|
| 2112 | - public function set_description( $value ) { |
|
| 2107 | + * Set the invoice description. |
|
| 2108 | + * |
|
| 2109 | + * @since 1.0.19 |
|
| 2110 | + * @param string $value New description. |
|
| 2111 | + */ |
|
| 2112 | + public function set_description( $value ) { |
|
| 2113 | 2113 | $description = wp_kses_post( $value ); |
| 2114 | - return $this->set_prop( 'description', $description ); |
|
| 2114 | + return $this->set_prop( 'description', $description ); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | 2117 | /** |
| 2118 | - * Alias of self::set_description(). |
|
| 2119 | - * |
|
| 2120 | - * @since 1.0.19 |
|
| 2121 | - * @param string $value New description. |
|
| 2122 | - */ |
|
| 2123 | - public function set_excerpt( $value ) { |
|
| 2124 | - $this->set_description( $value ); |
|
| 2118 | + * Alias of self::set_description(). |
|
| 2119 | + * |
|
| 2120 | + * @since 1.0.19 |
|
| 2121 | + * @param string $value New description. |
|
| 2122 | + */ |
|
| 2123 | + public function set_excerpt( $value ) { |
|
| 2124 | + $this->set_description( $value ); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | 2127 | /** |
| 2128 | - * Alias of self::set_description(). |
|
| 2129 | - * |
|
| 2130 | - * @since 1.0.19 |
|
| 2131 | - * @param string $value New description. |
|
| 2132 | - */ |
|
| 2133 | - public function set_summary( $value ) { |
|
| 2134 | - $this->set_description( $value ); |
|
| 2128 | + * Alias of self::set_description(). |
|
| 2129 | + * |
|
| 2130 | + * @since 1.0.19 |
|
| 2131 | + * @param string $value New description. |
|
| 2132 | + */ |
|
| 2133 | + public function set_summary( $value ) { |
|
| 2134 | + $this->set_description( $value ); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | /** |
| 2138 | - * Set the receiver of the invoice. |
|
| 2139 | - * |
|
| 2140 | - * @since 1.0.19 |
|
| 2141 | - * @param int $value New author. |
|
| 2142 | - */ |
|
| 2143 | - public function set_author( $value ) { |
|
| 2144 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2138 | + * Set the receiver of the invoice. |
|
| 2139 | + * |
|
| 2140 | + * @since 1.0.19 |
|
| 2141 | + * @param int $value New author. |
|
| 2142 | + */ |
|
| 2143 | + public function set_author( $value ) { |
|
| 2144 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2145 | 2145 | |
| 2146 | - if ( $user && $user->ID ) { |
|
| 2147 | - $this->set_prop( 'author', $user->ID ); |
|
| 2148 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2149 | - } |
|
| 2146 | + if ( $user && $user->ID ) { |
|
| 2147 | + $this->set_prop( 'author', $user->ID ); |
|
| 2148 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2149 | + } |
|
| 2150 | 2150 | |
| 2151 | 2151 | } |
| 2152 | 2152 | |
| 2153 | 2153 | /** |
| 2154 | - * Alias of self::set_author(). |
|
| 2155 | - * |
|
| 2156 | - * @since 1.0.19 |
|
| 2157 | - * @param int $value New user id. |
|
| 2158 | - */ |
|
| 2159 | - public function set_user_id( $value ) { |
|
| 2160 | - $this->set_author( $value ); |
|
| 2154 | + * Alias of self::set_author(). |
|
| 2155 | + * |
|
| 2156 | + * @since 1.0.19 |
|
| 2157 | + * @param int $value New user id. |
|
| 2158 | + */ |
|
| 2159 | + public function set_user_id( $value ) { |
|
| 2160 | + $this->set_author( $value ); |
|
| 2161 | + } |
|
| 2162 | + |
|
| 2163 | + /** |
|
| 2164 | + * Alias of self::set_author(). |
|
| 2165 | + * |
|
| 2166 | + * @since 1.0.19 |
|
| 2167 | + * @param int $value New user id. |
|
| 2168 | + */ |
|
| 2169 | + public function set_customer_id( $value ) { |
|
| 2170 | + $this->set_author( $value ); |
|
| 2171 | + } |
|
| 2172 | + |
|
| 2173 | + /** |
|
| 2174 | + * Set the customer's ip. |
|
| 2175 | + * |
|
| 2176 | + * @since 1.0.19 |
|
| 2177 | + * @param string $value ip address. |
|
| 2178 | + */ |
|
| 2179 | + public function set_ip( $value ) { |
|
| 2180 | + $this->set_prop( 'ip', $value ); |
|
| 2181 | + } |
|
| 2182 | + |
|
| 2183 | + /** |
|
| 2184 | + * Alias of self::set_ip(). |
|
| 2185 | + * |
|
| 2186 | + * @since 1.0.19 |
|
| 2187 | + * @param string $value ip address. |
|
| 2188 | + */ |
|
| 2189 | + public function set_user_ip( $value ) { |
|
| 2190 | + $this->set_ip( $value ); |
|
| 2161 | 2191 | } |
| 2162 | 2192 | |
| 2163 | 2193 | /** |
| 2164 | - * Alias of self::set_author(). |
|
| 2165 | - * |
|
| 2166 | - * @since 1.0.19 |
|
| 2167 | - * @param int $value New user id. |
|
| 2168 | - */ |
|
| 2169 | - public function set_customer_id( $value ) { |
|
| 2170 | - $this->set_author( $value ); |
|
| 2194 | + * Set the customer's first name. |
|
| 2195 | + * |
|
| 2196 | + * @since 1.0.19 |
|
| 2197 | + * @param string $value first name. |
|
| 2198 | + */ |
|
| 2199 | + public function set_first_name( $value ) { |
|
| 2200 | + $this->set_prop( 'first_name', $value ); |
|
| 2171 | 2201 | } |
| 2172 | 2202 | |
| 2173 | 2203 | /** |
| 2174 | - * Set the customer's ip. |
|
| 2175 | - * |
|
| 2176 | - * @since 1.0.19 |
|
| 2177 | - * @param string $value ip address. |
|
| 2178 | - */ |
|
| 2179 | - public function set_ip( $value ) { |
|
| 2180 | - $this->set_prop( 'ip', $value ); |
|
| 2204 | + * Alias of self::set_first_name(). |
|
| 2205 | + * |
|
| 2206 | + * @since 1.0.19 |
|
| 2207 | + * @param string $value first name. |
|
| 2208 | + */ |
|
| 2209 | + public function set_user_first_name( $value ) { |
|
| 2210 | + $this->set_first_name( $value ); |
|
| 2181 | 2211 | } |
| 2182 | 2212 | |
| 2183 | 2213 | /** |
| 2184 | - * Alias of self::set_ip(). |
|
| 2185 | - * |
|
| 2186 | - * @since 1.0.19 |
|
| 2187 | - * @param string $value ip address. |
|
| 2188 | - */ |
|
| 2189 | - public function set_user_ip( $value ) { |
|
| 2190 | - $this->set_ip( $value ); |
|
| 2214 | + * Alias of self::set_first_name(). |
|
| 2215 | + * |
|
| 2216 | + * @since 1.0.19 |
|
| 2217 | + * @param string $value first name. |
|
| 2218 | + */ |
|
| 2219 | + public function set_customer_first_name( $value ) { |
|
| 2220 | + $this->set_first_name( $value ); |
|
| 2191 | 2221 | } |
| 2192 | 2222 | |
| 2193 | 2223 | /** |
| 2194 | - * Set the customer's first name. |
|
| 2195 | - * |
|
| 2196 | - * @since 1.0.19 |
|
| 2197 | - * @param string $value first name. |
|
| 2198 | - */ |
|
| 2199 | - public function set_first_name( $value ) { |
|
| 2200 | - $this->set_prop( 'first_name', $value ); |
|
| 2224 | + * Set the customer's last name. |
|
| 2225 | + * |
|
| 2226 | + * @since 1.0.19 |
|
| 2227 | + * @param string $value last name. |
|
| 2228 | + */ |
|
| 2229 | + public function set_last_name( $value ) { |
|
| 2230 | + $this->set_prop( 'last_name', $value ); |
|
| 2201 | 2231 | } |
| 2202 | 2232 | |
| 2203 | 2233 | /** |
| 2204 | - * Alias of self::set_first_name(). |
|
| 2205 | - * |
|
| 2206 | - * @since 1.0.19 |
|
| 2207 | - * @param string $value first name. |
|
| 2208 | - */ |
|
| 2209 | - public function set_user_first_name( $value ) { |
|
| 2210 | - $this->set_first_name( $value ); |
|
| 2234 | + * Alias of self::set_last_name(). |
|
| 2235 | + * |
|
| 2236 | + * @since 1.0.19 |
|
| 2237 | + * @param string $value last name. |
|
| 2238 | + */ |
|
| 2239 | + public function set_user_last_name( $value ) { |
|
| 2240 | + $this->set_last_name( $value ); |
|
| 2211 | 2241 | } |
| 2212 | 2242 | |
| 2213 | 2243 | /** |
| 2214 | - * Alias of self::set_first_name(). |
|
| 2215 | - * |
|
| 2216 | - * @since 1.0.19 |
|
| 2217 | - * @param string $value first name. |
|
| 2218 | - */ |
|
| 2219 | - public function set_customer_first_name( $value ) { |
|
| 2220 | - $this->set_first_name( $value ); |
|
| 2244 | + * Alias of self::set_last_name(). |
|
| 2245 | + * |
|
| 2246 | + * @since 1.0.19 |
|
| 2247 | + * @param string $value last name. |
|
| 2248 | + */ |
|
| 2249 | + public function set_customer_last_name( $value ) { |
|
| 2250 | + $this->set_last_name( $value ); |
|
| 2221 | 2251 | } |
| 2222 | 2252 | |
| 2223 | 2253 | /** |
| 2224 | - * Set the customer's last name. |
|
| 2225 | - * |
|
| 2226 | - * @since 1.0.19 |
|
| 2227 | - * @param string $value last name. |
|
| 2228 | - */ |
|
| 2229 | - public function set_last_name( $value ) { |
|
| 2230 | - $this->set_prop( 'last_name', $value ); |
|
| 2254 | + * Set the customer's phone number. |
|
| 2255 | + * |
|
| 2256 | + * @since 1.0.19 |
|
| 2257 | + * @param string $value phone. |
|
| 2258 | + */ |
|
| 2259 | + public function set_phone( $value ) { |
|
| 2260 | + $this->set_prop( 'phone', $value ); |
|
| 2231 | 2261 | } |
| 2232 | 2262 | |
| 2233 | 2263 | /** |
| 2234 | - * Alias of self::set_last_name(). |
|
| 2235 | - * |
|
| 2236 | - * @since 1.0.19 |
|
| 2237 | - * @param string $value last name. |
|
| 2238 | - */ |
|
| 2239 | - public function set_user_last_name( $value ) { |
|
| 2240 | - $this->set_last_name( $value ); |
|
| 2264 | + * Alias of self::set_phone(). |
|
| 2265 | + * |
|
| 2266 | + * @since 1.0.19 |
|
| 2267 | + * @param string $value phone. |
|
| 2268 | + */ |
|
| 2269 | + public function set_user_phone( $value ) { |
|
| 2270 | + $this->set_phone( $value ); |
|
| 2241 | 2271 | } |
| 2242 | 2272 | |
| 2243 | 2273 | /** |
| 2244 | - * Alias of self::set_last_name(). |
|
| 2245 | - * |
|
| 2246 | - * @since 1.0.19 |
|
| 2247 | - * @param string $value last name. |
|
| 2248 | - */ |
|
| 2249 | - public function set_customer_last_name( $value ) { |
|
| 2250 | - $this->set_last_name( $value ); |
|
| 2274 | + * Alias of self::set_phone(). |
|
| 2275 | + * |
|
| 2276 | + * @since 1.0.19 |
|
| 2277 | + * @param string $value phone. |
|
| 2278 | + */ |
|
| 2279 | + public function set_customer_phone( $value ) { |
|
| 2280 | + $this->set_phone( $value ); |
|
| 2251 | 2281 | } |
| 2252 | 2282 | |
| 2253 | 2283 | /** |
| 2254 | - * Set the customer's phone number. |
|
| 2255 | - * |
|
| 2256 | - * @since 1.0.19 |
|
| 2257 | - * @param string $value phone. |
|
| 2258 | - */ |
|
| 2259 | - public function set_phone( $value ) { |
|
| 2260 | - $this->set_prop( 'phone', $value ); |
|
| 2284 | + * Alias of self::set_phone(). |
|
| 2285 | + * |
|
| 2286 | + * @since 1.0.19 |
|
| 2287 | + * @param string $value phone. |
|
| 2288 | + */ |
|
| 2289 | + public function set_phone_number( $value ) { |
|
| 2290 | + $this->set_phone( $value ); |
|
| 2261 | 2291 | } |
| 2262 | 2292 | |
| 2263 | 2293 | /** |
| 2264 | - * Alias of self::set_phone(). |
|
| 2265 | - * |
|
| 2266 | - * @since 1.0.19 |
|
| 2267 | - * @param string $value phone. |
|
| 2268 | - */ |
|
| 2269 | - public function set_user_phone( $value ) { |
|
| 2270 | - $this->set_phone( $value ); |
|
| 2294 | + * Set the customer's email address. |
|
| 2295 | + * |
|
| 2296 | + * @since 1.0.19 |
|
| 2297 | + * @param string $value email address. |
|
| 2298 | + */ |
|
| 2299 | + public function set_email( $value ) { |
|
| 2300 | + $this->set_prop( 'email', $value ); |
|
| 2271 | 2301 | } |
| 2272 | 2302 | |
| 2273 | 2303 | /** |
| 2274 | - * Alias of self::set_phone(). |
|
| 2275 | - * |
|
| 2276 | - * @since 1.0.19 |
|
| 2277 | - * @param string $value phone. |
|
| 2278 | - */ |
|
| 2279 | - public function set_customer_phone( $value ) { |
|
| 2280 | - $this->set_phone( $value ); |
|
| 2304 | + * Alias of self::set_email(). |
|
| 2305 | + * |
|
| 2306 | + * @since 1.0.19 |
|
| 2307 | + * @param string $value email address. |
|
| 2308 | + */ |
|
| 2309 | + public function set_user_email( $value ) { |
|
| 2310 | + $this->set_email( $value ); |
|
| 2281 | 2311 | } |
| 2282 | 2312 | |
| 2283 | 2313 | /** |
| 2284 | - * Alias of self::set_phone(). |
|
| 2285 | - * |
|
| 2286 | - * @since 1.0.19 |
|
| 2287 | - * @param string $value phone. |
|
| 2288 | - */ |
|
| 2289 | - public function set_phone_number( $value ) { |
|
| 2290 | - $this->set_phone( $value ); |
|
| 2314 | + * Alias of self::set_email(). |
|
| 2315 | + * |
|
| 2316 | + * @since 1.0.19 |
|
| 2317 | + * @param string $value email address. |
|
| 2318 | + */ |
|
| 2319 | + public function set_email_address( $value ) { |
|
| 2320 | + $this->set_email( $value ); |
|
| 2291 | 2321 | } |
| 2292 | 2322 | |
| 2293 | 2323 | /** |
| 2294 | - * Set the customer's email address. |
|
| 2295 | - * |
|
| 2296 | - * @since 1.0.19 |
|
| 2297 | - * @param string $value email address. |
|
| 2298 | - */ |
|
| 2299 | - public function set_email( $value ) { |
|
| 2300 | - $this->set_prop( 'email', $value ); |
|
| 2324 | + * Alias of self::set_email(). |
|
| 2325 | + * |
|
| 2326 | + * @since 1.0.19 |
|
| 2327 | + * @param string $value email address. |
|
| 2328 | + */ |
|
| 2329 | + public function set_customer_email( $value ) { |
|
| 2330 | + $this->set_email( $value ); |
|
| 2301 | 2331 | } |
| 2302 | 2332 | |
| 2303 | 2333 | /** |
| 2304 | - * Alias of self::set_email(). |
|
| 2305 | - * |
|
| 2306 | - * @since 1.0.19 |
|
| 2307 | - * @param string $value email address. |
|
| 2308 | - */ |
|
| 2309 | - public function set_user_email( $value ) { |
|
| 2310 | - $this->set_email( $value ); |
|
| 2334 | + * Set the customer's country. |
|
| 2335 | + * |
|
| 2336 | + * @since 1.0.19 |
|
| 2337 | + * @param string $value country. |
|
| 2338 | + */ |
|
| 2339 | + public function set_country( $value ) { |
|
| 2340 | + $this->set_prop( 'country', $value ); |
|
| 2311 | 2341 | } |
| 2312 | 2342 | |
| 2313 | 2343 | /** |
| 2314 | - * Alias of self::set_email(). |
|
| 2315 | - * |
|
| 2316 | - * @since 1.0.19 |
|
| 2317 | - * @param string $value email address. |
|
| 2318 | - */ |
|
| 2319 | - public function set_email_address( $value ) { |
|
| 2320 | - $this->set_email( $value ); |
|
| 2344 | + * Alias of self::set_country(). |
|
| 2345 | + * |
|
| 2346 | + * @since 1.0.19 |
|
| 2347 | + * @param string $value country. |
|
| 2348 | + */ |
|
| 2349 | + public function set_user_country( $value ) { |
|
| 2350 | + $this->set_country( $value ); |
|
| 2321 | 2351 | } |
| 2322 | 2352 | |
| 2323 | 2353 | /** |
| 2324 | - * Alias of self::set_email(). |
|
| 2325 | - * |
|
| 2326 | - * @since 1.0.19 |
|
| 2327 | - * @param string $value email address. |
|
| 2328 | - */ |
|
| 2329 | - public function set_customer_email( $value ) { |
|
| 2330 | - $this->set_email( $value ); |
|
| 2354 | + * Alias of self::set_country(). |
|
| 2355 | + * |
|
| 2356 | + * @since 1.0.19 |
|
| 2357 | + * @param string $value country. |
|
| 2358 | + */ |
|
| 2359 | + public function set_customer_country( $value ) { |
|
| 2360 | + $this->set_country( $value ); |
|
| 2331 | 2361 | } |
| 2332 | 2362 | |
| 2333 | 2363 | /** |
| 2334 | - * Set the customer's country. |
|
| 2335 | - * |
|
| 2336 | - * @since 1.0.19 |
|
| 2337 | - * @param string $value country. |
|
| 2338 | - */ |
|
| 2339 | - public function set_country( $value ) { |
|
| 2340 | - $this->set_prop( 'country', $value ); |
|
| 2364 | + * Set the customer's state. |
|
| 2365 | + * |
|
| 2366 | + * @since 1.0.19 |
|
| 2367 | + * @param string $value state. |
|
| 2368 | + */ |
|
| 2369 | + public function set_state( $value ) { |
|
| 2370 | + $this->set_prop( 'state', $value ); |
|
| 2341 | 2371 | } |
| 2342 | 2372 | |
| 2343 | 2373 | /** |
| 2344 | - * Alias of self::set_country(). |
|
| 2345 | - * |
|
| 2346 | - * @since 1.0.19 |
|
| 2347 | - * @param string $value country. |
|
| 2348 | - */ |
|
| 2349 | - public function set_user_country( $value ) { |
|
| 2350 | - $this->set_country( $value ); |
|
| 2374 | + * Alias of self::set_state(). |
|
| 2375 | + * |
|
| 2376 | + * @since 1.0.19 |
|
| 2377 | + * @param string $value state. |
|
| 2378 | + */ |
|
| 2379 | + public function set_user_state( $value ) { |
|
| 2380 | + $this->set_state( $value ); |
|
| 2351 | 2381 | } |
| 2352 | 2382 | |
| 2353 | 2383 | /** |
| 2354 | - * Alias of self::set_country(). |
|
| 2355 | - * |
|
| 2356 | - * @since 1.0.19 |
|
| 2357 | - * @param string $value country. |
|
| 2358 | - */ |
|
| 2359 | - public function set_customer_country( $value ) { |
|
| 2360 | - $this->set_country( $value ); |
|
| 2384 | + * Alias of self::set_state(). |
|
| 2385 | + * |
|
| 2386 | + * @since 1.0.19 |
|
| 2387 | + * @param string $value state. |
|
| 2388 | + */ |
|
| 2389 | + public function set_customer_state( $value ) { |
|
| 2390 | + $this->set_state( $value ); |
|
| 2361 | 2391 | } |
| 2362 | 2392 | |
| 2363 | 2393 | /** |
| 2364 | - * Set the customer's state. |
|
| 2365 | - * |
|
| 2366 | - * @since 1.0.19 |
|
| 2367 | - * @param string $value state. |
|
| 2368 | - */ |
|
| 2369 | - public function set_state( $value ) { |
|
| 2370 | - $this->set_prop( 'state', $value ); |
|
| 2394 | + * Set the customer's city. |
|
| 2395 | + * |
|
| 2396 | + * @since 1.0.19 |
|
| 2397 | + * @param string $value city. |
|
| 2398 | + */ |
|
| 2399 | + public function set_city( $value ) { |
|
| 2400 | + $this->set_prop( 'city', $value ); |
|
| 2371 | 2401 | } |
| 2372 | 2402 | |
| 2373 | 2403 | /** |
| 2374 | - * Alias of self::set_state(). |
|
| 2375 | - * |
|
| 2376 | - * @since 1.0.19 |
|
| 2377 | - * @param string $value state. |
|
| 2378 | - */ |
|
| 2379 | - public function set_user_state( $value ) { |
|
| 2380 | - $this->set_state( $value ); |
|
| 2404 | + * Alias of self::set_city(). |
|
| 2405 | + * |
|
| 2406 | + * @since 1.0.19 |
|
| 2407 | + * @param string $value city. |
|
| 2408 | + */ |
|
| 2409 | + public function set_user_city( $value ) { |
|
| 2410 | + $this->set_city( $value ); |
|
| 2381 | 2411 | } |
| 2382 | 2412 | |
| 2383 | 2413 | /** |
| 2384 | - * Alias of self::set_state(). |
|
| 2385 | - * |
|
| 2386 | - * @since 1.0.19 |
|
| 2387 | - * @param string $value state. |
|
| 2388 | - */ |
|
| 2389 | - public function set_customer_state( $value ) { |
|
| 2390 | - $this->set_state( $value ); |
|
| 2414 | + * Alias of self::set_city(). |
|
| 2415 | + * |
|
| 2416 | + * @since 1.0.19 |
|
| 2417 | + * @param string $value city. |
|
| 2418 | + */ |
|
| 2419 | + public function set_customer_city( $value ) { |
|
| 2420 | + $this->set_city( $value ); |
|
| 2391 | 2421 | } |
| 2392 | 2422 | |
| 2393 | 2423 | /** |
| 2394 | - * Set the customer's city. |
|
| 2395 | - * |
|
| 2396 | - * @since 1.0.19 |
|
| 2397 | - * @param string $value city. |
|
| 2398 | - */ |
|
| 2399 | - public function set_city( $value ) { |
|
| 2400 | - $this->set_prop( 'city', $value ); |
|
| 2424 | + * Set the customer's zip code. |
|
| 2425 | + * |
|
| 2426 | + * @since 1.0.19 |
|
| 2427 | + * @param string $value zip. |
|
| 2428 | + */ |
|
| 2429 | + public function set_zip( $value ) { |
|
| 2430 | + $this->set_prop( 'zip', $value ); |
|
| 2401 | 2431 | } |
| 2402 | 2432 | |
| 2403 | 2433 | /** |
| 2404 | - * Alias of self::set_city(). |
|
| 2405 | - * |
|
| 2406 | - * @since 1.0.19 |
|
| 2407 | - * @param string $value city. |
|
| 2408 | - */ |
|
| 2409 | - public function set_user_city( $value ) { |
|
| 2410 | - $this->set_city( $value ); |
|
| 2434 | + * Alias of self::set_zip(). |
|
| 2435 | + * |
|
| 2436 | + * @since 1.0.19 |
|
| 2437 | + * @param string $value zip. |
|
| 2438 | + */ |
|
| 2439 | + public function set_user_zip( $value ) { |
|
| 2440 | + $this->set_zip( $value ); |
|
| 2411 | 2441 | } |
| 2412 | 2442 | |
| 2413 | 2443 | /** |
| 2414 | - * Alias of self::set_city(). |
|
| 2415 | - * |
|
| 2416 | - * @since 1.0.19 |
|
| 2417 | - * @param string $value city. |
|
| 2418 | - */ |
|
| 2419 | - public function set_customer_city( $value ) { |
|
| 2420 | - $this->set_city( $value ); |
|
| 2444 | + * Alias of self::set_zip(). |
|
| 2445 | + * |
|
| 2446 | + * @since 1.0.19 |
|
| 2447 | + * @param string $value zip. |
|
| 2448 | + */ |
|
| 2449 | + public function set_customer_zip( $value ) { |
|
| 2450 | + $this->set_zip( $value ); |
|
| 2421 | 2451 | } |
| 2422 | 2452 | |
| 2423 | 2453 | /** |
| 2424 | - * Set the customer's zip code. |
|
| 2425 | - * |
|
| 2426 | - * @since 1.0.19 |
|
| 2427 | - * @param string $value zip. |
|
| 2428 | - */ |
|
| 2429 | - public function set_zip( $value ) { |
|
| 2430 | - $this->set_prop( 'zip', $value ); |
|
| 2454 | + * Set the customer's company. |
|
| 2455 | + * |
|
| 2456 | + * @since 1.0.19 |
|
| 2457 | + * @param string $value company. |
|
| 2458 | + */ |
|
| 2459 | + public function set_company( $value ) { |
|
| 2460 | + $this->set_prop( 'company', $value ); |
|
| 2431 | 2461 | } |
| 2432 | 2462 | |
| 2433 | 2463 | /** |
| 2434 | - * Alias of self::set_zip(). |
|
| 2435 | - * |
|
| 2436 | - * @since 1.0.19 |
|
| 2437 | - * @param string $value zip. |
|
| 2438 | - */ |
|
| 2439 | - public function set_user_zip( $value ) { |
|
| 2440 | - $this->set_zip( $value ); |
|
| 2464 | + * Alias of self::set_company(). |
|
| 2465 | + * |
|
| 2466 | + * @since 1.0.19 |
|
| 2467 | + * @param string $value company. |
|
| 2468 | + */ |
|
| 2469 | + public function set_user_company( $value ) { |
|
| 2470 | + $this->set_company( $value ); |
|
| 2441 | 2471 | } |
| 2442 | 2472 | |
| 2443 | 2473 | /** |
| 2444 | - * Alias of self::set_zip(). |
|
| 2445 | - * |
|
| 2446 | - * @since 1.0.19 |
|
| 2447 | - * @param string $value zip. |
|
| 2448 | - */ |
|
| 2449 | - public function set_customer_zip( $value ) { |
|
| 2450 | - $this->set_zip( $value ); |
|
| 2474 | + * Alias of self::set_company(). |
|
| 2475 | + * |
|
| 2476 | + * @since 1.0.19 |
|
| 2477 | + * @param string $value company. |
|
| 2478 | + */ |
|
| 2479 | + public function set_customer_company( $value ) { |
|
| 2480 | + $this->set_company( $value ); |
|
| 2451 | 2481 | } |
| 2452 | 2482 | |
| 2453 | 2483 | /** |
| 2454 | - * Set the customer's company. |
|
| 2455 | - * |
|
| 2456 | - * @since 1.0.19 |
|
| 2457 | - * @param string $value company. |
|
| 2458 | - */ |
|
| 2459 | - public function set_company( $value ) { |
|
| 2460 | - $this->set_prop( 'company', $value ); |
|
| 2484 | + * Set the customer's var number. |
|
| 2485 | + * |
|
| 2486 | + * @since 1.0.19 |
|
| 2487 | + * @param string $value var number. |
|
| 2488 | + */ |
|
| 2489 | + public function set_vat_number( $value ) { |
|
| 2490 | + $this->set_prop( 'vat_number', $value ); |
|
| 2461 | 2491 | } |
| 2462 | 2492 | |
| 2463 | 2493 | /** |
| 2464 | - * Alias of self::set_company(). |
|
| 2465 | - * |
|
| 2466 | - * @since 1.0.19 |
|
| 2467 | - * @param string $value company. |
|
| 2468 | - */ |
|
| 2469 | - public function set_user_company( $value ) { |
|
| 2470 | - $this->set_company( $value ); |
|
| 2494 | + * Alias of self::set_vat_number(). |
|
| 2495 | + * |
|
| 2496 | + * @since 1.0.19 |
|
| 2497 | + * @param string $value var number. |
|
| 2498 | + */ |
|
| 2499 | + public function set_user_vat_number( $value ) { |
|
| 2500 | + $this->set_vat_number( $value ); |
|
| 2471 | 2501 | } |
| 2472 | 2502 | |
| 2473 | 2503 | /** |
| 2474 | - * Alias of self::set_company(). |
|
| 2475 | - * |
|
| 2476 | - * @since 1.0.19 |
|
| 2477 | - * @param string $value company. |
|
| 2478 | - */ |
|
| 2479 | - public function set_customer_company( $value ) { |
|
| 2480 | - $this->set_company( $value ); |
|
| 2504 | + * Alias of self::set_vat_number(). |
|
| 2505 | + * |
|
| 2506 | + * @since 1.0.19 |
|
| 2507 | + * @param string $value var number. |
|
| 2508 | + */ |
|
| 2509 | + public function set_customer_vat_number( $value ) { |
|
| 2510 | + $this->set_vat_number( $value ); |
|
| 2481 | 2511 | } |
| 2482 | 2512 | |
| 2483 | 2513 | /** |
| 2484 | - * Set the customer's var number. |
|
| 2485 | - * |
|
| 2486 | - * @since 1.0.19 |
|
| 2487 | - * @param string $value var number. |
|
| 2488 | - */ |
|
| 2489 | - public function set_vat_number( $value ) { |
|
| 2490 | - $this->set_prop( 'vat_number', $value ); |
|
| 2514 | + * Set the customer's vat rate. |
|
| 2515 | + * |
|
| 2516 | + * @since 1.0.19 |
|
| 2517 | + * @param string $value var rate. |
|
| 2518 | + */ |
|
| 2519 | + public function set_vat_rate( $value ) { |
|
| 2520 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2491 | 2521 | } |
| 2492 | 2522 | |
| 2493 | 2523 | /** |
| 2494 | - * Alias of self::set_vat_number(). |
|
| 2495 | - * |
|
| 2496 | - * @since 1.0.19 |
|
| 2497 | - * @param string $value var number. |
|
| 2498 | - */ |
|
| 2499 | - public function set_user_vat_number( $value ) { |
|
| 2500 | - $this->set_vat_number( $value ); |
|
| 2524 | + * Alias of self::set_vat_rate(). |
|
| 2525 | + * |
|
| 2526 | + * @since 1.0.19 |
|
| 2527 | + * @param string $value var number. |
|
| 2528 | + */ |
|
| 2529 | + public function set_user_vat_rate( $value ) { |
|
| 2530 | + $this->set_vat_rate( $value ); |
|
| 2501 | 2531 | } |
| 2502 | 2532 | |
| 2503 | 2533 | /** |
| 2504 | - * Alias of self::set_vat_number(). |
|
| 2505 | - * |
|
| 2506 | - * @since 1.0.19 |
|
| 2507 | - * @param string $value var number. |
|
| 2508 | - */ |
|
| 2509 | - public function set_customer_vat_number( $value ) { |
|
| 2510 | - $this->set_vat_number( $value ); |
|
| 2534 | + * Alias of self::set_vat_rate(). |
|
| 2535 | + * |
|
| 2536 | + * @since 1.0.19 |
|
| 2537 | + * @param string $value var number. |
|
| 2538 | + */ |
|
| 2539 | + public function set_customer_vat_rate( $value ) { |
|
| 2540 | + $this->set_vat_rate( $value ); |
|
| 2511 | 2541 | } |
| 2512 | 2542 | |
| 2513 | 2543 | /** |
| 2514 | - * Set the customer's vat rate. |
|
| 2515 | - * |
|
| 2516 | - * @since 1.0.19 |
|
| 2517 | - * @param string $value var rate. |
|
| 2518 | - */ |
|
| 2519 | - public function set_vat_rate( $value ) { |
|
| 2520 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2544 | + * Set the customer's address. |
|
| 2545 | + * |
|
| 2546 | + * @since 1.0.19 |
|
| 2547 | + * @param string $value address. |
|
| 2548 | + */ |
|
| 2549 | + public function set_address( $value ) { |
|
| 2550 | + $this->set_prop( 'address', $value ); |
|
| 2521 | 2551 | } |
| 2522 | 2552 | |
| 2523 | 2553 | /** |
| 2524 | - * Alias of self::set_vat_rate(). |
|
| 2525 | - * |
|
| 2526 | - * @since 1.0.19 |
|
| 2527 | - * @param string $value var number. |
|
| 2528 | - */ |
|
| 2529 | - public function set_user_vat_rate( $value ) { |
|
| 2530 | - $this->set_vat_rate( $value ); |
|
| 2554 | + * Alias of self::set_address(). |
|
| 2555 | + * |
|
| 2556 | + * @since 1.0.19 |
|
| 2557 | + * @param string $value address. |
|
| 2558 | + */ |
|
| 2559 | + public function set_user_address( $value ) { |
|
| 2560 | + $this->set_address( $value ); |
|
| 2531 | 2561 | } |
| 2532 | 2562 | |
| 2533 | 2563 | /** |
| 2534 | - * Alias of self::set_vat_rate(). |
|
| 2535 | - * |
|
| 2536 | - * @since 1.0.19 |
|
| 2537 | - * @param string $value var number. |
|
| 2538 | - */ |
|
| 2539 | - public function set_customer_vat_rate( $value ) { |
|
| 2540 | - $this->set_vat_rate( $value ); |
|
| 2564 | + * Alias of self::set_address(). |
|
| 2565 | + * |
|
| 2566 | + * @since 1.0.19 |
|
| 2567 | + * @param string $value address. |
|
| 2568 | + */ |
|
| 2569 | + public function set_customer_address( $value ) { |
|
| 2570 | + $this->set_address( $value ); |
|
| 2541 | 2571 | } |
| 2542 | 2572 | |
| 2543 | 2573 | /** |
| 2544 | - * Set the customer's address. |
|
| 2545 | - * |
|
| 2546 | - * @since 1.0.19 |
|
| 2547 | - * @param string $value address. |
|
| 2548 | - */ |
|
| 2549 | - public function set_address( $value ) { |
|
| 2550 | - $this->set_prop( 'address', $value ); |
|
| 2574 | + * Set whether the customer has viewed the invoice or not. |
|
| 2575 | + * |
|
| 2576 | + * @since 1.0.19 |
|
| 2577 | + * @param int|bool $value confirmed. |
|
| 2578 | + */ |
|
| 2579 | + public function set_is_viewed( $value ) { |
|
| 2580 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2551 | 2581 | } |
| 2552 | 2582 | |
| 2553 | 2583 | /** |
| 2554 | - * Alias of self::set_address(). |
|
| 2555 | - * |
|
| 2556 | - * @since 1.0.19 |
|
| 2557 | - * @param string $value address. |
|
| 2558 | - */ |
|
| 2559 | - public function set_user_address( $value ) { |
|
| 2560 | - $this->set_address( $value ); |
|
| 2584 | + * Set extra email recipients. |
|
| 2585 | + * |
|
| 2586 | + * @since 1.0.19 |
|
| 2587 | + * @param string $value email recipients. |
|
| 2588 | + */ |
|
| 2589 | + public function set_email_cc( $value ) { |
|
| 2590 | + $this->set_prop( 'email_cc', $value ); |
|
| 2561 | 2591 | } |
| 2562 | 2592 | |
| 2563 | 2593 | /** |
| 2564 | - * Alias of self::set_address(). |
|
| 2565 | - * |
|
| 2566 | - * @since 1.0.19 |
|
| 2567 | - * @param string $value address. |
|
| 2568 | - */ |
|
| 2569 | - public function set_customer_address( $value ) { |
|
| 2570 | - $this->set_address( $value ); |
|
| 2594 | + * Set the invoice template. |
|
| 2595 | + * |
|
| 2596 | + * @since 1.0.19 |
|
| 2597 | + * @param string $value email recipients. |
|
| 2598 | + */ |
|
| 2599 | + public function set_template( $value ) { |
|
| 2600 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2601 | + $this->set_prop( 'template', $value ); |
|
| 2602 | + } |
|
| 2571 | 2603 | } |
| 2572 | 2604 | |
| 2573 | 2605 | /** |
| 2574 | - * Set whether the customer has viewed the invoice or not. |
|
| 2575 | - * |
|
| 2576 | - * @since 1.0.19 |
|
| 2577 | - * @param int|bool $value confirmed. |
|
| 2578 | - */ |
|
| 2579 | - public function set_is_viewed( $value ) { |
|
| 2580 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2581 | - } |
|
| 2582 | - |
|
| 2583 | - /** |
|
| 2584 | - * Set extra email recipients. |
|
| 2585 | - * |
|
| 2586 | - * @since 1.0.19 |
|
| 2587 | - * @param string $value email recipients. |
|
| 2588 | - */ |
|
| 2589 | - public function set_email_cc( $value ) { |
|
| 2590 | - $this->set_prop( 'email_cc', $value ); |
|
| 2591 | - } |
|
| 2592 | - |
|
| 2593 | - /** |
|
| 2594 | - * Set the invoice template. |
|
| 2595 | - * |
|
| 2596 | - * @since 1.0.19 |
|
| 2597 | - * @param string $value email recipients. |
|
| 2598 | - */ |
|
| 2599 | - public function set_template( $value ) { |
|
| 2600 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2601 | - $this->set_prop( 'template', $value ); |
|
| 2602 | - } |
|
| 2603 | - } |
|
| 2604 | - |
|
| 2605 | - /** |
|
| 2606 | - * Set the customer's address confirmed status. |
|
| 2607 | - * |
|
| 2608 | - * @since 1.0.19 |
|
| 2609 | - * @param int|bool $value confirmed. |
|
| 2610 | - */ |
|
| 2611 | - public function set_address_confirmed( $value ) { |
|
| 2612 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2606 | + * Set the customer's address confirmed status. |
|
| 2607 | + * |
|
| 2608 | + * @since 1.0.19 |
|
| 2609 | + * @param int|bool $value confirmed. |
|
| 2610 | + */ |
|
| 2611 | + public function set_address_confirmed( $value ) { |
|
| 2612 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | |
| 2615 | 2615 | /** |
| 2616 | - * Alias of self::set_address_confirmed(). |
|
| 2617 | - * |
|
| 2618 | - * @since 1.0.19 |
|
| 2619 | - * @param int|bool $value confirmed. |
|
| 2620 | - */ |
|
| 2621 | - public function set_user_address_confirmed( $value ) { |
|
| 2622 | - $this->set_address_confirmed( $value ); |
|
| 2616 | + * Alias of self::set_address_confirmed(). |
|
| 2617 | + * |
|
| 2618 | + * @since 1.0.19 |
|
| 2619 | + * @param int|bool $value confirmed. |
|
| 2620 | + */ |
|
| 2621 | + public function set_user_address_confirmed( $value ) { |
|
| 2622 | + $this->set_address_confirmed( $value ); |
|
| 2623 | 2623 | } |
| 2624 | 2624 | |
| 2625 | 2625 | /** |
| 2626 | - * Alias of self::set_address_confirmed(). |
|
| 2627 | - * |
|
| 2628 | - * @since 1.0.19 |
|
| 2629 | - * @param int|bool $value confirmed. |
|
| 2630 | - */ |
|
| 2631 | - public function set_customer_address_confirmed( $value ) { |
|
| 2632 | - $this->set_address_confirmed( $value ); |
|
| 2626 | + * Alias of self::set_address_confirmed(). |
|
| 2627 | + * |
|
| 2628 | + * @since 1.0.19 |
|
| 2629 | + * @param int|bool $value confirmed. |
|
| 2630 | + */ |
|
| 2631 | + public function set_customer_address_confirmed( $value ) { |
|
| 2632 | + $this->set_address_confirmed( $value ); |
|
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | /** |
| 2636 | - * Set the invoice sub total. |
|
| 2637 | - * |
|
| 2638 | - * @since 1.0.19 |
|
| 2639 | - * @param float $value sub total. |
|
| 2640 | - */ |
|
| 2641 | - public function set_subtotal( $value ) { |
|
| 2642 | - $this->set_prop( 'subtotal', $value ); |
|
| 2636 | + * Set the invoice sub total. |
|
| 2637 | + * |
|
| 2638 | + * @since 1.0.19 |
|
| 2639 | + * @param float $value sub total. |
|
| 2640 | + */ |
|
| 2641 | + public function set_subtotal( $value ) { |
|
| 2642 | + $this->set_prop( 'subtotal', $value ); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | /** |
| 2646 | - * Set the invoice discount amount. |
|
| 2647 | - * |
|
| 2648 | - * @since 1.0.19 |
|
| 2649 | - * @param float $value discount total. |
|
| 2650 | - */ |
|
| 2651 | - public function set_total_discount( $value ) { |
|
| 2652 | - $this->set_prop( 'total_discount', $value ); |
|
| 2646 | + * Set the invoice discount amount. |
|
| 2647 | + * |
|
| 2648 | + * @since 1.0.19 |
|
| 2649 | + * @param float $value discount total. |
|
| 2650 | + */ |
|
| 2651 | + public function set_total_discount( $value ) { |
|
| 2652 | + $this->set_prop( 'total_discount', $value ); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | |
| 2655 | 2655 | /** |
| 2656 | - * Alias of self::set_total_discount(). |
|
| 2657 | - * |
|
| 2658 | - * @since 1.0.19 |
|
| 2659 | - * @param float $value discount total. |
|
| 2660 | - */ |
|
| 2661 | - public function set_discount( $value ) { |
|
| 2662 | - $this->set_total_discount( $value ); |
|
| 2656 | + * Alias of self::set_total_discount(). |
|
| 2657 | + * |
|
| 2658 | + * @since 1.0.19 |
|
| 2659 | + * @param float $value discount total. |
|
| 2660 | + */ |
|
| 2661 | + public function set_discount( $value ) { |
|
| 2662 | + $this->set_total_discount( $value ); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
| 2666 | - * Set the invoice tax amount. |
|
| 2667 | - * |
|
| 2668 | - * @since 1.0.19 |
|
| 2669 | - * @param float $value tax total. |
|
| 2670 | - */ |
|
| 2671 | - public function set_total_tax( $value ) { |
|
| 2672 | - $this->set_prop( 'total_tax', $value ); |
|
| 2666 | + * Set the invoice tax amount. |
|
| 2667 | + * |
|
| 2668 | + * @since 1.0.19 |
|
| 2669 | + * @param float $value tax total. |
|
| 2670 | + */ |
|
| 2671 | + public function set_total_tax( $value ) { |
|
| 2672 | + $this->set_prop( 'total_tax', $value ); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
| 2676 | - * Alias of self::set_total_tax(). |
|
| 2677 | - * |
|
| 2678 | - * @since 1.0.19 |
|
| 2679 | - * @param float $value tax total. |
|
| 2680 | - */ |
|
| 2681 | - public function set_tax_total( $value ) { |
|
| 2682 | - $this->set_total_tax( $value ); |
|
| 2676 | + * Alias of self::set_total_tax(). |
|
| 2677 | + * |
|
| 2678 | + * @since 1.0.19 |
|
| 2679 | + * @param float $value tax total. |
|
| 2680 | + */ |
|
| 2681 | + public function set_tax_total( $value ) { |
|
| 2682 | + $this->set_total_tax( $value ); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
| 2686 | - * Set the invoice fees amount. |
|
| 2687 | - * |
|
| 2688 | - * @since 1.0.19 |
|
| 2689 | - * @param float $value fees total. |
|
| 2690 | - */ |
|
| 2691 | - public function set_total_fees( $value ) { |
|
| 2692 | - $this->set_prop( 'total_fees', $value ); |
|
| 2686 | + * Set the invoice fees amount. |
|
| 2687 | + * |
|
| 2688 | + * @since 1.0.19 |
|
| 2689 | + * @param float $value fees total. |
|
| 2690 | + */ |
|
| 2691 | + public function set_total_fees( $value ) { |
|
| 2692 | + $this->set_prop( 'total_fees', $value ); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
| 2696 | - * Alias of self::set_total_fees(). |
|
| 2697 | - * |
|
| 2698 | - * @since 1.0.19 |
|
| 2699 | - * @param float $value fees total. |
|
| 2700 | - */ |
|
| 2701 | - public function set_fees_total( $value ) { |
|
| 2702 | - $this->set_total_fees( $value ); |
|
| 2696 | + * Alias of self::set_total_fees(). |
|
| 2697 | + * |
|
| 2698 | + * @since 1.0.19 |
|
| 2699 | + * @param float $value fees total. |
|
| 2700 | + */ |
|
| 2701 | + public function set_fees_total( $value ) { |
|
| 2702 | + $this->set_total_fees( $value ); |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
| 2706 | - * Set the invoice fees. |
|
| 2707 | - * |
|
| 2708 | - * @since 1.0.19 |
|
| 2709 | - * @param array $value fees. |
|
| 2710 | - */ |
|
| 2711 | - public function set_fees( $value ) { |
|
| 2706 | + * Set the invoice fees. |
|
| 2707 | + * |
|
| 2708 | + * @since 1.0.19 |
|
| 2709 | + * @param array $value fees. |
|
| 2710 | + */ |
|
| 2711 | + public function set_fees( $value ) { |
|
| 2712 | 2712 | |
| 2713 | 2713 | $this->set_prop( 'fees', array() ); |
| 2714 | 2714 | |
@@ -2726,23 +2726,23 @@ discard block |
||
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | 2728 | /** |
| 2729 | - * Set the invoice taxes. |
|
| 2730 | - * |
|
| 2731 | - * @since 1.0.19 |
|
| 2732 | - * @param array $value taxes. |
|
| 2733 | - */ |
|
| 2734 | - public function set_taxes( $value ) { |
|
| 2735 | - $this->set_prop( 'taxes', $value ); |
|
| 2729 | + * Set the invoice taxes. |
|
| 2730 | + * |
|
| 2731 | + * @since 1.0.19 |
|
| 2732 | + * @param array $value taxes. |
|
| 2733 | + */ |
|
| 2734 | + public function set_taxes( $value ) { |
|
| 2735 | + $this->set_prop( 'taxes', $value ); |
|
| 2736 | 2736 | } |
| 2737 | 2737 | |
| 2738 | 2738 | /** |
| 2739 | - * Set the invoice discounts. |
|
| 2740 | - * |
|
| 2741 | - * @since 1.0.19 |
|
| 2742 | - * @param array $value discounts. |
|
| 2743 | - */ |
|
| 2744 | - public function set_discounts( $value ) { |
|
| 2745 | - $this->set_prop( 'discounts', array() ); |
|
| 2739 | + * Set the invoice discounts. |
|
| 2740 | + * |
|
| 2741 | + * @since 1.0.19 |
|
| 2742 | + * @param array $value discounts. |
|
| 2743 | + */ |
|
| 2744 | + public function set_discounts( $value ) { |
|
| 2745 | + $this->set_prop( 'discounts', array() ); |
|
| 2746 | 2746 | |
| 2747 | 2747 | // Ensure that we have an array. |
| 2748 | 2748 | if ( ! is_array( $value ) ) { |
@@ -2757,12 +2757,12 @@ discard block |
||
| 2757 | 2757 | } |
| 2758 | 2758 | |
| 2759 | 2759 | /** |
| 2760 | - * Set the invoice items. |
|
| 2761 | - * |
|
| 2762 | - * @since 1.0.19 |
|
| 2763 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2764 | - */ |
|
| 2765 | - public function set_items( $value ) { |
|
| 2760 | + * Set the invoice items. |
|
| 2761 | + * |
|
| 2762 | + * @since 1.0.19 |
|
| 2763 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2764 | + */ |
|
| 2765 | + public function set_items( $value ) { |
|
| 2766 | 2766 | |
| 2767 | 2767 | // Remove existing items. |
| 2768 | 2768 | $this->set_prop( 'items', array() ); |
@@ -2779,85 +2779,85 @@ discard block |
||
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | 2781 | /** |
| 2782 | - * Set the payment form. |
|
| 2783 | - * |
|
| 2784 | - * @since 1.0.19 |
|
| 2785 | - * @param int $value payment form. |
|
| 2786 | - */ |
|
| 2787 | - public function set_payment_form( $value ) { |
|
| 2788 | - $this->set_prop( 'payment_form', $value ); |
|
| 2782 | + * Set the payment form. |
|
| 2783 | + * |
|
| 2784 | + * @since 1.0.19 |
|
| 2785 | + * @param int $value payment form. |
|
| 2786 | + */ |
|
| 2787 | + public function set_payment_form( $value ) { |
|
| 2788 | + $this->set_prop( 'payment_form', $value ); |
|
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | /** |
| 2792 | - * Set the submission id. |
|
| 2793 | - * |
|
| 2794 | - * @since 1.0.19 |
|
| 2795 | - * @param string $value submission id. |
|
| 2796 | - */ |
|
| 2797 | - public function set_submission_id( $value ) { |
|
| 2798 | - $this->set_prop( 'submission_id', $value ); |
|
| 2792 | + * Set the submission id. |
|
| 2793 | + * |
|
| 2794 | + * @since 1.0.19 |
|
| 2795 | + * @param string $value submission id. |
|
| 2796 | + */ |
|
| 2797 | + public function set_submission_id( $value ) { |
|
| 2798 | + $this->set_prop( 'submission_id', $value ); |
|
| 2799 | 2799 | } |
| 2800 | 2800 | |
| 2801 | 2801 | /** |
| 2802 | - * Set the discount code. |
|
| 2803 | - * |
|
| 2804 | - * @since 1.0.19 |
|
| 2805 | - * @param string $value discount code. |
|
| 2806 | - */ |
|
| 2807 | - public function set_discount_code( $value ) { |
|
| 2808 | - $this->set_prop( 'discount_code', $value ); |
|
| 2802 | + * Set the discount code. |
|
| 2803 | + * |
|
| 2804 | + * @since 1.0.19 |
|
| 2805 | + * @param string $value discount code. |
|
| 2806 | + */ |
|
| 2807 | + public function set_discount_code( $value ) { |
|
| 2808 | + $this->set_prop( 'discount_code', $value ); |
|
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | 2811 | /** |
| 2812 | - * Set the gateway. |
|
| 2813 | - * |
|
| 2814 | - * @since 1.0.19 |
|
| 2815 | - * @param string $value gateway. |
|
| 2816 | - */ |
|
| 2817 | - public function set_gateway( $value ) { |
|
| 2818 | - $this->set_prop( 'gateway', $value ); |
|
| 2812 | + * Set the gateway. |
|
| 2813 | + * |
|
| 2814 | + * @since 1.0.19 |
|
| 2815 | + * @param string $value gateway. |
|
| 2816 | + */ |
|
| 2817 | + public function set_gateway( $value ) { |
|
| 2818 | + $this->set_prop( 'gateway', $value ); |
|
| 2819 | 2819 | } |
| 2820 | 2820 | |
| 2821 | 2821 | /** |
| 2822 | - * Set the transaction id. |
|
| 2823 | - * |
|
| 2824 | - * @since 1.0.19 |
|
| 2825 | - * @param string $value transaction id. |
|
| 2826 | - */ |
|
| 2827 | - public function set_transaction_id( $value ) { |
|
| 2828 | - if ( ! empty( $value ) ) { |
|
| 2829 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2830 | - } |
|
| 2822 | + * Set the transaction id. |
|
| 2823 | + * |
|
| 2824 | + * @since 1.0.19 |
|
| 2825 | + * @param string $value transaction id. |
|
| 2826 | + */ |
|
| 2827 | + public function set_transaction_id( $value ) { |
|
| 2828 | + if ( ! empty( $value ) ) { |
|
| 2829 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2830 | + } |
|
| 2831 | 2831 | } |
| 2832 | 2832 | |
| 2833 | 2833 | /** |
| 2834 | - * Set the currency id. |
|
| 2835 | - * |
|
| 2836 | - * @since 1.0.19 |
|
| 2837 | - * @param string $value currency id. |
|
| 2838 | - */ |
|
| 2839 | - public function set_currency( $value ) { |
|
| 2840 | - $this->set_prop( 'currency', $value ); |
|
| 2834 | + * Set the currency id. |
|
| 2835 | + * |
|
| 2836 | + * @since 1.0.19 |
|
| 2837 | + * @param string $value currency id. |
|
| 2838 | + */ |
|
| 2839 | + public function set_currency( $value ) { |
|
| 2840 | + $this->set_prop( 'currency', $value ); |
|
| 2841 | 2841 | } |
| 2842 | 2842 | |
| 2843 | - /** |
|
| 2844 | - * Set whether to disable taxes. |
|
| 2845 | - * |
|
| 2846 | - * @since 1.0.19 |
|
| 2847 | - * @param bool $value value. |
|
| 2848 | - */ |
|
| 2849 | - public function set_disable_taxes( $value ) { |
|
| 2850 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2851 | - } |
|
| 2843 | + /** |
|
| 2844 | + * Set whether to disable taxes. |
|
| 2845 | + * |
|
| 2846 | + * @since 1.0.19 |
|
| 2847 | + * @param bool $value value. |
|
| 2848 | + */ |
|
| 2849 | + public function set_disable_taxes( $value ) { |
|
| 2850 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2851 | + } |
|
| 2852 | 2852 | |
| 2853 | 2853 | /** |
| 2854 | - * Set the subscription id. |
|
| 2855 | - * |
|
| 2856 | - * @since 1.0.19 |
|
| 2857 | - * @param string $value subscription id. |
|
| 2858 | - */ |
|
| 2859 | - public function set_subscription_id( $value ) { |
|
| 2860 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2854 | + * Set the subscription id. |
|
| 2855 | + * |
|
| 2856 | + * @since 1.0.19 |
|
| 2857 | + * @param string $value subscription id. |
|
| 2858 | + */ |
|
| 2859 | + public function set_subscription_id( $value ) { |
|
| 2860 | + $this->set_prop( 'subscription_id', $value ); |
|
| 2861 | 2861 | } |
| 2862 | 2862 | |
| 2863 | 2863 | /* |
@@ -2896,12 +2896,12 @@ discard block |
||
| 2896 | 2896 | */ |
| 2897 | 2897 | public function is_taxable() { |
| 2898 | 2898 | return ! $this->get_disable_taxes(); |
| 2899 | - } |
|
| 2899 | + } |
|
| 2900 | 2900 | |
| 2901 | - /** |
|
| 2902 | - * @deprecated |
|
| 2903 | - */ |
|
| 2904 | - public function has_vat() { |
|
| 2901 | + /** |
|
| 2902 | + * @deprecated |
|
| 2903 | + */ |
|
| 2904 | + public function has_vat() { |
|
| 2905 | 2905 | global $wpinv_euvat, $wpi_country; |
| 2906 | 2906 | |
| 2907 | 2907 | $requires_vat = false; |
@@ -2912,17 +2912,17 @@ discard block |
||
| 2912 | 2912 | } |
| 2913 | 2913 | |
| 2914 | 2914 | return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
| 2915 | - } |
|
| 2915 | + } |
|
| 2916 | 2916 | |
| 2917 | - /** |
|
| 2918 | - * Checks to see if the invoice requires payment. |
|
| 2919 | - */ |
|
| 2920 | - public function is_free() { |
|
| 2917 | + /** |
|
| 2918 | + * Checks to see if the invoice requires payment. |
|
| 2919 | + */ |
|
| 2920 | + public function is_free() { |
|
| 2921 | 2921 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 2922 | 2922 | |
| 2923 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2924 | - $is_free = false; |
|
| 2925 | - } |
|
| 2923 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2924 | + $is_free = false; |
|
| 2925 | + } |
|
| 2926 | 2926 | |
| 2927 | 2927 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 2928 | 2928 | } |
@@ -2933,46 +2933,46 @@ discard block |
||
| 2933 | 2933 | public function is_paid() { |
| 2934 | 2934 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 2935 | 2935 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 2936 | - } |
|
| 2936 | + } |
|
| 2937 | 2937 | |
| 2938 | - /** |
|
| 2938 | + /** |
|
| 2939 | 2939 | * Checks if the invoice needs payment. |
| 2940 | 2940 | */ |
| 2941 | - public function needs_payment() { |
|
| 2942 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2941 | + public function needs_payment() { |
|
| 2942 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2943 | 2943 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | - /** |
|
| 2946 | + /** |
|
| 2947 | 2947 | * Checks if the invoice is refunded. |
| 2948 | 2948 | */ |
| 2949 | - public function is_refunded() { |
|
| 2949 | + public function is_refunded() { |
|
| 2950 | 2950 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 2951 | 2951 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 2952 | - } |
|
| 2952 | + } |
|
| 2953 | 2953 | |
| 2954 | - /** |
|
| 2954 | + /** |
|
| 2955 | 2955 | * Checks if the invoice is held. |
| 2956 | 2956 | */ |
| 2957 | - public function is_held() { |
|
| 2957 | + public function is_held() { |
|
| 2958 | 2958 | $is_held = $this->has_status( 'wpi-onhold' ); |
| 2959 | 2959 | return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
| 2960 | - } |
|
| 2960 | + } |
|
| 2961 | 2961 | |
| 2962 | - /** |
|
| 2962 | + /** |
|
| 2963 | 2963 | * Checks if the invoice is due. |
| 2964 | 2964 | */ |
| 2965 | - public function is_due() { |
|
| 2966 | - $due_date = $this->get_due_date(); |
|
| 2967 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 2968 | - } |
|
| 2965 | + public function is_due() { |
|
| 2966 | + $due_date = $this->get_due_date(); |
|
| 2967 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 2968 | + } |
|
| 2969 | 2969 | |
| 2970 | - /** |
|
| 2970 | + /** |
|
| 2971 | 2971 | * Checks if the invoice is draft. |
| 2972 | 2972 | */ |
| 2973 | - public function is_draft() { |
|
| 2973 | + public function is_draft() { |
|
| 2974 | 2974 | return $this->has_status( 'draft, auto-draft' ); |
| 2975 | - } |
|
| 2975 | + } |
|
| 2976 | 2976 | |
| 2977 | 2977 | /** |
| 2978 | 2978 | * Checks if the invoice has a given status. |
@@ -2980,9 +2980,9 @@ discard block |
||
| 2980 | 2980 | public function has_status( $status ) { |
| 2981 | 2981 | $status = wpinv_parse_list( $status ); |
| 2982 | 2982 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 2983 | - } |
|
| 2983 | + } |
|
| 2984 | 2984 | |
| 2985 | - /** |
|
| 2985 | + /** |
|
| 2986 | 2986 | * Checks if the invoice is of a given type. |
| 2987 | 2987 | */ |
| 2988 | 2988 | public function is_type( $type ) { |
@@ -3005,25 +3005,25 @@ discard block |
||
| 3005 | 3005 | */ |
| 3006 | 3006 | public function has_free_trial() { |
| 3007 | 3007 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 3008 | - } |
|
| 3008 | + } |
|
| 3009 | 3009 | |
| 3010 | - /** |
|
| 3010 | + /** |
|
| 3011 | 3011 | * @deprecated |
| 3012 | 3012 | */ |
| 3013 | 3013 | public function is_free_trial() { |
| 3014 | 3014 | $this->has_free_trial(); |
| 3015 | 3015 | } |
| 3016 | 3016 | |
| 3017 | - /** |
|
| 3017 | + /** |
|
| 3018 | 3018 | * Check if the initial payment if 0. |
| 3019 | 3019 | * |
| 3020 | 3020 | */ |
| 3021 | - public function is_initial_free() { |
|
| 3021 | + public function is_initial_free() { |
|
| 3022 | 3022 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3023 | 3023 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3024 | 3024 | } |
| 3025 | 3025 | |
| 3026 | - /** |
|
| 3026 | + /** |
|
| 3027 | 3027 | * Check if the recurring item has a free trial. |
| 3028 | 3028 | * |
| 3029 | 3029 | */ |
@@ -3036,21 +3036,21 @@ discard block |
||
| 3036 | 3036 | |
| 3037 | 3037 | $item = $this->get_recurring( true ); |
| 3038 | 3038 | return $item->has_free_trial(); |
| 3039 | - } |
|
| 3039 | + } |
|
| 3040 | 3040 | |
| 3041 | - /** |
|
| 3041 | + /** |
|
| 3042 | 3042 | * Check if the free trial is a result of a discount. |
| 3043 | 3043 | */ |
| 3044 | 3044 | public function is_free_trial_from_discount() { |
| 3045 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3046 | - } |
|
| 3045 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3046 | + } |
|
| 3047 | 3047 | |
| 3048 | - /** |
|
| 3048 | + /** |
|
| 3049 | 3049 | * @deprecated |
| 3050 | 3050 | */ |
| 3051 | 3051 | public function discount_first_payment_only() { |
| 3052 | 3052 | |
| 3053 | - $discount_code = $this->get_discount_code(); |
|
| 3053 | + $discount_code = $this->get_discount_code(); |
|
| 3054 | 3054 | if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
| 3055 | 3055 | return true; |
| 3056 | 3056 | } |
@@ -3081,28 +3081,28 @@ discard block |
||
| 3081 | 3081 | */ |
| 3082 | 3082 | public function add_item( $item ) { |
| 3083 | 3083 | |
| 3084 | - if ( is_array( $item ) ) { |
|
| 3085 | - $item = $this->process_array_item( $item ); |
|
| 3086 | - } |
|
| 3084 | + if ( is_array( $item ) ) { |
|
| 3085 | + $item = $this->process_array_item( $item ); |
|
| 3086 | + } |
|
| 3087 | 3087 | |
| 3088 | - if ( is_numeric( $item ) ) { |
|
| 3089 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3090 | - } |
|
| 3088 | + if ( is_numeric( $item ) ) { |
|
| 3089 | + $item = new GetPaid_Form_Item( $item ); |
|
| 3090 | + } |
|
| 3091 | 3091 | |
| 3092 | 3092 | // Make sure that it is available for purchase. |
| 3093 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3094 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3093 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3094 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3095 | 3095 | } |
| 3096 | 3096 | |
| 3097 | 3097 | // Do we have a recurring item? |
| 3098 | - if ( $item->is_recurring() ) { |
|
| 3098 | + if ( $item->is_recurring() ) { |
|
| 3099 | 3099 | |
| 3100 | - // An invoice can only contain one recurring item. |
|
| 3101 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3102 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3103 | - } |
|
| 3100 | + // An invoice can only contain one recurring item. |
|
| 3101 | + if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3102 | + return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3103 | + } |
|
| 3104 | 3104 | |
| 3105 | - $this->recurring_item = $item->get_id(); |
|
| 3105 | + $this->recurring_item = $item->get_id(); |
|
| 3106 | 3106 | } |
| 3107 | 3107 | |
| 3108 | 3108 | // Invoice id. |
@@ -3113,60 +3113,60 @@ discard block |
||
| 3113 | 3113 | $items[ (int) $item->get_id() ] = $item; |
| 3114 | 3114 | |
| 3115 | 3115 | $this->set_prop( 'items', $items ); |
| 3116 | - return true; |
|
| 3117 | - } |
|
| 3116 | + return true; |
|
| 3117 | + } |
|
| 3118 | 3118 | |
| 3119 | - /** |
|
| 3120 | - * Converts an array to an item. |
|
| 3121 | - * |
|
| 3122 | - * @since 1.0.19 |
|
| 3123 | - * @return GetPaid_Form_Item |
|
| 3124 | - */ |
|
| 3125 | - protected function process_array_item( $array ) { |
|
| 3126 | - |
|
| 3127 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3128 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3129 | - |
|
| 3130 | - // Set item data. |
|
| 3131 | - foreach( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3132 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3133 | - $method = "set_$key"; |
|
| 3134 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3135 | - } |
|
| 3136 | - } |
|
| 3137 | - |
|
| 3138 | - if ( isset( $array['quantity'] ) ) { |
|
| 3139 | - $item->set_quantity( $array['quantity'] ); |
|
| 3140 | - } |
|
| 3141 | - |
|
| 3142 | - // Set item meta. |
|
| 3143 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3144 | - $item->set_item_meta( $array['meta'] ); |
|
| 3145 | - } |
|
| 3146 | - |
|
| 3147 | - return $item; |
|
| 3148 | - |
|
| 3149 | - } |
|
| 3150 | - |
|
| 3151 | - /** |
|
| 3152 | - * Retrieves a specific item. |
|
| 3153 | - * |
|
| 3154 | - * @since 1.0.19 |
|
| 3155 | - */ |
|
| 3156 | - public function get_item( $item_id ) { |
|
| 3157 | - $items = $this->get_items(); |
|
| 3158 | - $item_id = (int) $item_id; |
|
| 3159 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3160 | - } |
|
| 3161 | - |
|
| 3162 | - /** |
|
| 3163 | - * Removes a specific item. |
|
| 3164 | - * |
|
| 3165 | - * @since 1.0.19 |
|
| 3166 | - */ |
|
| 3167 | - public function remove_item( $item_id ) { |
|
| 3168 | - $items = $this->get_items(); |
|
| 3169 | - $item_id = (int) $item_id; |
|
| 3119 | + /** |
|
| 3120 | + * Converts an array to an item. |
|
| 3121 | + * |
|
| 3122 | + * @since 1.0.19 |
|
| 3123 | + * @return GetPaid_Form_Item |
|
| 3124 | + */ |
|
| 3125 | + protected function process_array_item( $array ) { |
|
| 3126 | + |
|
| 3127 | + $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3128 | + $item = new GetPaid_Form_Item( $item_id ); |
|
| 3129 | + |
|
| 3130 | + // Set item data. |
|
| 3131 | + foreach( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3132 | + if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3133 | + $method = "set_$key"; |
|
| 3134 | + $item->$method( $array[ "item_$key" ] ); |
|
| 3135 | + } |
|
| 3136 | + } |
|
| 3137 | + |
|
| 3138 | + if ( isset( $array['quantity'] ) ) { |
|
| 3139 | + $item->set_quantity( $array['quantity'] ); |
|
| 3140 | + } |
|
| 3141 | + |
|
| 3142 | + // Set item meta. |
|
| 3143 | + if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3144 | + $item->set_item_meta( $array['meta'] ); |
|
| 3145 | + } |
|
| 3146 | + |
|
| 3147 | + return $item; |
|
| 3148 | + |
|
| 3149 | + } |
|
| 3150 | + |
|
| 3151 | + /** |
|
| 3152 | + * Retrieves a specific item. |
|
| 3153 | + * |
|
| 3154 | + * @since 1.0.19 |
|
| 3155 | + */ |
|
| 3156 | + public function get_item( $item_id ) { |
|
| 3157 | + $items = $this->get_items(); |
|
| 3158 | + $item_id = (int) $item_id; |
|
| 3159 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3160 | + } |
|
| 3161 | + |
|
| 3162 | + /** |
|
| 3163 | + * Removes a specific item. |
|
| 3164 | + * |
|
| 3165 | + * @since 1.0.19 |
|
| 3166 | + */ |
|
| 3167 | + public function remove_item( $item_id ) { |
|
| 3168 | + $items = $this->get_items(); |
|
| 3169 | + $item_id = (int) $item_id; |
|
| 3170 | 3170 | |
| 3171 | 3171 | if ( $item_id == $this->recurring_item ) { |
| 3172 | 3172 | $this->recurring_item = null; |
@@ -3193,38 +3193,38 @@ discard block |
||
| 3193 | 3193 | if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
| 3194 | 3194 | |
| 3195 | 3195 | $amount = $fees[ $fee ]['amount'] += $amount; |
| 3196 | - $fees[ $fee ] = array( |
|
| 3197 | - 'amount' => $amount, |
|
| 3196 | + $fees[ $fee ] = array( |
|
| 3197 | + 'amount' => $amount, |
|
| 3198 | 3198 | 'recurring' => (bool) $recurring, |
| 3199 | 3199 | ); |
| 3200 | 3200 | |
| 3201 | - } else { |
|
| 3202 | - $fees[ $fee ] = array( |
|
| 3201 | + } else { |
|
| 3202 | + $fees[ $fee ] = array( |
|
| 3203 | 3203 | 'amount' => $amount, |
| 3204 | 3204 | 'recurring' => (bool) $recurring, |
| 3205 | 3205 | ); |
| 3206 | - } |
|
| 3206 | + } |
|
| 3207 | 3207 | |
| 3208 | 3208 | $this->set_prop( 'fees', $fee ); |
| 3209 | 3209 | |
| 3210 | 3210 | } |
| 3211 | 3211 | |
| 3212 | 3212 | /** |
| 3213 | - * Retrieves a specific fee. |
|
| 3214 | - * |
|
| 3215 | - * @since 1.0.19 |
|
| 3216 | - */ |
|
| 3217 | - public function get_fee( $fee ) { |
|
| 3213 | + * Retrieves a specific fee. |
|
| 3214 | + * |
|
| 3215 | + * @since 1.0.19 |
|
| 3216 | + */ |
|
| 3217 | + public function get_fee( $fee ) { |
|
| 3218 | 3218 | $fees = $this->get_fees(); |
| 3219 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3219 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3220 | 3220 | } |
| 3221 | 3221 | |
| 3222 | 3222 | /** |
| 3223 | - * Removes a specific fee. |
|
| 3224 | - * |
|
| 3225 | - * @since 1.0.19 |
|
| 3226 | - */ |
|
| 3227 | - public function remove_fee( $fee ) { |
|
| 3223 | + * Removes a specific fee. |
|
| 3224 | + * |
|
| 3225 | + * @since 1.0.19 |
|
| 3226 | + */ |
|
| 3227 | + public function remove_fee( $fee ) { |
|
| 3228 | 3228 | $fees = $this->get_fees(); |
| 3229 | 3229 | if ( isset( $fees[ $fee ] ) ) { |
| 3230 | 3230 | unset( $fees[ $fee ] ); |
@@ -3247,44 +3247,44 @@ discard block |
||
| 3247 | 3247 | if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
| 3248 | 3248 | |
| 3249 | 3249 | $amount = $discounts[ $discount ]['amount'] += $amount; |
| 3250 | - $discounts[ $discount ] = array( |
|
| 3250 | + $discounts[ $discount ] = array( |
|
| 3251 | 3251 | 'amount' => $amount, |
| 3252 | 3252 | 'recurring' => (bool) $recurring, |
| 3253 | 3253 | ); |
| 3254 | 3254 | |
| 3255 | - } else { |
|
| 3256 | - $discounts[ $discount ] = array( |
|
| 3255 | + } else { |
|
| 3256 | + $discounts[ $discount ] = array( |
|
| 3257 | 3257 | 'amount' => $amount, |
| 3258 | 3258 | 'recurring' => (bool) $recurring, |
| 3259 | 3259 | ); |
| 3260 | - } |
|
| 3260 | + } |
|
| 3261 | 3261 | |
| 3262 | 3262 | $this->set_prop( 'discounts', $discount ); |
| 3263 | 3263 | |
| 3264 | 3264 | } |
| 3265 | 3265 | |
| 3266 | 3266 | /** |
| 3267 | - * Retrieves a specific discount. |
|
| 3268 | - * |
|
| 3269 | - * @since 1.0.19 |
|
| 3270 | - */ |
|
| 3271 | - public function get_discount( $discount = false ) { |
|
| 3267 | + * Retrieves a specific discount. |
|
| 3268 | + * |
|
| 3269 | + * @since 1.0.19 |
|
| 3270 | + */ |
|
| 3271 | + public function get_discount( $discount = false ) { |
|
| 3272 | 3272 | |
| 3273 | - // Backwards compatibilty. |
|
| 3274 | - if ( empty( $discount ) ) { |
|
| 3275 | - return $this->get_total_discount(); |
|
| 3276 | - } |
|
| 3273 | + // Backwards compatibilty. |
|
| 3274 | + if ( empty( $discount ) ) { |
|
| 3275 | + return $this->get_total_discount(); |
|
| 3276 | + } |
|
| 3277 | 3277 | |
| 3278 | 3278 | $discounts = $this->get_discounts(); |
| 3279 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3279 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3280 | 3280 | } |
| 3281 | 3281 | |
| 3282 | 3282 | /** |
| 3283 | - * Removes a specific discount. |
|
| 3284 | - * |
|
| 3285 | - * @since 1.0.19 |
|
| 3286 | - */ |
|
| 3287 | - public function remove_discount( $discount ) { |
|
| 3283 | + * Removes a specific discount. |
|
| 3284 | + * |
|
| 3285 | + * @since 1.0.19 |
|
| 3286 | + */ |
|
| 3287 | + public function remove_discount( $discount ) { |
|
| 3288 | 3288 | $discounts = $this->get_discounts(); |
| 3289 | 3289 | if ( isset( $discounts[ $discount ] ) ) { |
| 3290 | 3290 | unset( $discounts[ $discount ] ); |
@@ -3310,44 +3310,44 @@ discard block |
||
| 3310 | 3310 | if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
| 3311 | 3311 | |
| 3312 | 3312 | $amount = $taxes[ $tax ]['amount'] += $amount; |
| 3313 | - $taxes[ $tax ] = array( |
|
| 3313 | + $taxes[ $tax ] = array( |
|
| 3314 | 3314 | 'amount' => $amount, |
| 3315 | 3315 | 'recurring' => (bool) $recurring, |
| 3316 | 3316 | ); |
| 3317 | 3317 | |
| 3318 | - } else { |
|
| 3319 | - $taxes[ $tax ] = array( |
|
| 3318 | + } else { |
|
| 3319 | + $taxes[ $tax ] = array( |
|
| 3320 | 3320 | 'amount' => $amount, |
| 3321 | 3321 | 'recurring' => (bool) $recurring, |
| 3322 | 3322 | ); |
| 3323 | - } |
|
| 3323 | + } |
|
| 3324 | 3324 | |
| 3325 | 3325 | $this->set_prop( 'taxes', $tax ); |
| 3326 | 3326 | |
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | 3329 | /** |
| 3330 | - * Retrieves a specific tax. |
|
| 3331 | - * |
|
| 3332 | - * @since 1.0.19 |
|
| 3333 | - */ |
|
| 3334 | - public function get_tax( $tax = null ) { |
|
| 3330 | + * Retrieves a specific tax. |
|
| 3331 | + * |
|
| 3332 | + * @since 1.0.19 |
|
| 3333 | + */ |
|
| 3334 | + public function get_tax( $tax = null ) { |
|
| 3335 | 3335 | |
| 3336 | - // Backwards compatility. |
|
| 3337 | - if ( empty( $tax ) ) { |
|
| 3338 | - return $this->get_total_tax(); |
|
| 3339 | - } |
|
| 3336 | + // Backwards compatility. |
|
| 3337 | + if ( empty( $tax ) ) { |
|
| 3338 | + return $this->get_total_tax(); |
|
| 3339 | + } |
|
| 3340 | 3340 | |
| 3341 | 3341 | $taxes = $this->get_taxes(); |
| 3342 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3342 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3343 | 3343 | } |
| 3344 | 3344 | |
| 3345 | 3345 | /** |
| 3346 | - * Removes a specific tax. |
|
| 3347 | - * |
|
| 3348 | - * @since 1.0.19 |
|
| 3349 | - */ |
|
| 3350 | - public function remove_tax( $tax ) { |
|
| 3346 | + * Removes a specific tax. |
|
| 3347 | + * |
|
| 3348 | + * @since 1.0.19 |
|
| 3349 | + */ |
|
| 3350 | + public function remove_tax( $tax ) { |
|
| 3351 | 3351 | $taxes = $this->get_discounts(); |
| 3352 | 3352 | if ( isset( $taxes[ $tax ] ) ) { |
| 3353 | 3353 | unset( $taxes[ $tax ] ); |
@@ -3356,160 +3356,160 @@ discard block |
||
| 3356 | 3356 | } |
| 3357 | 3357 | |
| 3358 | 3358 | /** |
| 3359 | - * Recalculates the invoice subtotal. |
|
| 3360 | - * |
|
| 3361 | - * @since 1.0.19 |
|
| 3362 | - * @return float The recalculated subtotal |
|
| 3363 | - */ |
|
| 3364 | - public function recalculate_subtotal() { |
|
| 3359 | + * Recalculates the invoice subtotal. |
|
| 3360 | + * |
|
| 3361 | + * @since 1.0.19 |
|
| 3362 | + * @return float The recalculated subtotal |
|
| 3363 | + */ |
|
| 3364 | + public function recalculate_subtotal() { |
|
| 3365 | 3365 | $items = $this->get_items(); |
| 3366 | - $subtotal = 0; |
|
| 3367 | - $recurring = 0; |
|
| 3366 | + $subtotal = 0; |
|
| 3367 | + $recurring = 0; |
|
| 3368 | 3368 | |
| 3369 | 3369 | foreach ( $items as $item ) { |
| 3370 | - $subtotal += $item->get_sub_total(); |
|
| 3371 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3370 | + $subtotal += $item->get_sub_total(); |
|
| 3371 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3372 | 3372 | } |
| 3373 | 3373 | |
| 3374 | - if ( $this->is_renewal() ) { |
|
| 3375 | - $this->set_subtotal( $recurring ); |
|
| 3376 | - } else { |
|
| 3377 | - $this->set_subtotal( $subtotal ); |
|
| 3378 | - } |
|
| 3374 | + if ( $this->is_renewal() ) { |
|
| 3375 | + $this->set_subtotal( $recurring ); |
|
| 3376 | + } else { |
|
| 3377 | + $this->set_subtotal( $subtotal ); |
|
| 3378 | + } |
|
| 3379 | 3379 | |
| 3380 | - $this->totals['subtotal'] = array( |
|
| 3381 | - 'initial' => $subtotal, |
|
| 3382 | - 'recurring' => $recurring, |
|
| 3383 | - ); |
|
| 3380 | + $this->totals['subtotal'] = array( |
|
| 3381 | + 'initial' => $subtotal, |
|
| 3382 | + 'recurring' => $recurring, |
|
| 3383 | + ); |
|
| 3384 | 3384 | |
| 3385 | 3385 | return $this->is_renewal() ? $recurring : $subtotal; |
| 3386 | 3386 | } |
| 3387 | 3387 | |
| 3388 | 3388 | /** |
| 3389 | - * Recalculates the invoice discount total. |
|
| 3390 | - * |
|
| 3391 | - * @since 1.0.19 |
|
| 3392 | - * @return float The recalculated discount |
|
| 3393 | - */ |
|
| 3394 | - public function recalculate_total_discount() { |
|
| 3389 | + * Recalculates the invoice discount total. |
|
| 3390 | + * |
|
| 3391 | + * @since 1.0.19 |
|
| 3392 | + * @return float The recalculated discount |
|
| 3393 | + */ |
|
| 3394 | + public function recalculate_total_discount() { |
|
| 3395 | 3395 | $discounts = $this->get_discounts(); |
| 3396 | - $discount = 0; |
|
| 3397 | - $recurring = 0; |
|
| 3396 | + $discount = 0; |
|
| 3397 | + $recurring = 0; |
|
| 3398 | 3398 | |
| 3399 | 3399 | foreach ( $discounts as $data ) { |
| 3400 | 3400 | |
| 3401 | - if ( $data['recurring'] ) { |
|
| 3402 | - $recurring += $data['amount']; |
|
| 3403 | - } else { |
|
| 3404 | - $discount += $data['amount']; |
|
| 3405 | - } |
|
| 3401 | + if ( $data['recurring'] ) { |
|
| 3402 | + $recurring += $data['amount']; |
|
| 3403 | + } else { |
|
| 3404 | + $discount += $data['amount']; |
|
| 3405 | + } |
|
| 3406 | 3406 | |
| 3407 | - } |
|
| 3407 | + } |
|
| 3408 | 3408 | |
| 3409 | - if ( $this->is_renewal() ) { |
|
| 3410 | - $this->set_total_discount( $recurring ); |
|
| 3411 | - } else { |
|
| 3412 | - $this->set_total_discount( $discount ); |
|
| 3413 | - } |
|
| 3409 | + if ( $this->is_renewal() ) { |
|
| 3410 | + $this->set_total_discount( $recurring ); |
|
| 3411 | + } else { |
|
| 3412 | + $this->set_total_discount( $discount ); |
|
| 3413 | + } |
|
| 3414 | 3414 | |
| 3415 | - $this->totals['discount'] = array( |
|
| 3416 | - 'initial' => $discount, |
|
| 3417 | - 'recurring' => $recurring, |
|
| 3418 | - ); |
|
| 3415 | + $this->totals['discount'] = array( |
|
| 3416 | + 'initial' => $discount, |
|
| 3417 | + 'recurring' => $recurring, |
|
| 3418 | + ); |
|
| 3419 | 3419 | |
| 3420 | - return $this->is_renewal() ? $recurring : $discount; |
|
| 3420 | + return $this->is_renewal() ? $recurring : $discount; |
|
| 3421 | 3421 | |
| 3422 | 3422 | } |
| 3423 | 3423 | |
| 3424 | 3424 | /** |
| 3425 | - * Recalculates the invoice tax total. |
|
| 3426 | - * |
|
| 3427 | - * @since 1.0.19 |
|
| 3428 | - * @return float The recalculated tax |
|
| 3429 | - */ |
|
| 3430 | - public function recalculate_total_tax() { |
|
| 3425 | + * Recalculates the invoice tax total. |
|
| 3426 | + * |
|
| 3427 | + * @since 1.0.19 |
|
| 3428 | + * @return float The recalculated tax |
|
| 3429 | + */ |
|
| 3430 | + public function recalculate_total_tax() { |
|
| 3431 | 3431 | $taxes = $this->get_taxes(); |
| 3432 | - $tax = 0; |
|
| 3433 | - $recurring = 0; |
|
| 3432 | + $tax = 0; |
|
| 3433 | + $recurring = 0; |
|
| 3434 | 3434 | |
| 3435 | 3435 | foreach ( $taxes as $data ) { |
| 3436 | 3436 | |
| 3437 | - if ( $data['recurring'] ) { |
|
| 3438 | - $recurring += $data['amount']; |
|
| 3439 | - } else { |
|
| 3440 | - $tax += $data['amount']; |
|
| 3441 | - } |
|
| 3437 | + if ( $data['recurring'] ) { |
|
| 3438 | + $recurring += $data['amount']; |
|
| 3439 | + } else { |
|
| 3440 | + $tax += $data['amount']; |
|
| 3441 | + } |
|
| 3442 | 3442 | |
| 3443 | - } |
|
| 3443 | + } |
|
| 3444 | 3444 | |
| 3445 | - if ( $this->is_renewal() ) { |
|
| 3446 | - $this->set_total_tax( $recurring ); |
|
| 3447 | - } else { |
|
| 3448 | - $this->set_total_tax( $tax ); |
|
| 3449 | - } |
|
| 3445 | + if ( $this->is_renewal() ) { |
|
| 3446 | + $this->set_total_tax( $recurring ); |
|
| 3447 | + } else { |
|
| 3448 | + $this->set_total_tax( $tax ); |
|
| 3449 | + } |
|
| 3450 | 3450 | |
| 3451 | - $this->totals['tax'] = array( |
|
| 3452 | - 'initial' => $tax, |
|
| 3453 | - 'recurring' => $recurring, |
|
| 3454 | - ); |
|
| 3451 | + $this->totals['tax'] = array( |
|
| 3452 | + 'initial' => $tax, |
|
| 3453 | + 'recurring' => $recurring, |
|
| 3454 | + ); |
|
| 3455 | 3455 | |
| 3456 | - return $this->is_renewal() ? $recurring : $tax; |
|
| 3456 | + return $this->is_renewal() ? $recurring : $tax; |
|
| 3457 | 3457 | |
| 3458 | 3458 | } |
| 3459 | 3459 | |
| 3460 | 3460 | /** |
| 3461 | - * Recalculates the invoice fees total. |
|
| 3462 | - * |
|
| 3463 | - * @since 1.0.19 |
|
| 3464 | - * @return float The recalculated fee |
|
| 3465 | - */ |
|
| 3466 | - public function recalculate_total_fees() { |
|
| 3467 | - $fees = $this->get_fees(); |
|
| 3468 | - $fee = 0; |
|
| 3469 | - $recurring = 0; |
|
| 3461 | + * Recalculates the invoice fees total. |
|
| 3462 | + * |
|
| 3463 | + * @since 1.0.19 |
|
| 3464 | + * @return float The recalculated fee |
|
| 3465 | + */ |
|
| 3466 | + public function recalculate_total_fees() { |
|
| 3467 | + $fees = $this->get_fees(); |
|
| 3468 | + $fee = 0; |
|
| 3469 | + $recurring = 0; |
|
| 3470 | 3470 | |
| 3471 | 3471 | foreach ( $fees as $data ) { |
| 3472 | 3472 | |
| 3473 | - if ( $data['recurring'] ) { |
|
| 3474 | - $recurring += $data['amount']; |
|
| 3475 | - } else { |
|
| 3476 | - $fee += $data['amount']; |
|
| 3477 | - } |
|
| 3473 | + if ( $data['recurring'] ) { |
|
| 3474 | + $recurring += $data['amount']; |
|
| 3475 | + } else { |
|
| 3476 | + $fee += $data['amount']; |
|
| 3477 | + } |
|
| 3478 | 3478 | |
| 3479 | - } |
|
| 3479 | + } |
|
| 3480 | 3480 | |
| 3481 | 3481 | if ( $this->is_renewal() ) { |
| 3482 | - $this->set_total_fees( $recurring ); |
|
| 3483 | - } else { |
|
| 3484 | - $this->set_total_fees( $fee ); |
|
| 3485 | - } |
|
| 3482 | + $this->set_total_fees( $recurring ); |
|
| 3483 | + } else { |
|
| 3484 | + $this->set_total_fees( $fee ); |
|
| 3485 | + } |
|
| 3486 | 3486 | |
| 3487 | - $this->totals['fee'] = array( |
|
| 3488 | - 'initial' => $fee, |
|
| 3489 | - 'recurring' => $recurring, |
|
| 3490 | - ); |
|
| 3487 | + $this->totals['fee'] = array( |
|
| 3488 | + 'initial' => $fee, |
|
| 3489 | + 'recurring' => $recurring, |
|
| 3490 | + ); |
|
| 3491 | 3491 | |
| 3492 | 3492 | $this->set_total_fees( $fee ); |
| 3493 | 3493 | return $this->is_renewal() ? $recurring : $fee; |
| 3494 | 3494 | } |
| 3495 | 3495 | |
| 3496 | 3496 | /** |
| 3497 | - * Recalculates the invoice total. |
|
| 3498 | - * |
|
| 3499 | - * @since 1.0.19 |
|
| 3497 | + * Recalculates the invoice total. |
|
| 3498 | + * |
|
| 3499 | + * @since 1.0.19 |
|
| 3500 | 3500 | * @return float The invoice total |
| 3501 | - */ |
|
| 3502 | - public function recalculate_total() { |
|
| 3501 | + */ |
|
| 3502 | + public function recalculate_total() { |
|
| 3503 | 3503 | $this->recalculate_subtotal(); |
| 3504 | 3504 | $this->recalculate_total_fees(); |
| 3505 | 3505 | $this->recalculate_total_discount(); |
| 3506 | 3506 | $this->recalculate_total_tax(); |
| 3507 | - return $this->get_total(); |
|
| 3508 | - } |
|
| 3507 | + return $this->get_total(); |
|
| 3508 | + } |
|
| 3509 | 3509 | |
| 3510 | - /** |
|
| 3511 | - * @deprecated |
|
| 3512 | - */ |
|
| 3510 | + /** |
|
| 3511 | + * @deprecated |
|
| 3512 | + */ |
|
| 3513 | 3513 | public function recalculate_totals( $temp = false ) { |
| 3514 | 3514 | $this->update_items( $temp ); |
| 3515 | 3515 | $this->save( true ); |
@@ -3573,9 +3573,9 @@ discard block |
||
| 3573 | 3573 | } |
| 3574 | 3574 | |
| 3575 | 3575 | return $note_id; |
| 3576 | - } |
|
| 3576 | + } |
|
| 3577 | 3577 | |
| 3578 | - /** |
|
| 3578 | + /** |
|
| 3579 | 3579 | * Generates a unique key for the invoice. |
| 3580 | 3580 | */ |
| 3581 | 3581 | public function generate_key( $string = '' ) { |
@@ -3595,106 +3595,106 @@ discard block |
||
| 3595 | 3595 | $number = wpinv_get_next_invoice_number( $this->post_type ); |
| 3596 | 3596 | } |
| 3597 | 3597 | |
| 3598 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3598 | + $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3599 | 3599 | |
| 3600 | - return $number; |
|
| 3601 | - } |
|
| 3600 | + return $number; |
|
| 3601 | + } |
|
| 3602 | 3602 | |
| 3603 | - /** |
|
| 3604 | - * Handle the status transition. |
|
| 3605 | - */ |
|
| 3606 | - protected function status_transition() { |
|
| 3607 | - $status_transition = $this->status_transition; |
|
| 3603 | + /** |
|
| 3604 | + * Handle the status transition. |
|
| 3605 | + */ |
|
| 3606 | + protected function status_transition() { |
|
| 3607 | + $status_transition = $this->status_transition; |
|
| 3608 | 3608 | |
| 3609 | - // Reset status transition variable. |
|
| 3610 | - $this->status_transition = false; |
|
| 3609 | + // Reset status transition variable. |
|
| 3610 | + $this->status_transition = false; |
|
| 3611 | 3611 | |
| 3612 | - if ( $status_transition ) { |
|
| 3613 | - try { |
|
| 3612 | + if ( $status_transition ) { |
|
| 3613 | + try { |
|
| 3614 | 3614 | |
| 3615 | - // Fire a hook for the status change. |
|
| 3616 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3615 | + // Fire a hook for the status change. |
|
| 3616 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3617 | 3617 | |
| 3618 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3619 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3618 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3619 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3620 | 3620 | |
| 3621 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3621 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3622 | 3622 | |
| 3623 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3624 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3623 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3624 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3625 | 3625 | |
| 3626 | - // Fire another hook. |
|
| 3627 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3628 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3626 | + // Fire another hook. |
|
| 3627 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3628 | + do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3629 | 3629 | |
| 3630 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3631 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3630 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3631 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3632 | 3632 | |
| 3633 | - // Note the transition occurred. |
|
| 3634 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3633 | + // Note the transition occurred. |
|
| 3634 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3635 | 3635 | |
| 3636 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3637 | - if ( |
|
| 3638 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
| 3639 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3640 | - ) { |
|
| 3641 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3642 | - } |
|
| 3643 | - } else { |
|
| 3644 | - /* translators: %s: new invoice status */ |
|
| 3645 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3636 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3637 | + if ( |
|
| 3638 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
| 3639 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3640 | + ) { |
|
| 3641 | + do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3642 | + } |
|
| 3643 | + } else { |
|
| 3644 | + /* translators: %s: new invoice status */ |
|
| 3645 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3646 | 3646 | |
| 3647 | - // Note the transition occurred. |
|
| 3648 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3647 | + // Note the transition occurred. |
|
| 3648 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3649 | 3649 | |
| 3650 | - } |
|
| 3651 | - } catch ( Exception $e ) { |
|
| 3652 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3653 | - } |
|
| 3654 | - } |
|
| 3655 | - } |
|
| 3650 | + } |
|
| 3651 | + } catch ( Exception $e ) { |
|
| 3652 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3653 | + } |
|
| 3654 | + } |
|
| 3655 | + } |
|
| 3656 | 3656 | |
| 3657 | - /** |
|
| 3658 | - * Updates an invoice status. |
|
| 3659 | - */ |
|
| 3660 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3657 | + /** |
|
| 3658 | + * Updates an invoice status. |
|
| 3659 | + */ |
|
| 3660 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3661 | 3661 | |
| 3662 | - // Fires before updating a status. |
|
| 3663 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3662 | + // Fires before updating a status. |
|
| 3663 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3664 | 3664 | |
| 3665 | - // Update the status. |
|
| 3666 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3665 | + // Update the status. |
|
| 3666 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3667 | 3667 | |
| 3668 | - // Save the order. |
|
| 3669 | - return $this->save(); |
|
| 3668 | + // Save the order. |
|
| 3669 | + return $this->save(); |
|
| 3670 | 3670 | |
| 3671 | - } |
|
| 3671 | + } |
|
| 3672 | 3672 | |
| 3673 | - /** |
|
| 3674 | - * @deprecated |
|
| 3675 | - */ |
|
| 3676 | - public function refresh_item_ids() { |
|
| 3673 | + /** |
|
| 3674 | + * @deprecated |
|
| 3675 | + */ |
|
| 3676 | + public function refresh_item_ids() { |
|
| 3677 | 3677 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
| 3678 | 3678 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3679 | - } |
|
| 3679 | + } |
|
| 3680 | 3680 | |
| 3681 | - /** |
|
| 3682 | - * @deprecated |
|
| 3683 | - */ |
|
| 3684 | - public function update_items( $temp = false ) { |
|
| 3681 | + /** |
|
| 3682 | + * @deprecated |
|
| 3683 | + */ |
|
| 3684 | + public function update_items( $temp = false ) { |
|
| 3685 | 3685 | |
| 3686 | - $this->set_items( $this->get_items() ); |
|
| 3686 | + $this->set_items( $this->get_items() ); |
|
| 3687 | 3687 | |
| 3688 | - if ( ! $temp ) { |
|
| 3689 | - $this->save(); |
|
| 3690 | - } |
|
| 3688 | + if ( ! $temp ) { |
|
| 3689 | + $this->save(); |
|
| 3690 | + } |
|
| 3691 | 3691 | |
| 3692 | 3692 | return $this; |
| 3693 | - } |
|
| 3693 | + } |
|
| 3694 | 3694 | |
| 3695 | - /** |
|
| 3696 | - * @deprecated |
|
| 3697 | - */ |
|
| 3695 | + /** |
|
| 3696 | + * @deprecated |
|
| 3697 | + */ |
|
| 3698 | 3698 | public function validate_discount() { |
| 3699 | 3699 | |
| 3700 | 3700 | $discount_code = $this->get_discount_code(); |
@@ -3710,86 +3710,86 @@ discard block |
||
| 3710 | 3710 | |
| 3711 | 3711 | } |
| 3712 | 3712 | |
| 3713 | - /** |
|
| 3714 | - * Refunds an invoice. |
|
| 3715 | - */ |
|
| 3713 | + /** |
|
| 3714 | + * Refunds an invoice. |
|
| 3715 | + */ |
|
| 3716 | 3716 | public function refund() { |
| 3717 | - $this->set_status( 'wpi-refunded' ); |
|
| 3717 | + $this->set_status( 'wpi-refunded' ); |
|
| 3718 | 3718 | $this->save(); |
| 3719 | - } |
|
| 3719 | + } |
|
| 3720 | 3720 | |
| 3721 | - /** |
|
| 3722 | - * Marks an invoice as paid. |
|
| 3723 | - * |
|
| 3724 | - * @param string $transaction_id |
|
| 3725 | - */ |
|
| 3721 | + /** |
|
| 3722 | + * Marks an invoice as paid. |
|
| 3723 | + * |
|
| 3724 | + * @param string $transaction_id |
|
| 3725 | + */ |
|
| 3726 | 3726 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3727 | 3727 | |
| 3728 | - // Set the transaction id. |
|
| 3729 | - if ( empty( $transaction_id ) ) { |
|
| 3730 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3731 | - } |
|
| 3728 | + // Set the transaction id. |
|
| 3729 | + if ( empty( $transaction_id ) ) { |
|
| 3730 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3731 | + } |
|
| 3732 | 3732 | |
| 3733 | - if ( ! $this->get_transaction_id() ) { |
|
| 3734 | - $this->set_transaction_id( $transaction_id ); |
|
| 3735 | - } |
|
| 3733 | + if ( ! $this->get_transaction_id() ) { |
|
| 3734 | + $this->set_transaction_id( $transaction_id ); |
|
| 3735 | + } |
|
| 3736 | 3736 | |
| 3737 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3738 | - return $this->save(); |
|
| 3739 | - } |
|
| 3737 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3738 | + return $this->save(); |
|
| 3739 | + } |
|
| 3740 | 3740 | |
| 3741 | - // Set the completed date. |
|
| 3742 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3741 | + // Set the completed date. |
|
| 3742 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3743 | 3743 | |
| 3744 | - // Set the new status. |
|
| 3745 | - if ( $this->is_renewal() ) { |
|
| 3744 | + // Set the new status. |
|
| 3745 | + if ( $this->is_renewal() ) { |
|
| 3746 | 3746 | |
| 3747 | - $_note = sprintf( |
|
| 3748 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3749 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3750 | - ); |
|
| 3747 | + $_note = sprintf( |
|
| 3748 | + __( 'Renewed via %s', 'invoicing' ), |
|
| 3749 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3750 | + ); |
|
| 3751 | 3751 | |
| 3752 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3753 | - $_note = $note; |
|
| 3754 | - } |
|
| 3752 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3753 | + $_note = $note; |
|
| 3754 | + } |
|
| 3755 | 3755 | |
| 3756 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3756 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3757 | 3757 | |
| 3758 | - } else { |
|
| 3758 | + } else { |
|
| 3759 | 3759 | |
| 3760 | - $_note = sprintf( |
|
| 3761 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3762 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3763 | - ); |
|
| 3760 | + $_note = sprintf( |
|
| 3761 | + __( 'Paid via %s', 'invoicing' ), |
|
| 3762 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3763 | + ); |
|
| 3764 | 3764 | |
| 3765 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3766 | - $_note = $note; |
|
| 3767 | - } |
|
| 3765 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3766 | + $_note = $note; |
|
| 3767 | + } |
|
| 3768 | 3768 | |
| 3769 | - $this->set_status( 'publish',$_note ); |
|
| 3769 | + $this->set_status( 'publish',$_note ); |
|
| 3770 | 3770 | |
| 3771 | - } |
|
| 3771 | + } |
|
| 3772 | 3772 | |
| 3773 | - // Set checkout mode. |
|
| 3774 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3775 | - $this->set_mode( $mode ); |
|
| 3773 | + // Set checkout mode. |
|
| 3774 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3775 | + $this->set_mode( $mode ); |
|
| 3776 | 3776 | |
| 3777 | - // Save the invoice. |
|
| 3777 | + // Save the invoice. |
|
| 3778 | 3778 | $this->save(); |
| 3779 | - } |
|
| 3780 | - |
|
| 3781 | - |
|
| 3782 | - /** |
|
| 3783 | - * Save data to the database. |
|
| 3784 | - * |
|
| 3785 | - * @since 1.0.19 |
|
| 3786 | - * @return int invoice ID |
|
| 3787 | - */ |
|
| 3788 | - public function save() { |
|
| 3789 | - $this->maybe_set_date_paid(); |
|
| 3790 | - parent::save(); |
|
| 3791 | - $this->status_transition(); |
|
| 3792 | - return $this->get_id(); |
|
| 3793 | - } |
|
| 3779 | + } |
|
| 3780 | + |
|
| 3781 | + |
|
| 3782 | + /** |
|
| 3783 | + * Save data to the database. |
|
| 3784 | + * |
|
| 3785 | + * @since 1.0.19 |
|
| 3786 | + * @return int invoice ID |
|
| 3787 | + */ |
|
| 3788 | + public function save() { |
|
| 3789 | + $this->maybe_set_date_paid(); |
|
| 3790 | + parent::save(); |
|
| 3791 | + $this->status_transition(); |
|
| 3792 | + return $this->get_id(); |
|
| 3793 | + } |
|
| 3794 | 3794 | |
| 3795 | 3795 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Invoice class. |
@@ -133,40 +133,40 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 135 | 135 | */ |
| 136 | - public function __construct( $invoice = false ) { |
|
| 136 | + public function __construct($invoice = false) { |
|
| 137 | 137 | |
| 138 | - parent::__construct( $invoice ); |
|
| 138 | + parent::__construct($invoice); |
|
| 139 | 139 | |
| 140 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 141 | - $this->set_id( $invoice ); |
|
| 142 | - } elseif ( $invoice instanceof self ) { |
|
| 143 | - $this->set_id( $invoice->get_id() ); |
|
| 144 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 145 | - $this->set_id( $invoice->ID ); |
|
| 146 | - } elseif ( is_array( $invoice ) ) { |
|
| 147 | - $this->set_props( $invoice ); |
|
| 140 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
| 141 | + $this->set_id($invoice); |
|
| 142 | + } elseif ($invoice instanceof self) { |
|
| 143 | + $this->set_id($invoice->get_id()); |
|
| 144 | + } elseif (!empty($invoice->ID)) { |
|
| 145 | + $this->set_id($invoice->ID); |
|
| 146 | + } elseif (is_array($invoice)) { |
|
| 147 | + $this->set_props($invoice); |
|
| 148 | 148 | |
| 149 | - if ( isset( $invoice['ID'] ) ) { |
|
| 150 | - $this->set_id( $invoice['ID'] ); |
|
| 149 | + if (isset($invoice['ID'])) { |
|
| 150 | + $this->set_id($invoice['ID']); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 154 | - $this->set_id( $invoice_id ); |
|
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - }else { |
|
| 160 | - $this->set_object_read( true ); |
|
| 153 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 154 | + $this->set_id($invoice_id); |
|
| 155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 156 | + $this->set_id($invoice_id); |
|
| 157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 158 | + $this->set_id($invoice_id); |
|
| 159 | + } else { |
|
| 160 | + $this->set_object_read(true); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Load the datastore. |
| 164 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 164 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 165 | 165 | |
| 166 | - if ( $this->get_id() > 0 ) { |
|
| 167 | - $this->post = get_post( $this->get_id() ); |
|
| 166 | + if ($this->get_id() > 0) { |
|
| 167 | + $this->post = get_post($this->get_id()); |
|
| 168 | 168 | $this->ID = $this->get_id(); |
| 169 | - $this->data_store->read( $this ); |
|
| 169 | + $this->data_store->read($this); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
@@ -181,42 +181,42 @@ discard block |
||
| 181 | 181 | * @since 1.0.15 |
| 182 | 182 | * @return int |
| 183 | 183 | */ |
| 184 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 184 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 185 | 185 | global $wpdb; |
| 186 | 186 | |
| 187 | 187 | // Trim the value. |
| 188 | - $value = trim( $value ); |
|
| 188 | + $value = trim($value); |
|
| 189 | 189 | |
| 190 | - if ( empty( $value ) ) { |
|
| 190 | + if (empty($value)) { |
|
| 191 | 191 | return 0; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // Valid fields. |
| 195 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 195 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 196 | 196 | |
| 197 | 197 | // Ensure a field has been passed. |
| 198 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 198 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 199 | 199 | return 0; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // Maybe retrieve from the cache. |
| 203 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 204 | - if ( ! empty( $invoice_id ) ) { |
|
| 203 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 204 | + if (!empty($invoice_id)) { |
|
| 205 | 205 | return $invoice_id; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Fetch from the db. |
| 209 | 209 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 210 | 210 | $invoice_id = $wpdb->get_var( |
| 211 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 211 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - if ( empty( $invoice_id ) ) { |
|
| 214 | + if (empty($invoice_id)) { |
|
| 215 | 215 | return 0; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Update the cache with our data |
| 219 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 219 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 220 | 220 | |
| 221 | 221 | return $invoice_id; |
| 222 | 222 | } |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | /** |
| 225 | 225 | * Checks if an invoice key is set. |
| 226 | 226 | */ |
| 227 | - public function _isset( $key ) { |
|
| 228 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 227 | + public function _isset($key) { |
|
| 228 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /* |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | * @param string $context View or edit context. |
| 251 | 251 | * @return int |
| 252 | 252 | */ |
| 253 | - public function get_parent_id( $context = 'view' ) { |
|
| 254 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 253 | + public function get_parent_id($context = 'view') { |
|
| 254 | + return (int) $this->get_prop('parent_id', $context); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return WPInv_Invoice |
| 262 | 262 | */ |
| 263 | 263 | public function get_parent_payment() { |
| 264 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 264 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * @param string $context View or edit context. |
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | - public function get_status( $context = 'view' ) { |
|
| 285 | - return $this->get_prop( 'status', $context ); |
|
| 284 | + public function get_status($context = 'view') { |
|
| 285 | + return $this->get_prop('status', $context); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function get_all_statuses() { |
| 295 | 295 | |
| 296 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 296 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
| 297 | 297 | |
| 298 | 298 | // For backwards compatibility. |
| 299 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 299 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
| 300 | 300 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | public function get_status_nicename() { |
| 313 | 313 | $statuses = $this->get_all_statuses(); |
| 314 | 314 | |
| 315 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 315 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 316 | 316 | |
| 317 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 317 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -324,27 +324,27 @@ discard block |
||
| 324 | 324 | * @param string $context View or edit context. |
| 325 | 325 | * @return string |
| 326 | 326 | */ |
| 327 | - public function get_version( $context = 'view' ) { |
|
| 328 | - return $this->get_prop( 'version', $context ); |
|
| 327 | + public function get_version($context = 'view') { |
|
| 328 | + return $this->get_prop('version', $context); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | 332 | * @deprecated |
| 333 | 333 | */ |
| 334 | - public function get_invoice_date( $formatted = true ) { |
|
| 334 | + public function get_invoice_date($formatted = true) { |
|
| 335 | 335 | $date_completed = $this->get_date_completed(); |
| 336 | 336 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 337 | 337 | |
| 338 | - if ( $invoice_date == '' ) { |
|
| 338 | + if ($invoice_date == '') { |
|
| 339 | 339 | $date_created = $this->get_date_created(); |
| 340 | 340 | $invoice_date = $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( $formatted && $invoice_date ) { |
|
| 344 | - $invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) ); |
|
| 343 | + if ($formatted && $invoice_date) { |
|
| 344 | + $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date)); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this ); |
|
| 347 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | * @param string $context View or edit context. |
| 355 | 355 | * @return string |
| 356 | 356 | */ |
| 357 | - public function get_date_created( $context = 'view' ) { |
|
| 358 | - return $this->get_prop( 'date_created', $context ); |
|
| 357 | + public function get_date_created($context = 'view') { |
|
| 358 | + return $this->get_prop('date_created', $context); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | * @param string $context View or edit context. |
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | - public function get_created_date( $context = 'view' ) { |
|
| 369 | - return $this->get_date_created( $context ); |
|
| 368 | + public function get_created_date($context = 'view') { |
|
| 369 | + return $this->get_date_created($context); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -376,11 +376,11 @@ discard block |
||
| 376 | 376 | * @param string $context View or edit context. |
| 377 | 377 | * @return string |
| 378 | 378 | */ |
| 379 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 380 | - $date = $this->get_date_created( $context ); |
|
| 379 | + public function get_date_created_gmt($context = 'view') { |
|
| 380 | + $date = $this->get_date_created($context); |
|
| 381 | 381 | |
| 382 | - if ( $date ) { |
|
| 383 | - $date = get_gmt_from_date( $date ); |
|
| 382 | + if ($date) { |
|
| 383 | + $date = get_gmt_from_date($date); |
|
| 384 | 384 | } |
| 385 | 385 | return $date; |
| 386 | 386 | } |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | * @param string $context View or edit context. |
| 393 | 393 | * @return string |
| 394 | 394 | */ |
| 395 | - public function get_date_modified( $context = 'view' ) { |
|
| 396 | - return $this->get_prop( 'date_modified', $context ); |
|
| 395 | + public function get_date_modified($context = 'view') { |
|
| 396 | + return $this->get_prop('date_modified', $context); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | * @param string $context View or edit context. |
| 404 | 404 | * @return string |
| 405 | 405 | */ |
| 406 | - public function get_modified_date( $context = 'view' ) { |
|
| 407 | - return $this->get_date_modified( $context ); |
|
| 406 | + public function get_modified_date($context = 'view') { |
|
| 407 | + return $this->get_date_modified($context); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | * @param string $context View or edit context. |
| 415 | 415 | * @return string |
| 416 | 416 | */ |
| 417 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 418 | - $date = $this->get_date_modified( $context ); |
|
| 417 | + public function get_date_modified_gmt($context = 'view') { |
|
| 418 | + $date = $this->get_date_modified($context); |
|
| 419 | 419 | |
| 420 | - if ( $date ) { |
|
| 421 | - $date = get_gmt_from_date( $date ); |
|
| 420 | + if ($date) { |
|
| 421 | + $date = get_gmt_from_date($date); |
|
| 422 | 422 | } |
| 423 | 423 | return $date; |
| 424 | 424 | } |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | * @param string $context View or edit context. |
| 431 | 431 | * @return string |
| 432 | 432 | */ |
| 433 | - public function get_due_date( $context = 'view' ) { |
|
| 434 | - return $this->get_prop( 'due_date', $context ); |
|
| 433 | + public function get_due_date($context = 'view') { |
|
| 434 | + return $this->get_prop('due_date', $context); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | * @param string $context View or edit context. |
| 442 | 442 | * @return string |
| 443 | 443 | */ |
| 444 | - public function get_date_due( $context = 'view' ) { |
|
| 445 | - return $this->get_due_date( $context ); |
|
| 444 | + public function get_date_due($context = 'view') { |
|
| 445 | + return $this->get_due_date($context); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | * @param string $context View or edit context. |
| 453 | 453 | * @return string |
| 454 | 454 | */ |
| 455 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 456 | - $date = $this->get_due_date( $context ); |
|
| 455 | + public function get_due_date_gmt($context = 'view') { |
|
| 456 | + $date = $this->get_due_date($context); |
|
| 457 | 457 | |
| 458 | - if ( $date ) { |
|
| 459 | - $date = get_gmt_from_date( $date ); |
|
| 458 | + if ($date) { |
|
| 459 | + $date = get_gmt_from_date($date); |
|
| 460 | 460 | } |
| 461 | 461 | return $date; |
| 462 | 462 | } |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | * @param string $context View or edit context. |
| 469 | 469 | * @return string |
| 470 | 470 | */ |
| 471 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 472 | - return $this->get_due_date_gmt( $context ); |
|
| 471 | + public function get_gmt_date_due($context = 'view') { |
|
| 472 | + return $this->get_due_date_gmt($context); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | * @param string $context View or edit context. |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - public function get_completed_date( $context = 'view' ) { |
|
| 483 | - return $this->get_prop( 'completed_date', $context ); |
|
| 482 | + public function get_completed_date($context = 'view') { |
|
| 483 | + return $this->get_prop('completed_date', $context); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | * @param string $context View or edit context. |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | - public function get_date_completed( $context = 'view' ) { |
|
| 494 | - return $this->get_completed_date( $context ); |
|
| 493 | + public function get_date_completed($context = 'view') { |
|
| 494 | + return $this->get_completed_date($context); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
@@ -501,11 +501,11 @@ discard block |
||
| 501 | 501 | * @param string $context View or edit context. |
| 502 | 502 | * @return string |
| 503 | 503 | */ |
| 504 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 505 | - $date = $this->get_completed_date( $context ); |
|
| 504 | + public function get_completed_date_gmt($context = 'view') { |
|
| 505 | + $date = $this->get_completed_date($context); |
|
| 506 | 506 | |
| 507 | - if ( $date ) { |
|
| 508 | - $date = get_gmt_from_date( $date ); |
|
| 507 | + if ($date) { |
|
| 508 | + $date = get_gmt_from_date($date); |
|
| 509 | 509 | } |
| 510 | 510 | return $date; |
| 511 | 511 | } |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | * @param string $context View or edit context. |
| 518 | 518 | * @return string |
| 519 | 519 | */ |
| 520 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 521 | - return $this->get_completed_date_gmt( $context ); |
|
| 520 | + public function get_gmt_completed_date($context = 'view') { |
|
| 521 | + return $this->get_completed_date_gmt($context); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -528,12 +528,12 @@ discard block |
||
| 528 | 528 | * @param string $context View or edit context. |
| 529 | 529 | * @return string |
| 530 | 530 | */ |
| 531 | - public function get_number( $context = 'view' ) { |
|
| 532 | - $number = $this->get_prop( 'number', $context ); |
|
| 531 | + public function get_number($context = 'view') { |
|
| 532 | + $number = $this->get_prop('number', $context); |
|
| 533 | 533 | |
| 534 | - if ( empty( $number ) ) { |
|
| 534 | + if (empty($number)) { |
|
| 535 | 535 | $number = $this->generate_number(); |
| 536 | - $this->set_number( $number ); |
|
| 536 | + $this->set_number($number); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | return $number; |
@@ -546,12 +546,12 @@ discard block |
||
| 546 | 546 | * @param string $context View or edit context. |
| 547 | 547 | * @return string |
| 548 | 548 | */ |
| 549 | - public function get_key( $context = 'view' ) { |
|
| 550 | - $key = $this->get_prop( 'key', $context ); |
|
| 549 | + public function get_key($context = 'view') { |
|
| 550 | + $key = $this->get_prop('key', $context); |
|
| 551 | 551 | |
| 552 | - if ( empty( $key ) ) { |
|
| 553 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 554 | - $this->set_key( $key ); |
|
| 552 | + if (empty($key)) { |
|
| 553 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 554 | + $this->set_key($key); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | return $key; |
@@ -564,23 +564,23 @@ discard block |
||
| 564 | 564 | * @param string $context View or edit context. |
| 565 | 565 | * @return string |
| 566 | 566 | */ |
| 567 | - public function get_type( $context = 'view' ) { |
|
| 568 | - return $this->get_prop( 'type', $context ); |
|
| 567 | + public function get_type($context = 'view') { |
|
| 568 | + return $this->get_prop('type', $context); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
| 572 | 572 | * @deprecated |
| 573 | 573 | */ |
| 574 | - public function get_invoice_quote_type( $post_id ) { |
|
| 575 | - if ( empty( $post_id ) ) { |
|
| 574 | + public function get_invoice_quote_type($post_id) { |
|
| 575 | + if (empty($post_id)) { |
|
| 576 | 576 | return ''; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - $type = get_post_type( $post_id ); |
|
| 579 | + $type = get_post_type($post_id); |
|
| 580 | 580 | |
| 581 | - if ( 'wpi_invoice' === $type ) { |
|
| 581 | + if ('wpi_invoice' === $type) { |
|
| 582 | 582 | $post_type = __('Invoice', 'invoicing'); |
| 583 | - } else{ |
|
| 583 | + } else { |
|
| 584 | 584 | $post_type = __('Quote', 'invoicing'); |
| 585 | 585 | } |
| 586 | 586 | |
@@ -594,8 +594,8 @@ discard block |
||
| 594 | 594 | * @param string $context View or edit context. |
| 595 | 595 | * @return string |
| 596 | 596 | */ |
| 597 | - public function get_post_type( $context = 'view' ) { |
|
| 598 | - return $this->get_prop( 'post_type', $context ); |
|
| 597 | + public function get_post_type($context = 'view') { |
|
| 598 | + return $this->get_prop('post_type', $context); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -605,8 +605,8 @@ discard block |
||
| 605 | 605 | * @param string $context View or edit context. |
| 606 | 606 | * @return string |
| 607 | 607 | */ |
| 608 | - public function get_mode( $context = 'view' ) { |
|
| 609 | - return $this->get_prop( 'mode', $context ); |
|
| 608 | + public function get_mode($context = 'view') { |
|
| 609 | + return $this->get_prop('mode', $context); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -616,12 +616,12 @@ discard block |
||
| 616 | 616 | * @param string $context View or edit context. |
| 617 | 617 | * @return string |
| 618 | 618 | */ |
| 619 | - public function get_path( $context = 'view' ) { |
|
| 620 | - $path = $this->get_prop( 'path', $context ); |
|
| 619 | + public function get_path($context = 'view') { |
|
| 620 | + $path = $this->get_prop('path', $context); |
|
| 621 | 621 | |
| 622 | - if ( empty( $path ) ) { |
|
| 623 | - $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type ); |
|
| 624 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
| 622 | + if (empty($path)) { |
|
| 623 | + $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type); |
|
| 624 | + $path = sanitize_title($prefix . $this->get_id()); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | return $path; |
@@ -634,10 +634,10 @@ discard block |
||
| 634 | 634 | * @param string $context View or edit context. |
| 635 | 635 | * @return string |
| 636 | 636 | */ |
| 637 | - public function get_name( $context = 'view' ) { |
|
| 638 | - $name = $this->get_prop( 'title', $context ); |
|
| 637 | + public function get_name($context = 'view') { |
|
| 638 | + $name = $this->get_prop('title', $context); |
|
| 639 | 639 | |
| 640 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 640 | + return empty($name) ? $this->get_number($context) : $name; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -647,8 +647,8 @@ discard block |
||
| 647 | 647 | * @param string $context View or edit context. |
| 648 | 648 | * @return string |
| 649 | 649 | */ |
| 650 | - public function get_title( $context = 'view' ) { |
|
| 651 | - return $this->get_name( $context ); |
|
| 650 | + public function get_title($context = 'view') { |
|
| 651 | + return $this->get_name($context); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
@@ -658,8 +658,8 @@ discard block |
||
| 658 | 658 | * @param string $context View or edit context. |
| 659 | 659 | * @return string |
| 660 | 660 | */ |
| 661 | - public function get_description( $context = 'view' ) { |
|
| 662 | - return $this->get_prop( 'description', $context ); |
|
| 661 | + public function get_description($context = 'view') { |
|
| 662 | + return $this->get_prop('description', $context); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
@@ -669,8 +669,8 @@ discard block |
||
| 669 | 669 | * @param string $context View or edit context. |
| 670 | 670 | * @return string |
| 671 | 671 | */ |
| 672 | - public function get_excerpt( $context = 'view' ) { |
|
| 673 | - return $this->get_description( $context ); |
|
| 672 | + public function get_excerpt($context = 'view') { |
|
| 673 | + return $this->get_description($context); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | * @param string $context View or edit context. |
| 681 | 681 | * @return string |
| 682 | 682 | */ |
| 683 | - public function get_summary( $context = 'view' ) { |
|
| 684 | - return $this->get_description( $context ); |
|
| 683 | + public function get_summary($context = 'view') { |
|
| 684 | + return $this->get_description($context); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -691,25 +691,25 @@ discard block |
||
| 691 | 691 | * @param string $context View or edit context. |
| 692 | 692 | * @return array |
| 693 | 693 | */ |
| 694 | - public function get_user_info( $context = 'view' ) { |
|
| 694 | + public function get_user_info($context = 'view') { |
|
| 695 | 695 | |
| 696 | 696 | $user_info = array( |
| 697 | - 'user_id' => $this->get_user_id( $context ), |
|
| 698 | - 'email' => $this->get_email( $context ), |
|
| 699 | - 'first_name' => $this->get_first_name( $context ), |
|
| 700 | - 'last_name' => $this->get_last_name( $context ), |
|
| 701 | - 'address' => $this->get_address( $context ), |
|
| 702 | - 'phone' => $this->get_phone( $context ), |
|
| 703 | - 'city' => $this->get_city( $context ), |
|
| 704 | - 'country' => $this->get_country( $context ), |
|
| 705 | - 'state' => $this->get_state( $context ), |
|
| 706 | - 'zip' => $this->get_zip( $context ), |
|
| 707 | - 'company' => $this->get_company( $context ), |
|
| 708 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 709 | - 'discount' => $this->get_discount_code( $context ), |
|
| 697 | + 'user_id' => $this->get_user_id($context), |
|
| 698 | + 'email' => $this->get_email($context), |
|
| 699 | + 'first_name' => $this->get_first_name($context), |
|
| 700 | + 'last_name' => $this->get_last_name($context), |
|
| 701 | + 'address' => $this->get_address($context), |
|
| 702 | + 'phone' => $this->get_phone($context), |
|
| 703 | + 'city' => $this->get_city($context), |
|
| 704 | + 'country' => $this->get_country($context), |
|
| 705 | + 'state' => $this->get_state($context), |
|
| 706 | + 'zip' => $this->get_zip($context), |
|
| 707 | + 'company' => $this->get_company($context), |
|
| 708 | + 'vat_number' => $this->get_vat_number($context), |
|
| 709 | + 'discount' => $this->get_discount_code($context), |
|
| 710 | 710 | ); |
| 711 | 711 | |
| 712 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 712 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 713 | 713 | |
| 714 | 714 | } |
| 715 | 715 | |
@@ -720,8 +720,8 @@ discard block |
||
| 720 | 720 | * @param string $context View or edit context. |
| 721 | 721 | * @return int |
| 722 | 722 | */ |
| 723 | - public function get_author( $context = 'view' ) { |
|
| 724 | - return (int) $this->get_prop( 'author', $context ); |
|
| 723 | + public function get_author($context = 'view') { |
|
| 724 | + return (int) $this->get_prop('author', $context); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
@@ -731,8 +731,8 @@ discard block |
||
| 731 | 731 | * @param string $context View or edit context. |
| 732 | 732 | * @return int |
| 733 | 733 | */ |
| 734 | - public function get_user_id( $context = 'view' ) { |
|
| 735 | - return $this->get_author( $context ); |
|
| 734 | + public function get_user_id($context = 'view') { |
|
| 735 | + return $this->get_author($context); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -742,8 +742,8 @@ discard block |
||
| 742 | 742 | * @param string $context View or edit context. |
| 743 | 743 | * @return int |
| 744 | 744 | */ |
| 745 | - public function get_customer_id( $context = 'view' ) { |
|
| 746 | - return $this->get_author( $context ); |
|
| 745 | + public function get_customer_id($context = 'view') { |
|
| 746 | + return $this->get_author($context); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | * @param string $context View or edit context. |
| 754 | 754 | * @return string |
| 755 | 755 | */ |
| 756 | - public function get_ip( $context = 'view' ) { |
|
| 757 | - return $this->get_prop( 'user_ip', $context ); |
|
| 756 | + public function get_ip($context = 'view') { |
|
| 757 | + return $this->get_prop('user_ip', $context); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param string $context View or edit context. |
| 765 | 765 | * @return string |
| 766 | 766 | */ |
| 767 | - public function get_user_ip( $context = 'view' ) { |
|
| 768 | - return $this->get_ip( $context ); |
|
| 767 | + public function get_user_ip($context = 'view') { |
|
| 768 | + return $this->get_ip($context); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -775,8 +775,8 @@ discard block |
||
| 775 | 775 | * @param string $context View or edit context. |
| 776 | 776 | * @return string |
| 777 | 777 | */ |
| 778 | - public function get_customer_ip( $context = 'view' ) { |
|
| 779 | - return $this->get_ip( $context ); |
|
| 778 | + public function get_customer_ip($context = 'view') { |
|
| 779 | + return $this->get_ip($context); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
@@ -786,8 +786,8 @@ discard block |
||
| 786 | 786 | * @param string $context View or edit context. |
| 787 | 787 | * @return string |
| 788 | 788 | */ |
| 789 | - public function get_first_name( $context = 'view' ) { |
|
| 790 | - return $this->get_prop( 'first_name', $context ); |
|
| 789 | + public function get_first_name($context = 'view') { |
|
| 790 | + return $this->get_prop('first_name', $context); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -797,8 +797,8 @@ discard block |
||
| 797 | 797 | * @param string $context View or edit context. |
| 798 | 798 | * @return int |
| 799 | 799 | */ |
| 800 | - public function get_user_first_name( $context = 'view' ) { |
|
| 801 | - return $this->get_first_name( $context ); |
|
| 800 | + public function get_user_first_name($context = 'view') { |
|
| 801 | + return $this->get_first_name($context); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | /** |
@@ -808,8 +808,8 @@ discard block |
||
| 808 | 808 | * @param string $context View or edit context. |
| 809 | 809 | * @return int |
| 810 | 810 | */ |
| 811 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 812 | - return $this->get_first_name( $context ); |
|
| 811 | + public function get_customer_first_name($context = 'view') { |
|
| 812 | + return $this->get_first_name($context); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -819,8 +819,8 @@ discard block |
||
| 819 | 819 | * @param string $context View or edit context. |
| 820 | 820 | * @return string |
| 821 | 821 | */ |
| 822 | - public function get_last_name( $context = 'view' ) { |
|
| 823 | - return $this->get_prop( 'last_name', $context ); |
|
| 822 | + public function get_last_name($context = 'view') { |
|
| 823 | + return $this->get_prop('last_name', $context); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
@@ -830,8 +830,8 @@ discard block |
||
| 830 | 830 | * @param string $context View or edit context. |
| 831 | 831 | * @return int |
| 832 | 832 | */ |
| 833 | - public function get_user_last_name( $context = 'view' ) { |
|
| 834 | - return $this->get_last_name( $context ); |
|
| 833 | + public function get_user_last_name($context = 'view') { |
|
| 834 | + return $this->get_last_name($context); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | * @param string $context View or edit context. |
| 842 | 842 | * @return int |
| 843 | 843 | */ |
| 844 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 845 | - return $this->get_last_name( $context ); |
|
| 844 | + public function get_customer_last_name($context = 'view') { |
|
| 845 | + return $this->get_last_name($context); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | * @param string $context View or edit context. |
| 853 | 853 | * @return string |
| 854 | 854 | */ |
| 855 | - public function get_full_name( $context = 'view' ) { |
|
| 856 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 855 | + public function get_full_name($context = 'view') { |
|
| 856 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
@@ -863,8 +863,8 @@ discard block |
||
| 863 | 863 | * @param string $context View or edit context. |
| 864 | 864 | * @return int |
| 865 | 865 | */ |
| 866 | - public function get_user_full_name( $context = 'view' ) { |
|
| 867 | - return $this->get_full_name( $context ); |
|
| 866 | + public function get_user_full_name($context = 'view') { |
|
| 867 | + return $this->get_full_name($context); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
@@ -874,8 +874,8 @@ discard block |
||
| 874 | 874 | * @param string $context View or edit context. |
| 875 | 875 | * @return int |
| 876 | 876 | */ |
| 877 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 878 | - return $this->get_full_name( $context ); |
|
| 877 | + public function get_customer_full_name($context = 'view') { |
|
| 878 | + return $this->get_full_name($context); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
@@ -885,8 +885,8 @@ discard block |
||
| 885 | 885 | * @param string $context View or edit context. |
| 886 | 886 | * @return string |
| 887 | 887 | */ |
| 888 | - public function get_phone( $context = 'view' ) { |
|
| 889 | - return $this->get_prop( 'phone', $context ); |
|
| 888 | + public function get_phone($context = 'view') { |
|
| 889 | + return $this->get_prop('phone', $context); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /** |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | * @param string $context View or edit context. |
| 897 | 897 | * @return int |
| 898 | 898 | */ |
| 899 | - public function get_phone_number( $context = 'view' ) { |
|
| 900 | - return $this->get_phone( $context ); |
|
| 899 | + public function get_phone_number($context = 'view') { |
|
| 900 | + return $this->get_phone($context); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -907,8 +907,8 @@ discard block |
||
| 907 | 907 | * @param string $context View or edit context. |
| 908 | 908 | * @return int |
| 909 | 909 | */ |
| 910 | - public function get_user_phone( $context = 'view' ) { |
|
| 911 | - return $this->get_phone( $context ); |
|
| 910 | + public function get_user_phone($context = 'view') { |
|
| 911 | + return $this->get_phone($context); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -918,8 +918,8 @@ discard block |
||
| 918 | 918 | * @param string $context View or edit context. |
| 919 | 919 | * @return int |
| 920 | 920 | */ |
| 921 | - public function get_customer_phone( $context = 'view' ) { |
|
| 922 | - return $this->get_phone( $context ); |
|
| 921 | + public function get_customer_phone($context = 'view') { |
|
| 922 | + return $this->get_phone($context); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
@@ -929,8 +929,8 @@ discard block |
||
| 929 | 929 | * @param string $context View or edit context. |
| 930 | 930 | * @return string |
| 931 | 931 | */ |
| 932 | - public function get_email( $context = 'view' ) { |
|
| 933 | - return $this->get_prop( 'email', $context ); |
|
| 932 | + public function get_email($context = 'view') { |
|
| 933 | + return $this->get_prop('email', $context); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -940,8 +940,8 @@ discard block |
||
| 940 | 940 | * @param string $context View or edit context. |
| 941 | 941 | * @return string |
| 942 | 942 | */ |
| 943 | - public function get_email_address( $context = 'view' ) { |
|
| 944 | - return $this->get_email( $context ); |
|
| 943 | + public function get_email_address($context = 'view') { |
|
| 944 | + return $this->get_email($context); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | /** |
@@ -951,8 +951,8 @@ discard block |
||
| 951 | 951 | * @param string $context View or edit context. |
| 952 | 952 | * @return int |
| 953 | 953 | */ |
| 954 | - public function get_user_email( $context = 'view' ) { |
|
| 955 | - return $this->get_email( $context ); |
|
| 954 | + public function get_user_email($context = 'view') { |
|
| 955 | + return $this->get_email($context); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | /** |
@@ -962,8 +962,8 @@ discard block |
||
| 962 | 962 | * @param string $context View or edit context. |
| 963 | 963 | * @return int |
| 964 | 964 | */ |
| 965 | - public function get_customer_email( $context = 'view' ) { |
|
| 966 | - return $this->get_email( $context ); |
|
| 965 | + public function get_customer_email($context = 'view') { |
|
| 966 | + return $this->get_email($context); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
@@ -973,9 +973,9 @@ discard block |
||
| 973 | 973 | * @param string $context View or edit context. |
| 974 | 974 | * @return string |
| 975 | 975 | */ |
| 976 | - public function get_country( $context = 'view' ) { |
|
| 977 | - $country = $this->get_prop( 'country', $context ); |
|
| 978 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 976 | + public function get_country($context = 'view') { |
|
| 977 | + $country = $this->get_prop('country', $context); |
|
| 978 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | /** |
@@ -985,8 +985,8 @@ discard block |
||
| 985 | 985 | * @param string $context View or edit context. |
| 986 | 986 | * @return int |
| 987 | 987 | */ |
| 988 | - public function get_user_country( $context = 'view' ) { |
|
| 989 | - return $this->get_country( $context ); |
|
| 988 | + public function get_user_country($context = 'view') { |
|
| 989 | + return $this->get_country($context); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
@@ -996,8 +996,8 @@ discard block |
||
| 996 | 996 | * @param string $context View or edit context. |
| 997 | 997 | * @return int |
| 998 | 998 | */ |
| 999 | - public function get_customer_country( $context = 'view' ) { |
|
| 1000 | - return $this->get_country( $context ); |
|
| 999 | + public function get_customer_country($context = 'view') { |
|
| 1000 | + return $this->get_country($context); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | /** |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | * @param string $context View or edit context. |
| 1008 | 1008 | * @return string |
| 1009 | 1009 | */ |
| 1010 | - public function get_state( $context = 'view' ) { |
|
| 1011 | - $state = $this->get_prop( 'state', $context ); |
|
| 1012 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1010 | + public function get_state($context = 'view') { |
|
| 1011 | + $state = $this->get_prop('state', $context); |
|
| 1012 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /** |
@@ -1019,8 +1019,8 @@ discard block |
||
| 1019 | 1019 | * @param string $context View or edit context. |
| 1020 | 1020 | * @return int |
| 1021 | 1021 | */ |
| 1022 | - public function get_user_state( $context = 'view' ) { |
|
| 1023 | - return $this->get_state( $context ); |
|
| 1022 | + public function get_user_state($context = 'view') { |
|
| 1023 | + return $this->get_state($context); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | * @param string $context View or edit context. |
| 1031 | 1031 | * @return int |
| 1032 | 1032 | */ |
| 1033 | - public function get_customer_state( $context = 'view' ) { |
|
| 1034 | - return $this->get_state( $context ); |
|
| 1033 | + public function get_customer_state($context = 'view') { |
|
| 1034 | + return $this->get_state($context); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
@@ -1041,8 +1041,8 @@ discard block |
||
| 1041 | 1041 | * @param string $context View or edit context. |
| 1042 | 1042 | * @return string |
| 1043 | 1043 | */ |
| 1044 | - public function get_city( $context = 'view' ) { |
|
| 1045 | - return $this->get_prop( 'city', $context ); |
|
| 1044 | + public function get_city($context = 'view') { |
|
| 1045 | + return $this->get_prop('city', $context); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
@@ -1052,8 +1052,8 @@ discard block |
||
| 1052 | 1052 | * @param string $context View or edit context. |
| 1053 | 1053 | * @return string |
| 1054 | 1054 | */ |
| 1055 | - public function get_user_city( $context = 'view' ) { |
|
| 1056 | - return $this->get_city( $context ); |
|
| 1055 | + public function get_user_city($context = 'view') { |
|
| 1056 | + return $this->get_city($context); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
| 1063 | 1063 | * @param string $context View or edit context. |
| 1064 | 1064 | * @return string |
| 1065 | 1065 | */ |
| 1066 | - public function get_customer_city( $context = 'view' ) { |
|
| 1067 | - return $this->get_city( $context ); |
|
| 1066 | + public function get_customer_city($context = 'view') { |
|
| 1067 | + return $this->get_city($context); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
@@ -1074,8 +1074,8 @@ discard block |
||
| 1074 | 1074 | * @param string $context View or edit context. |
| 1075 | 1075 | * @return string |
| 1076 | 1076 | */ |
| 1077 | - public function get_zip( $context = 'view' ) { |
|
| 1078 | - return $this->get_prop( 'zip', $context ); |
|
| 1077 | + public function get_zip($context = 'view') { |
|
| 1078 | + return $this->get_prop('zip', $context); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
@@ -1085,8 +1085,8 @@ discard block |
||
| 1085 | 1085 | * @param string $context View or edit context. |
| 1086 | 1086 | * @return string |
| 1087 | 1087 | */ |
| 1088 | - public function get_user_zip( $context = 'view' ) { |
|
| 1089 | - return $this->get_zip( $context ); |
|
| 1088 | + public function get_user_zip($context = 'view') { |
|
| 1089 | + return $this->get_zip($context); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
@@ -1096,8 +1096,8 @@ discard block |
||
| 1096 | 1096 | * @param string $context View or edit context. |
| 1097 | 1097 | * @return string |
| 1098 | 1098 | */ |
| 1099 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1100 | - return $this->get_zip( $context ); |
|
| 1099 | + public function get_customer_zip($context = 'view') { |
|
| 1100 | + return $this->get_zip($context); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1107,8 +1107,8 @@ discard block |
||
| 1107 | 1107 | * @param string $context View or edit context. |
| 1108 | 1108 | * @return string |
| 1109 | 1109 | */ |
| 1110 | - public function get_company( $context = 'view' ) { |
|
| 1111 | - return $this->get_prop( 'company', $context ); |
|
| 1110 | + public function get_company($context = 'view') { |
|
| 1111 | + return $this->get_prop('company', $context); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1118,8 +1118,8 @@ discard block |
||
| 1118 | 1118 | * @param string $context View or edit context. |
| 1119 | 1119 | * @return string |
| 1120 | 1120 | */ |
| 1121 | - public function get_user_company( $context = 'view' ) { |
|
| 1122 | - return $this->get_company( $context ); |
|
| 1121 | + public function get_user_company($context = 'view') { |
|
| 1122 | + return $this->get_company($context); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
@@ -1129,8 +1129,8 @@ discard block |
||
| 1129 | 1129 | * @param string $context View or edit context. |
| 1130 | 1130 | * @return string |
| 1131 | 1131 | */ |
| 1132 | - public function get_customer_company( $context = 'view' ) { |
|
| 1133 | - return $this->get_company( $context ); |
|
| 1132 | + public function get_customer_company($context = 'view') { |
|
| 1133 | + return $this->get_company($context); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | /** |
@@ -1140,8 +1140,8 @@ discard block |
||
| 1140 | 1140 | * @param string $context View or edit context. |
| 1141 | 1141 | * @return string |
| 1142 | 1142 | */ |
| 1143 | - public function get_vat_number( $context = 'view' ) { |
|
| 1144 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1143 | + public function get_vat_number($context = 'view') { |
|
| 1144 | + return $this->get_prop('vat_number', $context); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1151,8 +1151,8 @@ discard block |
||
| 1151 | 1151 | * @param string $context View or edit context. |
| 1152 | 1152 | * @return string |
| 1153 | 1153 | */ |
| 1154 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1155 | - return $this->get_vat_number( $context ); |
|
| 1154 | + public function get_user_vat_number($context = 'view') { |
|
| 1155 | + return $this->get_vat_number($context); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
@@ -1162,8 +1162,8 @@ discard block |
||
| 1162 | 1162 | * @param string $context View or edit context. |
| 1163 | 1163 | * @return string |
| 1164 | 1164 | */ |
| 1165 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1166 | - return $this->get_vat_number( $context ); |
|
| 1165 | + public function get_customer_vat_number($context = 'view') { |
|
| 1166 | + return $this->get_vat_number($context); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | /** |
@@ -1173,8 +1173,8 @@ discard block |
||
| 1173 | 1173 | * @param string $context View or edit context. |
| 1174 | 1174 | * @return string |
| 1175 | 1175 | */ |
| 1176 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1177 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1176 | + public function get_vat_rate($context = 'view') { |
|
| 1177 | + return $this->get_prop('vat_rate', $context); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | /** |
@@ -1184,8 +1184,8 @@ discard block |
||
| 1184 | 1184 | * @param string $context View or edit context. |
| 1185 | 1185 | * @return string |
| 1186 | 1186 | */ |
| 1187 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1188 | - return $this->get_vat_rate( $context ); |
|
| 1187 | + public function get_user_vat_rate($context = 'view') { |
|
| 1188 | + return $this->get_vat_rate($context); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | * @param string $context View or edit context. |
| 1196 | 1196 | * @return string |
| 1197 | 1197 | */ |
| 1198 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1199 | - return $this->get_vat_rate( $context ); |
|
| 1198 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1199 | + return $this->get_vat_rate($context); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | /** |
@@ -1206,8 +1206,8 @@ discard block |
||
| 1206 | 1206 | * @param string $context View or edit context. |
| 1207 | 1207 | * @return string |
| 1208 | 1208 | */ |
| 1209 | - public function get_address( $context = 'view' ) { |
|
| 1210 | - return $this->get_prop( 'address', $context ); |
|
| 1209 | + public function get_address($context = 'view') { |
|
| 1210 | + return $this->get_prop('address', $context); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | /** |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | * @param string $context View or edit context. |
| 1218 | 1218 | * @return string |
| 1219 | 1219 | */ |
| 1220 | - public function get_user_address( $context = 'view' ) { |
|
| 1221 | - return $this->get_address( $context ); |
|
| 1220 | + public function get_user_address($context = 'view') { |
|
| 1221 | + return $this->get_address($context); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | /** |
@@ -1228,8 +1228,8 @@ discard block |
||
| 1228 | 1228 | * @param string $context View or edit context. |
| 1229 | 1229 | * @return string |
| 1230 | 1230 | */ |
| 1231 | - public function get_customer_address( $context = 'view' ) { |
|
| 1232 | - return $this->get_address( $context ); |
|
| 1231 | + public function get_customer_address($context = 'view') { |
|
| 1232 | + return $this->get_address($context); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | /** |
@@ -1239,8 +1239,8 @@ discard block |
||
| 1239 | 1239 | * @param string $context View or edit context. |
| 1240 | 1240 | * @return bool |
| 1241 | 1241 | */ |
| 1242 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1243 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1242 | + public function get_is_viewed($context = 'view') { |
|
| 1243 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1250,8 +1250,8 @@ discard block |
||
| 1250 | 1250 | * @param string $context View or edit context. |
| 1251 | 1251 | * @return bool |
| 1252 | 1252 | */ |
| 1253 | - public function get_email_cc( $context = 'view' ) { |
|
| 1254 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1253 | + public function get_email_cc($context = 'view') { |
|
| 1254 | + return $this->get_prop('email_cc', $context); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | /** |
@@ -1261,8 +1261,8 @@ discard block |
||
| 1261 | 1261 | * @param string $context View or edit context. |
| 1262 | 1262 | * @return bool |
| 1263 | 1263 | */ |
| 1264 | - public function get_template( $context = 'view' ) { |
|
| 1265 | - return $this->get_prop( 'template', $context ); |
|
| 1264 | + public function get_template($context = 'view') { |
|
| 1265 | + return $this->get_prop('template', $context); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | /** |
@@ -1272,8 +1272,8 @@ discard block |
||
| 1272 | 1272 | * @param string $context View or edit context. |
| 1273 | 1273 | * @return bool |
| 1274 | 1274 | */ |
| 1275 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1276 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1275 | + public function get_address_confirmed($context = 'view') { |
|
| 1276 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | /** |
@@ -1283,8 +1283,8 @@ discard block |
||
| 1283 | 1283 | * @param string $context View or edit context. |
| 1284 | 1284 | * @return bool |
| 1285 | 1285 | */ |
| 1286 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1287 | - return $this->get_address_confirmed( $context ); |
|
| 1286 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1287 | + return $this->get_address_confirmed($context); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | 1290 | /** |
@@ -1294,8 +1294,8 @@ discard block |
||
| 1294 | 1294 | * @param string $context View or edit context. |
| 1295 | 1295 | * @return bool |
| 1296 | 1296 | */ |
| 1297 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1298 | - return $this->get_address_confirmed( $context ); |
|
| 1297 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1298 | + return $this->get_address_confirmed($context); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1305,12 +1305,12 @@ discard block |
||
| 1305 | 1305 | * @param string $context View or edit context. |
| 1306 | 1306 | * @return float |
| 1307 | 1307 | */ |
| 1308 | - public function get_subtotal( $context = 'view' ) { |
|
| 1309 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1308 | + public function get_subtotal($context = 'view') { |
|
| 1309 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1310 | 1310 | |
| 1311 | 1311 | // Backwards compatibility. |
| 1312 | - if ( is_bool( $context ) && $context ) { |
|
| 1313 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
| 1312 | + if (is_bool($context) && $context) { |
|
| 1313 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | return $subtotal; |
@@ -1323,8 +1323,8 @@ discard block |
||
| 1323 | 1323 | * @param string $context View or edit context. |
| 1324 | 1324 | * @return float |
| 1325 | 1325 | */ |
| 1326 | - public function get_total_discount( $context = 'view' ) { |
|
| 1327 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1326 | + public function get_total_discount($context = 'view') { |
|
| 1327 | + return (float) $this->get_prop('total_discount', $context); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
@@ -1334,18 +1334,18 @@ discard block |
||
| 1334 | 1334 | * @param string $context View or edit context. |
| 1335 | 1335 | * @return float |
| 1336 | 1336 | */ |
| 1337 | - public function get_total_tax( $context = 'view' ) { |
|
| 1338 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1337 | + public function get_total_tax($context = 'view') { |
|
| 1338 | + return (float) $this->get_prop('total_tax', $context); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
| 1342 | 1342 | * @deprecated |
| 1343 | 1343 | */ |
| 1344 | - public function get_final_tax( $currency = false ) { |
|
| 1344 | + public function get_final_tax($currency = false) { |
|
| 1345 | 1345 | $tax = $this->get_total_tax(); |
| 1346 | 1346 | |
| 1347 | - if ( $currency ) { |
|
| 1348 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1347 | + if ($currency) { |
|
| 1348 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | return $tax; |
@@ -1358,8 +1358,8 @@ discard block |
||
| 1358 | 1358 | * @param string $context View or edit context. |
| 1359 | 1359 | * @return float |
| 1360 | 1360 | */ |
| 1361 | - public function get_total_fees( $context = 'view' ) { |
|
| 1362 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1361 | + public function get_total_fees($context = 'view') { |
|
| 1362 | + return (float) $this->get_prop('total_fees', $context); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | /** |
@@ -1369,8 +1369,8 @@ discard block |
||
| 1369 | 1369 | * @param string $context View or edit context. |
| 1370 | 1370 | * @return float |
| 1371 | 1371 | */ |
| 1372 | - public function get_fees_total( $context = 'view' ) { |
|
| 1373 | - return $this->get_total_fees( $context ); |
|
| 1372 | + public function get_fees_total($context = 'view') { |
|
| 1373 | + return $this->get_total_fees($context); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | */ |
| 1382 | 1382 | public function get_total() { |
| 1383 | 1383 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
| 1384 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1384 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
@@ -1403,7 +1403,7 @@ discard block |
||
| 1403 | 1403 | */ |
| 1404 | 1404 | public function get_initial_total() { |
| 1405 | 1405 | |
| 1406 | - if ( empty( $this->totals ) ) { |
|
| 1406 | + if (empty($this->totals)) { |
|
| 1407 | 1407 | $this->recalculate_total(); |
| 1408 | 1408 | } |
| 1409 | 1409 | |
@@ -1413,11 +1413,11 @@ discard block |
||
| 1413 | 1413 | $subtotal = $this->totals['subtotal']['initial']; |
| 1414 | 1414 | $total = $tax + $fee - $discount + $subtotal; |
| 1415 | 1415 | |
| 1416 | - if ( 0 > $total ) { |
|
| 1416 | + if (0 > $total) { |
|
| 1417 | 1417 | $total = 0; |
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1420 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | 1423 | /** |
@@ -1429,7 +1429,7 @@ discard block |
||
| 1429 | 1429 | */ |
| 1430 | 1430 | public function get_recurring_total() { |
| 1431 | 1431 | |
| 1432 | - if ( empty( $this->totals ) ) { |
|
| 1432 | + if (empty($this->totals)) { |
|
| 1433 | 1433 | $this->recalculate_total(); |
| 1434 | 1434 | } |
| 1435 | 1435 | |
@@ -1439,11 +1439,11 @@ discard block |
||
| 1439 | 1439 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1440 | 1440 | $total = $tax + $fee - $discount + $subtotal; |
| 1441 | 1441 | |
| 1442 | - if ( 0 > $total ) { |
|
| 1442 | + if (0 > $total) { |
|
| 1443 | 1443 | $total = 0; |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1446 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1454,10 +1454,10 @@ discard block |
||
| 1454 | 1454 | * @param string $currency Whether to include the currency. |
| 1455 | 1455 | * @return float |
| 1456 | 1456 | */ |
| 1457 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1457 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1458 | 1458 | |
| 1459 | 1459 | // Maybe recalculate totals. |
| 1460 | - if ( empty( $this->totals ) ) { |
|
| 1460 | + if (empty($this->totals)) { |
|
| 1461 | 1461 | $this->recalculate_total(); |
| 1462 | 1462 | } |
| 1463 | 1463 | |
@@ -1477,8 +1477,8 @@ discard block |
||
| 1477 | 1477 | $currency |
| 1478 | 1478 | ); |
| 1479 | 1479 | |
| 1480 | - if ( isset( $data[$field] ) ) { |
|
| 1481 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1480 | + if (isset($data[$field])) { |
|
| 1481 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | 1484 | return $data; |
@@ -1491,8 +1491,8 @@ discard block |
||
| 1491 | 1491 | * @param string $context View or edit context. |
| 1492 | 1492 | * @return array |
| 1493 | 1493 | */ |
| 1494 | - public function get_fees( $context = 'view' ) { |
|
| 1495 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1494 | + public function get_fees($context = 'view') { |
|
| 1495 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 | /** |
@@ -1502,8 +1502,8 @@ discard block |
||
| 1502 | 1502 | * @param string $context View or edit context. |
| 1503 | 1503 | * @return array |
| 1504 | 1504 | */ |
| 1505 | - public function get_discounts( $context = 'view' ) { |
|
| 1506 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1505 | + public function get_discounts($context = 'view') { |
|
| 1506 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | /** |
@@ -1513,8 +1513,8 @@ discard block |
||
| 1513 | 1513 | * @param string $context View or edit context. |
| 1514 | 1514 | * @return array |
| 1515 | 1515 | */ |
| 1516 | - public function get_taxes( $context = 'view' ) { |
|
| 1517 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1516 | + public function get_taxes($context = 'view') { |
|
| 1517 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | /** |
@@ -1524,8 +1524,8 @@ discard block |
||
| 1524 | 1524 | * @param string $context View or edit context. |
| 1525 | 1525 | * @return GetPaid_Form_Item[] |
| 1526 | 1526 | */ |
| 1527 | - public function get_items( $context = 'view' ) { |
|
| 1528 | - return $this->get_prop( 'items', $context ); |
|
| 1527 | + public function get_items($context = 'view') { |
|
| 1528 | + return $this->get_prop('items', $context); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | /** |
@@ -1535,8 +1535,8 @@ discard block |
||
| 1535 | 1535 | * @param string $context View or edit context. |
| 1536 | 1536 | * @return int |
| 1537 | 1537 | */ |
| 1538 | - public function get_payment_form( $context = 'view' ) { |
|
| 1539 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1538 | + public function get_payment_form($context = 'view') { |
|
| 1539 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | /** |
@@ -1546,8 +1546,8 @@ discard block |
||
| 1546 | 1546 | * @param string $context View or edit context. |
| 1547 | 1547 | * @return string |
| 1548 | 1548 | */ |
| 1549 | - public function get_submission_id( $context = 'view' ) { |
|
| 1550 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1549 | + public function get_submission_id($context = 'view') { |
|
| 1550 | + return $this->get_prop('submission_id', $context); |
|
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | /** |
@@ -1557,8 +1557,8 @@ discard block |
||
| 1557 | 1557 | * @param string $context View or edit context. |
| 1558 | 1558 | * @return string |
| 1559 | 1559 | */ |
| 1560 | - public function get_discount_code( $context = 'view' ) { |
|
| 1561 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1560 | + public function get_discount_code($context = 'view') { |
|
| 1561 | + return $this->get_prop('discount_code', $context); |
|
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | /** |
@@ -1568,8 +1568,8 @@ discard block |
||
| 1568 | 1568 | * @param string $context View or edit context. |
| 1569 | 1569 | * @return string |
| 1570 | 1570 | */ |
| 1571 | - public function get_gateway( $context = 'view' ) { |
|
| 1572 | - return $this->get_prop( 'gateway', $context ); |
|
| 1571 | + public function get_gateway($context = 'view') { |
|
| 1572 | + return $this->get_prop('gateway', $context); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | /** |
@@ -1579,8 +1579,8 @@ discard block |
||
| 1579 | 1579 | * @return string |
| 1580 | 1580 | */ |
| 1581 | 1581 | public function get_gateway_title() { |
| 1582 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1583 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1582 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1583 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | /** |
@@ -1590,8 +1590,8 @@ discard block |
||
| 1590 | 1590 | * @param string $context View or edit context. |
| 1591 | 1591 | * @return string |
| 1592 | 1592 | */ |
| 1593 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1594 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1593 | + public function get_transaction_id($context = 'view') { |
|
| 1594 | + return $this->get_prop('transaction_id', $context); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1601,9 +1601,9 @@ discard block |
||
| 1601 | 1601 | * @param string $context View or edit context. |
| 1602 | 1602 | * @return string |
| 1603 | 1603 | */ |
| 1604 | - public function get_currency( $context = 'view' ) { |
|
| 1605 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1606 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1604 | + public function get_currency($context = 'view') { |
|
| 1605 | + $currency = $this->get_prop('currency', $context); |
|
| 1606 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | /** |
@@ -1613,8 +1613,8 @@ discard block |
||
| 1613 | 1613 | * @param string $context View or edit context. |
| 1614 | 1614 | * @return bool |
| 1615 | 1615 | */ |
| 1616 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1617 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1616 | + public function get_disable_taxes($context = 'view') { |
|
| 1617 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | 1620 | /** |
@@ -1624,12 +1624,12 @@ discard block |
||
| 1624 | 1624 | * @param string $context View or edit context. |
| 1625 | 1625 | * @return int |
| 1626 | 1626 | */ |
| 1627 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1628 | - $subscription_id = $this->get_prop( 'subscription_id', $context ); |
|
| 1627 | + public function get_subscription_id($context = 'view') { |
|
| 1628 | + $subscription_id = $this->get_prop('subscription_id', $context); |
|
| 1629 | 1629 | |
| 1630 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1630 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1631 | 1631 | $parent = $this->get_parent(); |
| 1632 | - return $parent->get_subscription_id( $context ); |
|
| 1632 | + return $parent->get_subscription_id($context); |
|
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | 1635 | return $subscription_id; |
@@ -1642,20 +1642,20 @@ discard block |
||
| 1642 | 1642 | * @param string $context View or edit context. |
| 1643 | 1643 | * @return array |
| 1644 | 1644 | */ |
| 1645 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1645 | + public function get_payment_meta($context = 'view') { |
|
| 1646 | 1646 | |
| 1647 | 1647 | return array( |
| 1648 | - 'price' => $this->get_total( $context ), |
|
| 1649 | - 'date' => $this->get_date_created( $context ), |
|
| 1650 | - 'user_email' => $this->get_email( $context ), |
|
| 1651 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1652 | - 'currency' => $this->get_currency( $context ), |
|
| 1653 | - 'items' => $this->get_items( $context ), |
|
| 1654 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1648 | + 'price' => $this->get_total($context), |
|
| 1649 | + 'date' => $this->get_date_created($context), |
|
| 1650 | + 'user_email' => $this->get_email($context), |
|
| 1651 | + 'invoice_key' => $this->get_key($context), |
|
| 1652 | + 'currency' => $this->get_currency($context), |
|
| 1653 | + 'items' => $this->get_items($context), |
|
| 1654 | + 'user_info' => $this->get_user_info($context), |
|
| 1655 | 1655 | 'cart_details' => $this->get_cart_details(), |
| 1656 | - 'status' => $this->get_status( $context ), |
|
| 1657 | - 'fees' => $this->get_fees( $context ), |
|
| 1658 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1656 | + 'status' => $this->get_status($context), |
|
| 1657 | + 'fees' => $this->get_fees($context), |
|
| 1658 | + 'taxes' => $this->get_taxes($context), |
|
| 1659 | 1659 | ); |
| 1660 | 1660 | |
| 1661 | 1661 | } |
@@ -1670,7 +1670,7 @@ discard block |
||
| 1670 | 1670 | $items = $this->get_items(); |
| 1671 | 1671 | $cart_details = array(); |
| 1672 | 1672 | |
| 1673 | - foreach ( $items as $item_id => $item ) { |
|
| 1673 | + foreach ($items as $item_id => $item) { |
|
| 1674 | 1674 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1675 | 1675 | } |
| 1676 | 1676 | |
@@ -1682,11 +1682,11 @@ discard block |
||
| 1682 | 1682 | * |
| 1683 | 1683 | * @return null|GetPaid_Form_Item|int |
| 1684 | 1684 | */ |
| 1685 | - public function get_recurring( $object = false ) { |
|
| 1685 | + public function get_recurring($object = false) { |
|
| 1686 | 1686 | |
| 1687 | 1687 | // Are we returning an object? |
| 1688 | - if ( $object ) { |
|
| 1689 | - return $this->get_item( $this->recurring_item ); |
|
| 1688 | + if ($object) { |
|
| 1689 | + return $this->get_item($this->recurring_item); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | return $this->recurring_item; |
@@ -1701,15 +1701,15 @@ discard block |
||
| 1701 | 1701 | public function get_subscription_name() { |
| 1702 | 1702 | |
| 1703 | 1703 | // Retrieve the recurring name |
| 1704 | - $item = $this->get_recurring( true ); |
|
| 1704 | + $item = $this->get_recurring(true); |
|
| 1705 | 1705 | |
| 1706 | 1706 | // Abort if it does not exist. |
| 1707 | - if ( empty( $item ) ) { |
|
| 1707 | + if (empty($item)) { |
|
| 1708 | 1708 | return ''; |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | 1711 | // Return the item name. |
| 1712 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1712 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1713 | 1713 | } |
| 1714 | 1714 | |
| 1715 | 1715 | /** |
@@ -1719,9 +1719,9 @@ discard block |
||
| 1719 | 1719 | * @return string |
| 1720 | 1720 | */ |
| 1721 | 1721 | public function get_view_url() { |
| 1722 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1723 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1724 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1722 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1723 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1724 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | /** |
@@ -1730,25 +1730,25 @@ discard block |
||
| 1730 | 1730 | * @since 1.0.19 |
| 1731 | 1731 | * @return string |
| 1732 | 1732 | */ |
| 1733 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1733 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1734 | 1734 | |
| 1735 | 1735 | // Retrieve the checkout url. |
| 1736 | 1736 | $pay_url = wpinv_get_checkout_uri(); |
| 1737 | 1737 | |
| 1738 | 1738 | // Maybe force ssl. |
| 1739 | - if ( is_ssl() ) { |
|
| 1740 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1739 | + if (is_ssl()) { |
|
| 1740 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | // Add the invoice key. |
| 1744 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1744 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1745 | 1745 | |
| 1746 | 1746 | // (Maybe?) add a secret |
| 1747 | - if ( $secret ) { |
|
| 1748 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1747 | + if ($secret) { |
|
| 1748 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1751 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | /** |
@@ -1763,14 +1763,14 @@ discard block |
||
| 1763 | 1763 | $receipt_url = wpinv_get_success_page_uri(); |
| 1764 | 1764 | |
| 1765 | 1765 | // Maybe force ssl. |
| 1766 | - if ( is_ssl() ) { |
|
| 1767 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1766 | + if (is_ssl()) { |
|
| 1767 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | 1770 | // Add the invoice key. |
| 1771 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1771 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1772 | 1772 | |
| 1773 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1773 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | 1776 | /** |
@@ -1783,8 +1783,8 @@ discard block |
||
| 1783 | 1783 | * @param string $context View or edit context. |
| 1784 | 1784 | * @return mixed Value of the given invoice property (if set). |
| 1785 | 1785 | */ |
| 1786 | - public function get( $key, $context = 'view' ) { |
|
| 1787 | - return $this->get_prop( $key, $context ); |
|
| 1786 | + public function get($key, $context = 'view') { |
|
| 1787 | + return $this->get_prop($key, $context); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | /* |
@@ -1807,11 +1807,11 @@ discard block |
||
| 1807 | 1807 | * @param mixed $value new value. |
| 1808 | 1808 | * @return mixed Value of the given invoice property (if set). |
| 1809 | 1809 | */ |
| 1810 | - public function set( $key, $value ) { |
|
| 1810 | + public function set($key, $value) { |
|
| 1811 | 1811 | |
| 1812 | 1812 | $setter = "set_$key"; |
| 1813 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1814 | - $this->{$setter}( $value ); |
|
| 1813 | + if (is_callable(array($this, $setter))) { |
|
| 1814 | + $this->{$setter}($value); |
|
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | 1817 | } |
@@ -1825,48 +1825,48 @@ discard block |
||
| 1825 | 1825 | * @param bool $manual_update Is this a manual status change?. |
| 1826 | 1826 | * @return array details of change. |
| 1827 | 1827 | */ |
| 1828 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1828 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1829 | 1829 | $old_status = $this->get_status(); |
| 1830 | 1830 | |
| 1831 | 1831 | $statuses = $this->get_all_statuses(); |
| 1832 | 1832 | |
| 1833 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1834 | - unset( $statuses[ 'draft' ] ); |
|
| 1833 | + if (isset($statuses['draft'])) { |
|
| 1834 | + unset($statuses['draft']); |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | |
| 1838 | - $this->set_prop( 'status', $new_status ); |
|
| 1838 | + $this->set_prop('status', $new_status); |
|
| 1839 | 1839 | |
| 1840 | 1840 | // If setting the status, ensure it's set to a valid status. |
| 1841 | - if ( true === $this->object_read ) { |
|
| 1841 | + if (true === $this->object_read) { |
|
| 1842 | 1842 | |
| 1843 | 1843 | // Only allow valid new status. |
| 1844 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1844 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1845 | 1845 | $new_status = 'wpi-pending'; |
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1849 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1849 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1850 | 1850 | $old_status = 'wpi-pending'; |
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | 1853 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1854 | - if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) { |
|
| 1854 | + if ($new_status == 'wpi-renewal' && $old_status == 'publish') { |
|
| 1855 | 1855 | $old_status = 'wpi-pending'; |
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1860 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 1861 | 1861 | $this->status_transition = array( |
| 1862 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1862 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1863 | 1863 | 'to' => $new_status, |
| 1864 | 1864 | 'note' => $note, |
| 1865 | 1865 | 'manual' => (bool) $manual_update, |
| 1866 | 1866 | ); |
| 1867 | 1867 | |
| 1868 | - if ( $manual_update ) { |
|
| 1869 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1868 | + if ($manual_update) { |
|
| 1869 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1870 | 1870 | } |
| 1871 | 1871 | |
| 1872 | 1872 | $this->maybe_set_date_paid(); |
@@ -1889,8 +1889,8 @@ discard block |
||
| 1889 | 1889 | */ |
| 1890 | 1890 | public function maybe_set_date_paid() { |
| 1891 | 1891 | |
| 1892 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1893 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1892 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 1893 | + $this->set_date_completed(current_time('mysql')); |
|
| 1894 | 1894 | } |
| 1895 | 1895 | } |
| 1896 | 1896 | |
@@ -1899,11 +1899,11 @@ discard block |
||
| 1899 | 1899 | * |
| 1900 | 1900 | * @since 1.0.19 |
| 1901 | 1901 | */ |
| 1902 | - public function set_parent_id( $value ) { |
|
| 1903 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1902 | + public function set_parent_id($value) { |
|
| 1903 | + if ($value && ($value === $this->get_id())) { |
|
| 1904 | 1904 | return; |
| 1905 | 1905 | } |
| 1906 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1906 | + $this->set_prop('parent_id', absint($value)); |
|
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | 1909 | /** |
@@ -1911,8 +1911,8 @@ discard block |
||
| 1911 | 1911 | * |
| 1912 | 1912 | * @since 1.0.19 |
| 1913 | 1913 | */ |
| 1914 | - public function set_version( $value ) { |
|
| 1915 | - $this->set_prop( 'version', $value ); |
|
| 1914 | + public function set_version($value) { |
|
| 1915 | + $this->set_prop('version', $value); |
|
| 1916 | 1916 | } |
| 1917 | 1917 | |
| 1918 | 1918 | /** |
@@ -1922,15 +1922,15 @@ discard block |
||
| 1922 | 1922 | * @param string $value Value to set. |
| 1923 | 1923 | * @return bool Whether or not the date was set. |
| 1924 | 1924 | */ |
| 1925 | - public function set_date_created( $value ) { |
|
| 1926 | - $date = strtotime( $value ); |
|
| 1925 | + public function set_date_created($value) { |
|
| 1926 | + $date = strtotime($value); |
|
| 1927 | 1927 | |
| 1928 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1929 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1928 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1929 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 1930 | 1930 | return true; |
| 1931 | 1931 | } |
| 1932 | 1932 | |
| 1933 | - return $this->set_prop( 'date_created', '' ); |
|
| 1933 | + return $this->set_prop('date_created', ''); |
|
| 1934 | 1934 | |
| 1935 | 1935 | } |
| 1936 | 1936 | |
@@ -1941,15 +1941,15 @@ discard block |
||
| 1941 | 1941 | * @param string $value Value to set. |
| 1942 | 1942 | * @return bool Whether or not the date was set. |
| 1943 | 1943 | */ |
| 1944 | - public function set_due_date( $value ) { |
|
| 1945 | - $date = strtotime( $value ); |
|
| 1944 | + public function set_due_date($value) { |
|
| 1945 | + $date = strtotime($value); |
|
| 1946 | 1946 | |
| 1947 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1948 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1947 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1948 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 1949 | 1949 | return true; |
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | - $this->set_prop( 'due_date', '' ); |
|
| 1952 | + $this->set_prop('due_date', ''); |
|
| 1953 | 1953 | return false; |
| 1954 | 1954 | |
| 1955 | 1955 | } |
@@ -1960,8 +1960,8 @@ discard block |
||
| 1960 | 1960 | * @since 1.0.19 |
| 1961 | 1961 | * @param string $value New name. |
| 1962 | 1962 | */ |
| 1963 | - public function set_date_due( $value ) { |
|
| 1964 | - $this->set_due_date( $value ); |
|
| 1963 | + public function set_date_due($value) { |
|
| 1964 | + $this->set_due_date($value); |
|
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | /** |
@@ -1971,15 +1971,15 @@ discard block |
||
| 1971 | 1971 | * @param string $value Value to set. |
| 1972 | 1972 | * @return bool Whether or not the date was set. |
| 1973 | 1973 | */ |
| 1974 | - public function set_completed_date( $value ) { |
|
| 1975 | - $date = strtotime( $value ); |
|
| 1974 | + public function set_completed_date($value) { |
|
| 1975 | + $date = strtotime($value); |
|
| 1976 | 1976 | |
| 1977 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1978 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1977 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1978 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 1979 | 1979 | return true; |
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - $this->set_prop( 'completed_date', '' ); |
|
| 1982 | + $this->set_prop('completed_date', ''); |
|
| 1983 | 1983 | return false; |
| 1984 | 1984 | |
| 1985 | 1985 | } |
@@ -1990,8 +1990,8 @@ discard block |
||
| 1990 | 1990 | * @since 1.0.19 |
| 1991 | 1991 | * @param string $value New name. |
| 1992 | 1992 | */ |
| 1993 | - public function set_date_completed( $value ) { |
|
| 1994 | - $this->set_completed_date( $value ); |
|
| 1993 | + public function set_date_completed($value) { |
|
| 1994 | + $this->set_completed_date($value); |
|
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | 1997 | /** |
@@ -2001,15 +2001,15 @@ discard block |
||
| 2001 | 2001 | * @param string $value Value to set. |
| 2002 | 2002 | * @return bool Whether or not the date was set. |
| 2003 | 2003 | */ |
| 2004 | - public function set_date_modified( $value ) { |
|
| 2005 | - $date = strtotime( $value ); |
|
| 2004 | + public function set_date_modified($value) { |
|
| 2005 | + $date = strtotime($value); |
|
| 2006 | 2006 | |
| 2007 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2008 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2007 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2008 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 2009 | 2009 | return true; |
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | - $this->set_prop( 'date_modified', '' ); |
|
| 2012 | + $this->set_prop('date_modified', ''); |
|
| 2013 | 2013 | return false; |
| 2014 | 2014 | |
| 2015 | 2015 | } |
@@ -2020,9 +2020,9 @@ discard block |
||
| 2020 | 2020 | * @since 1.0.19 |
| 2021 | 2021 | * @param string $value New number. |
| 2022 | 2022 | */ |
| 2023 | - public function set_number( $value ) { |
|
| 2024 | - $number = sanitize_text_field( $value ); |
|
| 2025 | - $this->set_prop( 'number', $number ); |
|
| 2023 | + public function set_number($value) { |
|
| 2024 | + $number = sanitize_text_field($value); |
|
| 2025 | + $this->set_prop('number', $number); |
|
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | /** |
@@ -2031,9 +2031,9 @@ discard block |
||
| 2031 | 2031 | * @since 1.0.19 |
| 2032 | 2032 | * @param string $value Type. |
| 2033 | 2033 | */ |
| 2034 | - public function set_type( $value ) { |
|
| 2035 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2036 | - $this->set_prop( 'type', $type ); |
|
| 2034 | + public function set_type($value) { |
|
| 2035 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2036 | + $this->set_prop('type', $type); |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | /** |
@@ -2042,10 +2042,10 @@ discard block |
||
| 2042 | 2042 | * @since 1.0.19 |
| 2043 | 2043 | * @param string $value Post type. |
| 2044 | 2044 | */ |
| 2045 | - public function set_post_type( $value ) { |
|
| 2046 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2047 | - $this->set_type( $value ); |
|
| 2048 | - $this->set_prop( 'post_type', $value ); |
|
| 2045 | + public function set_post_type($value) { |
|
| 2046 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2047 | + $this->set_type($value); |
|
| 2048 | + $this->set_prop('post_type', $value); |
|
| 2049 | 2049 | } |
| 2050 | 2050 | } |
| 2051 | 2051 | |
@@ -2055,9 +2055,9 @@ discard block |
||
| 2055 | 2055 | * @since 1.0.19 |
| 2056 | 2056 | * @param string $value New key. |
| 2057 | 2057 | */ |
| 2058 | - public function set_key( $value ) { |
|
| 2059 | - $key = sanitize_text_field( $value ); |
|
| 2060 | - $this->set_prop( 'key', $key ); |
|
| 2058 | + public function set_key($value) { |
|
| 2059 | + $key = sanitize_text_field($value); |
|
| 2060 | + $this->set_prop('key', $key); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | /** |
@@ -2066,9 +2066,9 @@ discard block |
||
| 2066 | 2066 | * @since 1.0.19 |
| 2067 | 2067 | * @param string $value mode. |
| 2068 | 2068 | */ |
| 2069 | - public function set_mode( $value ) { |
|
| 2070 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2071 | - $this->set_prop( 'value', $value ); |
|
| 2069 | + public function set_mode($value) { |
|
| 2070 | + if (!in_array($value, array('live', 'test'))) { |
|
| 2071 | + $this->set_prop('value', $value); |
|
| 2072 | 2072 | } |
| 2073 | 2073 | } |
| 2074 | 2074 | |
@@ -2078,8 +2078,8 @@ discard block |
||
| 2078 | 2078 | * @since 1.0.19 |
| 2079 | 2079 | * @param string $value path. |
| 2080 | 2080 | */ |
| 2081 | - public function set_path( $value ) { |
|
| 2082 | - $this->set_prop( 'path', $value ); |
|
| 2081 | + public function set_path($value) { |
|
| 2082 | + $this->set_prop('path', $value); |
|
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | /** |
@@ -2088,9 +2088,9 @@ discard block |
||
| 2088 | 2088 | * @since 1.0.19 |
| 2089 | 2089 | * @param string $value New name. |
| 2090 | 2090 | */ |
| 2091 | - public function set_name( $value ) { |
|
| 2092 | - $name = sanitize_text_field( $value ); |
|
| 2093 | - $this->set_prop( 'name', $name ); |
|
| 2091 | + public function set_name($value) { |
|
| 2092 | + $name = sanitize_text_field($value); |
|
| 2093 | + $this->set_prop('name', $name); |
|
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | 2096 | /** |
@@ -2099,8 +2099,8 @@ discard block |
||
| 2099 | 2099 | * @since 1.0.19 |
| 2100 | 2100 | * @param string $value New name. |
| 2101 | 2101 | */ |
| 2102 | - public function set_title( $value ) { |
|
| 2103 | - $this->set_name( $value ); |
|
| 2102 | + public function set_title($value) { |
|
| 2103 | + $this->set_name($value); |
|
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | 2106 | /** |
@@ -2109,9 +2109,9 @@ discard block |
||
| 2109 | 2109 | * @since 1.0.19 |
| 2110 | 2110 | * @param string $value New description. |
| 2111 | 2111 | */ |
| 2112 | - public function set_description( $value ) { |
|
| 2113 | - $description = wp_kses_post( $value ); |
|
| 2114 | - return $this->set_prop( 'description', $description ); |
|
| 2112 | + public function set_description($value) { |
|
| 2113 | + $description = wp_kses_post($value); |
|
| 2114 | + return $this->set_prop('description', $description); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | 2117 | /** |
@@ -2120,8 +2120,8 @@ discard block |
||
| 2120 | 2120 | * @since 1.0.19 |
| 2121 | 2121 | * @param string $value New description. |
| 2122 | 2122 | */ |
| 2123 | - public function set_excerpt( $value ) { |
|
| 2124 | - $this->set_description( $value ); |
|
| 2123 | + public function set_excerpt($value) { |
|
| 2124 | + $this->set_description($value); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | 2127 | /** |
@@ -2130,8 +2130,8 @@ discard block |
||
| 2130 | 2130 | * @since 1.0.19 |
| 2131 | 2131 | * @param string $value New description. |
| 2132 | 2132 | */ |
| 2133 | - public function set_summary( $value ) { |
|
| 2134 | - $this->set_description( $value ); |
|
| 2133 | + public function set_summary($value) { |
|
| 2134 | + $this->set_description($value); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | /** |
@@ -2140,12 +2140,12 @@ discard block |
||
| 2140 | 2140 | * @since 1.0.19 |
| 2141 | 2141 | * @param int $value New author. |
| 2142 | 2142 | */ |
| 2143 | - public function set_author( $value ) { |
|
| 2144 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2143 | + public function set_author($value) { |
|
| 2144 | + $user = get_user_by('id', (int) $value); |
|
| 2145 | 2145 | |
| 2146 | - if ( $user && $user->ID ) { |
|
| 2147 | - $this->set_prop( 'author', $user->ID ); |
|
| 2148 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2146 | + if ($user && $user->ID) { |
|
| 2147 | + $this->set_prop('author', $user->ID); |
|
| 2148 | + $this->set_prop('email', $user->user_email); |
|
| 2149 | 2149 | } |
| 2150 | 2150 | |
| 2151 | 2151 | } |
@@ -2156,8 +2156,8 @@ discard block |
||
| 2156 | 2156 | * @since 1.0.19 |
| 2157 | 2157 | * @param int $value New user id. |
| 2158 | 2158 | */ |
| 2159 | - public function set_user_id( $value ) { |
|
| 2160 | - $this->set_author( $value ); |
|
| 2159 | + public function set_user_id($value) { |
|
| 2160 | + $this->set_author($value); |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | /** |
@@ -2166,8 +2166,8 @@ discard block |
||
| 2166 | 2166 | * @since 1.0.19 |
| 2167 | 2167 | * @param int $value New user id. |
| 2168 | 2168 | */ |
| 2169 | - public function set_customer_id( $value ) { |
|
| 2170 | - $this->set_author( $value ); |
|
| 2169 | + public function set_customer_id($value) { |
|
| 2170 | + $this->set_author($value); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | 2173 | /** |
@@ -2176,8 +2176,8 @@ discard block |
||
| 2176 | 2176 | * @since 1.0.19 |
| 2177 | 2177 | * @param string $value ip address. |
| 2178 | 2178 | */ |
| 2179 | - public function set_ip( $value ) { |
|
| 2180 | - $this->set_prop( 'ip', $value ); |
|
| 2179 | + public function set_ip($value) { |
|
| 2180 | + $this->set_prop('ip', $value); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | /** |
@@ -2186,8 +2186,8 @@ discard block |
||
| 2186 | 2186 | * @since 1.0.19 |
| 2187 | 2187 | * @param string $value ip address. |
| 2188 | 2188 | */ |
| 2189 | - public function set_user_ip( $value ) { |
|
| 2190 | - $this->set_ip( $value ); |
|
| 2189 | + public function set_user_ip($value) { |
|
| 2190 | + $this->set_ip($value); |
|
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | /** |
@@ -2196,8 +2196,8 @@ discard block |
||
| 2196 | 2196 | * @since 1.0.19 |
| 2197 | 2197 | * @param string $value first name. |
| 2198 | 2198 | */ |
| 2199 | - public function set_first_name( $value ) { |
|
| 2200 | - $this->set_prop( 'first_name', $value ); |
|
| 2199 | + public function set_first_name($value) { |
|
| 2200 | + $this->set_prop('first_name', $value); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | 2203 | /** |
@@ -2206,8 +2206,8 @@ discard block |
||
| 2206 | 2206 | * @since 1.0.19 |
| 2207 | 2207 | * @param string $value first name. |
| 2208 | 2208 | */ |
| 2209 | - public function set_user_first_name( $value ) { |
|
| 2210 | - $this->set_first_name( $value ); |
|
| 2209 | + public function set_user_first_name($value) { |
|
| 2210 | + $this->set_first_name($value); |
|
| 2211 | 2211 | } |
| 2212 | 2212 | |
| 2213 | 2213 | /** |
@@ -2216,8 +2216,8 @@ discard block |
||
| 2216 | 2216 | * @since 1.0.19 |
| 2217 | 2217 | * @param string $value first name. |
| 2218 | 2218 | */ |
| 2219 | - public function set_customer_first_name( $value ) { |
|
| 2220 | - $this->set_first_name( $value ); |
|
| 2219 | + public function set_customer_first_name($value) { |
|
| 2220 | + $this->set_first_name($value); |
|
| 2221 | 2221 | } |
| 2222 | 2222 | |
| 2223 | 2223 | /** |
@@ -2226,8 +2226,8 @@ discard block |
||
| 2226 | 2226 | * @since 1.0.19 |
| 2227 | 2227 | * @param string $value last name. |
| 2228 | 2228 | */ |
| 2229 | - public function set_last_name( $value ) { |
|
| 2230 | - $this->set_prop( 'last_name', $value ); |
|
| 2229 | + public function set_last_name($value) { |
|
| 2230 | + $this->set_prop('last_name', $value); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | /** |
@@ -2236,8 +2236,8 @@ discard block |
||
| 2236 | 2236 | * @since 1.0.19 |
| 2237 | 2237 | * @param string $value last name. |
| 2238 | 2238 | */ |
| 2239 | - public function set_user_last_name( $value ) { |
|
| 2240 | - $this->set_last_name( $value ); |
|
| 2239 | + public function set_user_last_name($value) { |
|
| 2240 | + $this->set_last_name($value); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | /** |
@@ -2246,8 +2246,8 @@ discard block |
||
| 2246 | 2246 | * @since 1.0.19 |
| 2247 | 2247 | * @param string $value last name. |
| 2248 | 2248 | */ |
| 2249 | - public function set_customer_last_name( $value ) { |
|
| 2250 | - $this->set_last_name( $value ); |
|
| 2249 | + public function set_customer_last_name($value) { |
|
| 2250 | + $this->set_last_name($value); |
|
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | /** |
@@ -2256,8 +2256,8 @@ discard block |
||
| 2256 | 2256 | * @since 1.0.19 |
| 2257 | 2257 | * @param string $value phone. |
| 2258 | 2258 | */ |
| 2259 | - public function set_phone( $value ) { |
|
| 2260 | - $this->set_prop( 'phone', $value ); |
|
| 2259 | + public function set_phone($value) { |
|
| 2260 | + $this->set_prop('phone', $value); |
|
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /** |
@@ -2266,8 +2266,8 @@ discard block |
||
| 2266 | 2266 | * @since 1.0.19 |
| 2267 | 2267 | * @param string $value phone. |
| 2268 | 2268 | */ |
| 2269 | - public function set_user_phone( $value ) { |
|
| 2270 | - $this->set_phone( $value ); |
|
| 2269 | + public function set_user_phone($value) { |
|
| 2270 | + $this->set_phone($value); |
|
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | 2273 | /** |
@@ -2276,8 +2276,8 @@ discard block |
||
| 2276 | 2276 | * @since 1.0.19 |
| 2277 | 2277 | * @param string $value phone. |
| 2278 | 2278 | */ |
| 2279 | - public function set_customer_phone( $value ) { |
|
| 2280 | - $this->set_phone( $value ); |
|
| 2279 | + public function set_customer_phone($value) { |
|
| 2280 | + $this->set_phone($value); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | /** |
@@ -2286,8 +2286,8 @@ discard block |
||
| 2286 | 2286 | * @since 1.0.19 |
| 2287 | 2287 | * @param string $value phone. |
| 2288 | 2288 | */ |
| 2289 | - public function set_phone_number( $value ) { |
|
| 2290 | - $this->set_phone( $value ); |
|
| 2289 | + public function set_phone_number($value) { |
|
| 2290 | + $this->set_phone($value); |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | /** |
@@ -2296,8 +2296,8 @@ discard block |
||
| 2296 | 2296 | * @since 1.0.19 |
| 2297 | 2297 | * @param string $value email address. |
| 2298 | 2298 | */ |
| 2299 | - public function set_email( $value ) { |
|
| 2300 | - $this->set_prop( 'email', $value ); |
|
| 2299 | + public function set_email($value) { |
|
| 2300 | + $this->set_prop('email', $value); |
|
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | 2303 | /** |
@@ -2306,8 +2306,8 @@ discard block |
||
| 2306 | 2306 | * @since 1.0.19 |
| 2307 | 2307 | * @param string $value email address. |
| 2308 | 2308 | */ |
| 2309 | - public function set_user_email( $value ) { |
|
| 2310 | - $this->set_email( $value ); |
|
| 2309 | + public function set_user_email($value) { |
|
| 2310 | + $this->set_email($value); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | |
| 2313 | 2313 | /** |
@@ -2316,8 +2316,8 @@ discard block |
||
| 2316 | 2316 | * @since 1.0.19 |
| 2317 | 2317 | * @param string $value email address. |
| 2318 | 2318 | */ |
| 2319 | - public function set_email_address( $value ) { |
|
| 2320 | - $this->set_email( $value ); |
|
| 2319 | + public function set_email_address($value) { |
|
| 2320 | + $this->set_email($value); |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | /** |
@@ -2326,8 +2326,8 @@ discard block |
||
| 2326 | 2326 | * @since 1.0.19 |
| 2327 | 2327 | * @param string $value email address. |
| 2328 | 2328 | */ |
| 2329 | - public function set_customer_email( $value ) { |
|
| 2330 | - $this->set_email( $value ); |
|
| 2329 | + public function set_customer_email($value) { |
|
| 2330 | + $this->set_email($value); |
|
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | /** |
@@ -2336,8 +2336,8 @@ discard block |
||
| 2336 | 2336 | * @since 1.0.19 |
| 2337 | 2337 | * @param string $value country. |
| 2338 | 2338 | */ |
| 2339 | - public function set_country( $value ) { |
|
| 2340 | - $this->set_prop( 'country', $value ); |
|
| 2339 | + public function set_country($value) { |
|
| 2340 | + $this->set_prop('country', $value); |
|
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | 2343 | /** |
@@ -2346,8 +2346,8 @@ discard block |
||
| 2346 | 2346 | * @since 1.0.19 |
| 2347 | 2347 | * @param string $value country. |
| 2348 | 2348 | */ |
| 2349 | - public function set_user_country( $value ) { |
|
| 2350 | - $this->set_country( $value ); |
|
| 2349 | + public function set_user_country($value) { |
|
| 2350 | + $this->set_country($value); |
|
| 2351 | 2351 | } |
| 2352 | 2352 | |
| 2353 | 2353 | /** |
@@ -2356,8 +2356,8 @@ discard block |
||
| 2356 | 2356 | * @since 1.0.19 |
| 2357 | 2357 | * @param string $value country. |
| 2358 | 2358 | */ |
| 2359 | - public function set_customer_country( $value ) { |
|
| 2360 | - $this->set_country( $value ); |
|
| 2359 | + public function set_customer_country($value) { |
|
| 2360 | + $this->set_country($value); |
|
| 2361 | 2361 | } |
| 2362 | 2362 | |
| 2363 | 2363 | /** |
@@ -2366,8 +2366,8 @@ discard block |
||
| 2366 | 2366 | * @since 1.0.19 |
| 2367 | 2367 | * @param string $value state. |
| 2368 | 2368 | */ |
| 2369 | - public function set_state( $value ) { |
|
| 2370 | - $this->set_prop( 'state', $value ); |
|
| 2369 | + public function set_state($value) { |
|
| 2370 | + $this->set_prop('state', $value); |
|
| 2371 | 2371 | } |
| 2372 | 2372 | |
| 2373 | 2373 | /** |
@@ -2376,8 +2376,8 @@ discard block |
||
| 2376 | 2376 | * @since 1.0.19 |
| 2377 | 2377 | * @param string $value state. |
| 2378 | 2378 | */ |
| 2379 | - public function set_user_state( $value ) { |
|
| 2380 | - $this->set_state( $value ); |
|
| 2379 | + public function set_user_state($value) { |
|
| 2380 | + $this->set_state($value); |
|
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | 2383 | /** |
@@ -2386,8 +2386,8 @@ discard block |
||
| 2386 | 2386 | * @since 1.0.19 |
| 2387 | 2387 | * @param string $value state. |
| 2388 | 2388 | */ |
| 2389 | - public function set_customer_state( $value ) { |
|
| 2390 | - $this->set_state( $value ); |
|
| 2389 | + public function set_customer_state($value) { |
|
| 2390 | + $this->set_state($value); |
|
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | 2393 | /** |
@@ -2396,8 +2396,8 @@ discard block |
||
| 2396 | 2396 | * @since 1.0.19 |
| 2397 | 2397 | * @param string $value city. |
| 2398 | 2398 | */ |
| 2399 | - public function set_city( $value ) { |
|
| 2400 | - $this->set_prop( 'city', $value ); |
|
| 2399 | + public function set_city($value) { |
|
| 2400 | + $this->set_prop('city', $value); |
|
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | /** |
@@ -2406,8 +2406,8 @@ discard block |
||
| 2406 | 2406 | * @since 1.0.19 |
| 2407 | 2407 | * @param string $value city. |
| 2408 | 2408 | */ |
| 2409 | - public function set_user_city( $value ) { |
|
| 2410 | - $this->set_city( $value ); |
|
| 2409 | + public function set_user_city($value) { |
|
| 2410 | + $this->set_city($value); |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | 2413 | /** |
@@ -2416,8 +2416,8 @@ discard block |
||
| 2416 | 2416 | * @since 1.0.19 |
| 2417 | 2417 | * @param string $value city. |
| 2418 | 2418 | */ |
| 2419 | - public function set_customer_city( $value ) { |
|
| 2420 | - $this->set_city( $value ); |
|
| 2419 | + public function set_customer_city($value) { |
|
| 2420 | + $this->set_city($value); |
|
| 2421 | 2421 | } |
| 2422 | 2422 | |
| 2423 | 2423 | /** |
@@ -2426,8 +2426,8 @@ discard block |
||
| 2426 | 2426 | * @since 1.0.19 |
| 2427 | 2427 | * @param string $value zip. |
| 2428 | 2428 | */ |
| 2429 | - public function set_zip( $value ) { |
|
| 2430 | - $this->set_prop( 'zip', $value ); |
|
| 2429 | + public function set_zip($value) { |
|
| 2430 | + $this->set_prop('zip', $value); |
|
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | /** |
@@ -2436,8 +2436,8 @@ discard block |
||
| 2436 | 2436 | * @since 1.0.19 |
| 2437 | 2437 | * @param string $value zip. |
| 2438 | 2438 | */ |
| 2439 | - public function set_user_zip( $value ) { |
|
| 2440 | - $this->set_zip( $value ); |
|
| 2439 | + public function set_user_zip($value) { |
|
| 2440 | + $this->set_zip($value); |
|
| 2441 | 2441 | } |
| 2442 | 2442 | |
| 2443 | 2443 | /** |
@@ -2446,8 +2446,8 @@ discard block |
||
| 2446 | 2446 | * @since 1.0.19 |
| 2447 | 2447 | * @param string $value zip. |
| 2448 | 2448 | */ |
| 2449 | - public function set_customer_zip( $value ) { |
|
| 2450 | - $this->set_zip( $value ); |
|
| 2449 | + public function set_customer_zip($value) { |
|
| 2450 | + $this->set_zip($value); |
|
| 2451 | 2451 | } |
| 2452 | 2452 | |
| 2453 | 2453 | /** |
@@ -2456,8 +2456,8 @@ discard block |
||
| 2456 | 2456 | * @since 1.0.19 |
| 2457 | 2457 | * @param string $value company. |
| 2458 | 2458 | */ |
| 2459 | - public function set_company( $value ) { |
|
| 2460 | - $this->set_prop( 'company', $value ); |
|
| 2459 | + public function set_company($value) { |
|
| 2460 | + $this->set_prop('company', $value); |
|
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | /** |
@@ -2466,8 +2466,8 @@ discard block |
||
| 2466 | 2466 | * @since 1.0.19 |
| 2467 | 2467 | * @param string $value company. |
| 2468 | 2468 | */ |
| 2469 | - public function set_user_company( $value ) { |
|
| 2470 | - $this->set_company( $value ); |
|
| 2469 | + public function set_user_company($value) { |
|
| 2470 | + $this->set_company($value); |
|
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | /** |
@@ -2476,8 +2476,8 @@ discard block |
||
| 2476 | 2476 | * @since 1.0.19 |
| 2477 | 2477 | * @param string $value company. |
| 2478 | 2478 | */ |
| 2479 | - public function set_customer_company( $value ) { |
|
| 2480 | - $this->set_company( $value ); |
|
| 2479 | + public function set_customer_company($value) { |
|
| 2480 | + $this->set_company($value); |
|
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | 2483 | /** |
@@ -2486,8 +2486,8 @@ discard block |
||
| 2486 | 2486 | * @since 1.0.19 |
| 2487 | 2487 | * @param string $value var number. |
| 2488 | 2488 | */ |
| 2489 | - public function set_vat_number( $value ) { |
|
| 2490 | - $this->set_prop( 'vat_number', $value ); |
|
| 2489 | + public function set_vat_number($value) { |
|
| 2490 | + $this->set_prop('vat_number', $value); |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
@@ -2496,8 +2496,8 @@ discard block |
||
| 2496 | 2496 | * @since 1.0.19 |
| 2497 | 2497 | * @param string $value var number. |
| 2498 | 2498 | */ |
| 2499 | - public function set_user_vat_number( $value ) { |
|
| 2500 | - $this->set_vat_number( $value ); |
|
| 2499 | + public function set_user_vat_number($value) { |
|
| 2500 | + $this->set_vat_number($value); |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | 2503 | /** |
@@ -2506,8 +2506,8 @@ discard block |
||
| 2506 | 2506 | * @since 1.0.19 |
| 2507 | 2507 | * @param string $value var number. |
| 2508 | 2508 | */ |
| 2509 | - public function set_customer_vat_number( $value ) { |
|
| 2510 | - $this->set_vat_number( $value ); |
|
| 2509 | + public function set_customer_vat_number($value) { |
|
| 2510 | + $this->set_vat_number($value); |
|
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | 2513 | /** |
@@ -2516,8 +2516,8 @@ discard block |
||
| 2516 | 2516 | * @since 1.0.19 |
| 2517 | 2517 | * @param string $value var rate. |
| 2518 | 2518 | */ |
| 2519 | - public function set_vat_rate( $value ) { |
|
| 2520 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2519 | + public function set_vat_rate($value) { |
|
| 2520 | + $this->set_prop('vat_rate', $value); |
|
| 2521 | 2521 | } |
| 2522 | 2522 | |
| 2523 | 2523 | /** |
@@ -2526,8 +2526,8 @@ discard block |
||
| 2526 | 2526 | * @since 1.0.19 |
| 2527 | 2527 | * @param string $value var number. |
| 2528 | 2528 | */ |
| 2529 | - public function set_user_vat_rate( $value ) { |
|
| 2530 | - $this->set_vat_rate( $value ); |
|
| 2529 | + public function set_user_vat_rate($value) { |
|
| 2530 | + $this->set_vat_rate($value); |
|
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | 2533 | /** |
@@ -2536,8 +2536,8 @@ discard block |
||
| 2536 | 2536 | * @since 1.0.19 |
| 2537 | 2537 | * @param string $value var number. |
| 2538 | 2538 | */ |
| 2539 | - public function set_customer_vat_rate( $value ) { |
|
| 2540 | - $this->set_vat_rate( $value ); |
|
| 2539 | + public function set_customer_vat_rate($value) { |
|
| 2540 | + $this->set_vat_rate($value); |
|
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | 2543 | /** |
@@ -2546,8 +2546,8 @@ discard block |
||
| 2546 | 2546 | * @since 1.0.19 |
| 2547 | 2547 | * @param string $value address. |
| 2548 | 2548 | */ |
| 2549 | - public function set_address( $value ) { |
|
| 2550 | - $this->set_prop( 'address', $value ); |
|
| 2549 | + public function set_address($value) { |
|
| 2550 | + $this->set_prop('address', $value); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | |
| 2553 | 2553 | /** |
@@ -2556,8 +2556,8 @@ discard block |
||
| 2556 | 2556 | * @since 1.0.19 |
| 2557 | 2557 | * @param string $value address. |
| 2558 | 2558 | */ |
| 2559 | - public function set_user_address( $value ) { |
|
| 2560 | - $this->set_address( $value ); |
|
| 2559 | + public function set_user_address($value) { |
|
| 2560 | + $this->set_address($value); |
|
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | /** |
@@ -2566,8 +2566,8 @@ discard block |
||
| 2566 | 2566 | * @since 1.0.19 |
| 2567 | 2567 | * @param string $value address. |
| 2568 | 2568 | */ |
| 2569 | - public function set_customer_address( $value ) { |
|
| 2570 | - $this->set_address( $value ); |
|
| 2569 | + public function set_customer_address($value) { |
|
| 2570 | + $this->set_address($value); |
|
| 2571 | 2571 | } |
| 2572 | 2572 | |
| 2573 | 2573 | /** |
@@ -2576,8 +2576,8 @@ discard block |
||
| 2576 | 2576 | * @since 1.0.19 |
| 2577 | 2577 | * @param int|bool $value confirmed. |
| 2578 | 2578 | */ |
| 2579 | - public function set_is_viewed( $value ) { |
|
| 2580 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2579 | + public function set_is_viewed($value) { |
|
| 2580 | + $this->set_prop('is_viewed', $value); |
|
| 2581 | 2581 | } |
| 2582 | 2582 | |
| 2583 | 2583 | /** |
@@ -2586,8 +2586,8 @@ discard block |
||
| 2586 | 2586 | * @since 1.0.19 |
| 2587 | 2587 | * @param string $value email recipients. |
| 2588 | 2588 | */ |
| 2589 | - public function set_email_cc( $value ) { |
|
| 2590 | - $this->set_prop( 'email_cc', $value ); |
|
| 2589 | + public function set_email_cc($value) { |
|
| 2590 | + $this->set_prop('email_cc', $value); |
|
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | /** |
@@ -2596,9 +2596,9 @@ discard block |
||
| 2596 | 2596 | * @since 1.0.19 |
| 2597 | 2597 | * @param string $value email recipients. |
| 2598 | 2598 | */ |
| 2599 | - public function set_template( $value ) { |
|
| 2600 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2601 | - $this->set_prop( 'template', $value ); |
|
| 2599 | + public function set_template($value) { |
|
| 2600 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2601 | + $this->set_prop('template', $value); |
|
| 2602 | 2602 | } |
| 2603 | 2603 | } |
| 2604 | 2604 | |
@@ -2608,8 +2608,8 @@ discard block |
||
| 2608 | 2608 | * @since 1.0.19 |
| 2609 | 2609 | * @param int|bool $value confirmed. |
| 2610 | 2610 | */ |
| 2611 | - public function set_address_confirmed( $value ) { |
|
| 2612 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2611 | + public function set_address_confirmed($value) { |
|
| 2612 | + $this->set_prop('address_confirmed', $value); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | |
| 2615 | 2615 | /** |
@@ -2618,8 +2618,8 @@ discard block |
||
| 2618 | 2618 | * @since 1.0.19 |
| 2619 | 2619 | * @param int|bool $value confirmed. |
| 2620 | 2620 | */ |
| 2621 | - public function set_user_address_confirmed( $value ) { |
|
| 2622 | - $this->set_address_confirmed( $value ); |
|
| 2621 | + public function set_user_address_confirmed($value) { |
|
| 2622 | + $this->set_address_confirmed($value); |
|
| 2623 | 2623 | } |
| 2624 | 2624 | |
| 2625 | 2625 | /** |
@@ -2628,8 +2628,8 @@ discard block |
||
| 2628 | 2628 | * @since 1.0.19 |
| 2629 | 2629 | * @param int|bool $value confirmed. |
| 2630 | 2630 | */ |
| 2631 | - public function set_customer_address_confirmed( $value ) { |
|
| 2632 | - $this->set_address_confirmed( $value ); |
|
| 2631 | + public function set_customer_address_confirmed($value) { |
|
| 2632 | + $this->set_address_confirmed($value); |
|
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | /** |
@@ -2638,8 +2638,8 @@ discard block |
||
| 2638 | 2638 | * @since 1.0.19 |
| 2639 | 2639 | * @param float $value sub total. |
| 2640 | 2640 | */ |
| 2641 | - public function set_subtotal( $value ) { |
|
| 2642 | - $this->set_prop( 'subtotal', $value ); |
|
| 2641 | + public function set_subtotal($value) { |
|
| 2642 | + $this->set_prop('subtotal', $value); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | /** |
@@ -2648,8 +2648,8 @@ discard block |
||
| 2648 | 2648 | * @since 1.0.19 |
| 2649 | 2649 | * @param float $value discount total. |
| 2650 | 2650 | */ |
| 2651 | - public function set_total_discount( $value ) { |
|
| 2652 | - $this->set_prop( 'total_discount', $value ); |
|
| 2651 | + public function set_total_discount($value) { |
|
| 2652 | + $this->set_prop('total_discount', $value); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | |
| 2655 | 2655 | /** |
@@ -2658,8 +2658,8 @@ discard block |
||
| 2658 | 2658 | * @since 1.0.19 |
| 2659 | 2659 | * @param float $value discount total. |
| 2660 | 2660 | */ |
| 2661 | - public function set_discount( $value ) { |
|
| 2662 | - $this->set_total_discount( $value ); |
|
| 2661 | + public function set_discount($value) { |
|
| 2662 | + $this->set_total_discount($value); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
@@ -2668,8 +2668,8 @@ discard block |
||
| 2668 | 2668 | * @since 1.0.19 |
| 2669 | 2669 | * @param float $value tax total. |
| 2670 | 2670 | */ |
| 2671 | - public function set_total_tax( $value ) { |
|
| 2672 | - $this->set_prop( 'total_tax', $value ); |
|
| 2671 | + public function set_total_tax($value) { |
|
| 2672 | + $this->set_prop('total_tax', $value); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
| 2678 | 2678 | * @since 1.0.19 |
| 2679 | 2679 | * @param float $value tax total. |
| 2680 | 2680 | */ |
| 2681 | - public function set_tax_total( $value ) { |
|
| 2682 | - $this->set_total_tax( $value ); |
|
| 2681 | + public function set_tax_total($value) { |
|
| 2682 | + $this->set_total_tax($value); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
@@ -2688,8 +2688,8 @@ discard block |
||
| 2688 | 2688 | * @since 1.0.19 |
| 2689 | 2689 | * @param float $value fees total. |
| 2690 | 2690 | */ |
| 2691 | - public function set_total_fees( $value ) { |
|
| 2692 | - $this->set_prop( 'total_fees', $value ); |
|
| 2691 | + public function set_total_fees($value) { |
|
| 2692 | + $this->set_prop('total_fees', $value); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
@@ -2698,8 +2698,8 @@ discard block |
||
| 2698 | 2698 | * @since 1.0.19 |
| 2699 | 2699 | * @param float $value fees total. |
| 2700 | 2700 | */ |
| 2701 | - public function set_fees_total( $value ) { |
|
| 2702 | - $this->set_total_fees( $value ); |
|
| 2701 | + public function set_fees_total($value) { |
|
| 2702 | + $this->set_total_fees($value); |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
@@ -2708,18 +2708,18 @@ discard block |
||
| 2708 | 2708 | * @since 1.0.19 |
| 2709 | 2709 | * @param array $value fees. |
| 2710 | 2710 | */ |
| 2711 | - public function set_fees( $value ) { |
|
| 2711 | + public function set_fees($value) { |
|
| 2712 | 2712 | |
| 2713 | - $this->set_prop( 'fees', array() ); |
|
| 2713 | + $this->set_prop('fees', array()); |
|
| 2714 | 2714 | |
| 2715 | 2715 | // Ensure that we have an array. |
| 2716 | - if ( ! is_array( $value ) ) { |
|
| 2716 | + if (!is_array($value)) { |
|
| 2717 | 2717 | return; |
| 2718 | 2718 | } |
| 2719 | 2719 | |
| 2720 | - foreach ( $value as $name => $data ) { |
|
| 2721 | - if ( isset( $data['amount'] ) ) { |
|
| 2722 | - $this->add_fee( $name, $data['amount'], $data['recurring'] ); |
|
| 2720 | + foreach ($value as $name => $data) { |
|
| 2721 | + if (isset($data['amount'])) { |
|
| 2722 | + $this->add_fee($name, $data['amount'], $data['recurring']); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | } |
| 2725 | 2725 | |
@@ -2731,8 +2731,8 @@ discard block |
||
| 2731 | 2731 | * @since 1.0.19 |
| 2732 | 2732 | * @param array $value taxes. |
| 2733 | 2733 | */ |
| 2734 | - public function set_taxes( $value ) { |
|
| 2735 | - $this->set_prop( 'taxes', $value ); |
|
| 2734 | + public function set_taxes($value) { |
|
| 2735 | + $this->set_prop('taxes', $value); |
|
| 2736 | 2736 | } |
| 2737 | 2737 | |
| 2738 | 2738 | /** |
@@ -2741,17 +2741,17 @@ discard block |
||
| 2741 | 2741 | * @since 1.0.19 |
| 2742 | 2742 | * @param array $value discounts. |
| 2743 | 2743 | */ |
| 2744 | - public function set_discounts( $value ) { |
|
| 2745 | - $this->set_prop( 'discounts', array() ); |
|
| 2744 | + public function set_discounts($value) { |
|
| 2745 | + $this->set_prop('discounts', array()); |
|
| 2746 | 2746 | |
| 2747 | 2747 | // Ensure that we have an array. |
| 2748 | - if ( ! is_array( $value ) ) { |
|
| 2748 | + if (!is_array($value)) { |
|
| 2749 | 2749 | return; |
| 2750 | 2750 | } |
| 2751 | 2751 | |
| 2752 | - foreach ( $value as $name => $data ) { |
|
| 2753 | - if ( isset( $data['amount'] ) ) { |
|
| 2754 | - $this->add_discount( $name, $data['amount'], $data['recurring'] ); |
|
| 2752 | + foreach ($value as $name => $data) { |
|
| 2753 | + if (isset($data['amount'])) { |
|
| 2754 | + $this->add_discount($name, $data['amount'], $data['recurring']); |
|
| 2755 | 2755 | } |
| 2756 | 2756 | } |
| 2757 | 2757 | } |
@@ -2762,18 +2762,18 @@ discard block |
||
| 2762 | 2762 | * @since 1.0.19 |
| 2763 | 2763 | * @param GetPaid_Form_Item[] $value items. |
| 2764 | 2764 | */ |
| 2765 | - public function set_items( $value ) { |
|
| 2765 | + public function set_items($value) { |
|
| 2766 | 2766 | |
| 2767 | 2767 | // Remove existing items. |
| 2768 | - $this->set_prop( 'items', array() ); |
|
| 2768 | + $this->set_prop('items', array()); |
|
| 2769 | 2769 | |
| 2770 | 2770 | // Ensure that we have an array. |
| 2771 | - if ( ! is_array( $value ) ) { |
|
| 2771 | + if (!is_array($value)) { |
|
| 2772 | 2772 | return; |
| 2773 | 2773 | } |
| 2774 | 2774 | |
| 2775 | - foreach ( $value as $item ) { |
|
| 2776 | - $this->add_item( $item ); |
|
| 2775 | + foreach ($value as $item) { |
|
| 2776 | + $this->add_item($item); |
|
| 2777 | 2777 | } |
| 2778 | 2778 | |
| 2779 | 2779 | } |
@@ -2784,8 +2784,8 @@ discard block |
||
| 2784 | 2784 | * @since 1.0.19 |
| 2785 | 2785 | * @param int $value payment form. |
| 2786 | 2786 | */ |
| 2787 | - public function set_payment_form( $value ) { |
|
| 2788 | - $this->set_prop( 'payment_form', $value ); |
|
| 2787 | + public function set_payment_form($value) { |
|
| 2788 | + $this->set_prop('payment_form', $value); |
|
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | /** |
@@ -2794,8 +2794,8 @@ discard block |
||
| 2794 | 2794 | * @since 1.0.19 |
| 2795 | 2795 | * @param string $value submission id. |
| 2796 | 2796 | */ |
| 2797 | - public function set_submission_id( $value ) { |
|
| 2798 | - $this->set_prop( 'submission_id', $value ); |
|
| 2797 | + public function set_submission_id($value) { |
|
| 2798 | + $this->set_prop('submission_id', $value); |
|
| 2799 | 2799 | } |
| 2800 | 2800 | |
| 2801 | 2801 | /** |
@@ -2804,8 +2804,8 @@ discard block |
||
| 2804 | 2804 | * @since 1.0.19 |
| 2805 | 2805 | * @param string $value discount code. |
| 2806 | 2806 | */ |
| 2807 | - public function set_discount_code( $value ) { |
|
| 2808 | - $this->set_prop( 'discount_code', $value ); |
|
| 2807 | + public function set_discount_code($value) { |
|
| 2808 | + $this->set_prop('discount_code', $value); |
|
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | 2811 | /** |
@@ -2814,8 +2814,8 @@ discard block |
||
| 2814 | 2814 | * @since 1.0.19 |
| 2815 | 2815 | * @param string $value gateway. |
| 2816 | 2816 | */ |
| 2817 | - public function set_gateway( $value ) { |
|
| 2818 | - $this->set_prop( 'gateway', $value ); |
|
| 2817 | + public function set_gateway($value) { |
|
| 2818 | + $this->set_prop('gateway', $value); |
|
| 2819 | 2819 | } |
| 2820 | 2820 | |
| 2821 | 2821 | /** |
@@ -2824,9 +2824,9 @@ discard block |
||
| 2824 | 2824 | * @since 1.0.19 |
| 2825 | 2825 | * @param string $value transaction id. |
| 2826 | 2826 | */ |
| 2827 | - public function set_transaction_id( $value ) { |
|
| 2828 | - if ( ! empty( $value ) ) { |
|
| 2829 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2827 | + public function set_transaction_id($value) { |
|
| 2828 | + if (!empty($value)) { |
|
| 2829 | + $this->set_prop('transaction_id', $value); |
|
| 2830 | 2830 | } |
| 2831 | 2831 | } |
| 2832 | 2832 | |
@@ -2836,8 +2836,8 @@ discard block |
||
| 2836 | 2836 | * @since 1.0.19 |
| 2837 | 2837 | * @param string $value currency id. |
| 2838 | 2838 | */ |
| 2839 | - public function set_currency( $value ) { |
|
| 2840 | - $this->set_prop( 'currency', $value ); |
|
| 2839 | + public function set_currency($value) { |
|
| 2840 | + $this->set_prop('currency', $value); |
|
| 2841 | 2841 | } |
| 2842 | 2842 | |
| 2843 | 2843 | /** |
@@ -2846,8 +2846,8 @@ discard block |
||
| 2846 | 2846 | * @since 1.0.19 |
| 2847 | 2847 | * @param bool $value value. |
| 2848 | 2848 | */ |
| 2849 | - public function set_disable_taxes( $value ) { |
|
| 2850 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2849 | + public function set_disable_taxes($value) { |
|
| 2850 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2851 | 2851 | } |
| 2852 | 2852 | |
| 2853 | 2853 | /** |
@@ -2856,8 +2856,8 @@ discard block |
||
| 2856 | 2856 | * @since 1.0.19 |
| 2857 | 2857 | * @param string $value subscription id. |
| 2858 | 2858 | */ |
| 2859 | - public function set_subscription_id( $value ) { |
|
| 2860 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2859 | + public function set_subscription_id($value) { |
|
| 2860 | + $this->set_prop('subscription_id', $value); |
|
| 2861 | 2861 | } |
| 2862 | 2862 | |
| 2863 | 2863 | /* |
@@ -2874,28 +2874,28 @@ discard block |
||
| 2874 | 2874 | */ |
| 2875 | 2875 | public function is_parent() { |
| 2876 | 2876 | $parent = $this->get_parent_id(); |
| 2877 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 2877 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 2878 | 2878 | } |
| 2879 | 2879 | |
| 2880 | 2880 | /** |
| 2881 | 2881 | * Checks if this is a renewal invoice. |
| 2882 | 2882 | */ |
| 2883 | 2883 | public function is_renewal() { |
| 2884 | - return ! $this->is_parent(); |
|
| 2884 | + return !$this->is_parent(); |
|
| 2885 | 2885 | } |
| 2886 | 2886 | |
| 2887 | 2887 | /** |
| 2888 | 2888 | * Checks if this is a recurring invoice. |
| 2889 | 2889 | */ |
| 2890 | 2890 | public function is_recurring() { |
| 2891 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 2891 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 2892 | 2892 | } |
| 2893 | 2893 | |
| 2894 | 2894 | /** |
| 2895 | 2895 | * Checks if this is a taxable invoice. |
| 2896 | 2896 | */ |
| 2897 | 2897 | public function is_taxable() { |
| 2898 | - return ! $this->get_disable_taxes(); |
|
| 2898 | + return !$this->get_disable_taxes(); |
|
| 2899 | 2899 | } |
| 2900 | 2900 | |
| 2901 | 2901 | /** |
@@ -2906,57 +2906,57 @@ discard block |
||
| 2906 | 2906 | |
| 2907 | 2907 | $requires_vat = false; |
| 2908 | 2908 | |
| 2909 | - if ( $this->country ) { |
|
| 2909 | + if ($this->country) { |
|
| 2910 | 2910 | $wpi_country = $this->country; |
| 2911 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
| 2911 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
| 2912 | 2912 | } |
| 2913 | 2913 | |
| 2914 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
| 2914 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
| 2915 | 2915 | } |
| 2916 | 2916 | |
| 2917 | 2917 | /** |
| 2918 | 2918 | * Checks to see if the invoice requires payment. |
| 2919 | 2919 | */ |
| 2920 | 2920 | public function is_free() { |
| 2921 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 2921 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 2922 | 2922 | |
| 2923 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2923 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 2924 | 2924 | $is_free = false; |
| 2925 | 2925 | } |
| 2926 | 2926 | |
| 2927 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2927 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2928 | 2928 | } |
| 2929 | 2929 | |
| 2930 | 2930 | /** |
| 2931 | 2931 | * Checks if the invoice is paid. |
| 2932 | 2932 | */ |
| 2933 | 2933 | public function is_paid() { |
| 2934 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 2935 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 2934 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 2935 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 2936 | 2936 | } |
| 2937 | 2937 | |
| 2938 | 2938 | /** |
| 2939 | 2939 | * Checks if the invoice needs payment. |
| 2940 | 2940 | */ |
| 2941 | 2941 | public function needs_payment() { |
| 2942 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2943 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 2942 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 2943 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | /** |
| 2947 | 2947 | * Checks if the invoice is refunded. |
| 2948 | 2948 | */ |
| 2949 | 2949 | public function is_refunded() { |
| 2950 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 2951 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 2950 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 2951 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | |
| 2954 | 2954 | /** |
| 2955 | 2955 | * Checks if the invoice is held. |
| 2956 | 2956 | */ |
| 2957 | 2957 | public function is_held() { |
| 2958 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
| 2959 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
| 2958 | + $is_held = $this->has_status('wpi-onhold'); |
|
| 2959 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
| 2960 | 2960 | } |
| 2961 | 2961 | |
| 2962 | 2962 | /** |
@@ -2964,30 +2964,30 @@ discard block |
||
| 2964 | 2964 | */ |
| 2965 | 2965 | public function is_due() { |
| 2966 | 2966 | $due_date = $this->get_due_date(); |
| 2967 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 2967 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 2968 | 2968 | } |
| 2969 | 2969 | |
| 2970 | 2970 | /** |
| 2971 | 2971 | * Checks if the invoice is draft. |
| 2972 | 2972 | */ |
| 2973 | 2973 | public function is_draft() { |
| 2974 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 2974 | + return $this->has_status('draft, auto-draft'); |
|
| 2975 | 2975 | } |
| 2976 | 2976 | |
| 2977 | 2977 | /** |
| 2978 | 2978 | * Checks if the invoice has a given status. |
| 2979 | 2979 | */ |
| 2980 | - public function has_status( $status ) { |
|
| 2981 | - $status = wpinv_parse_list( $status ); |
|
| 2982 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 2980 | + public function has_status($status) { |
|
| 2981 | + $status = wpinv_parse_list($status); |
|
| 2982 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 2983 | 2983 | } |
| 2984 | 2984 | |
| 2985 | 2985 | /** |
| 2986 | 2986 | * Checks if the invoice is of a given type. |
| 2987 | 2987 | */ |
| 2988 | - public function is_type( $type ) { |
|
| 2989 | - $type = wpinv_parse_list( $type ); |
|
| 2990 | - return in_array( $this->get_type(), $type ); |
|
| 2988 | + public function is_type($type) { |
|
| 2989 | + $type = wpinv_parse_list($type); |
|
| 2990 | + return in_array($this->get_type(), $type); |
|
| 2991 | 2991 | } |
| 2992 | 2992 | |
| 2993 | 2993 | /** |
@@ -3019,8 +3019,8 @@ discard block |
||
| 3019 | 3019 | * |
| 3020 | 3020 | */ |
| 3021 | 3021 | public function is_initial_free() { |
| 3022 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3023 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3022 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3023 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3024 | 3024 | } |
| 3025 | 3025 | |
| 3026 | 3026 | /** |
@@ -3030,11 +3030,11 @@ discard block |
||
| 3030 | 3030 | public function item_has_free_trial() { |
| 3031 | 3031 | |
| 3032 | 3032 | // Ensure we have a recurring item. |
| 3033 | - if ( ! $this->is_recurring() ) { |
|
| 3033 | + if (!$this->is_recurring()) { |
|
| 3034 | 3034 | return false; |
| 3035 | 3035 | } |
| 3036 | 3036 | |
| 3037 | - $item = $this->get_recurring( true ); |
|
| 3037 | + $item = $this->get_recurring(true); |
|
| 3038 | 3038 | return $item->has_free_trial(); |
| 3039 | 3039 | } |
| 3040 | 3040 | |
@@ -3042,7 +3042,7 @@ discard block |
||
| 3042 | 3042 | * Check if the free trial is a result of a discount. |
| 3043 | 3043 | */ |
| 3044 | 3044 | public function is_free_trial_from_discount() { |
| 3045 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3045 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3046 | 3046 | } |
| 3047 | 3047 | |
| 3048 | 3048 | /** |
@@ -3051,17 +3051,17 @@ discard block |
||
| 3051 | 3051 | public function discount_first_payment_only() { |
| 3052 | 3052 | |
| 3053 | 3053 | $discount_code = $this->get_discount_code(); |
| 3054 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
| 3054 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
| 3055 | 3055 | return true; |
| 3056 | 3056 | } |
| 3057 | 3057 | |
| 3058 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3058 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3059 | 3059 | |
| 3060 | - if ( ! $discount || ! $discount->exists() ) { |
|
| 3060 | + if (!$discount || !$discount->exists()) { |
|
| 3061 | 3061 | return true; |
| 3062 | 3062 | } |
| 3063 | 3063 | |
| 3064 | - return ! $discount->get_is_recurring(); |
|
| 3064 | + return !$discount->get_is_recurring(); |
|
| 3065 | 3065 | } |
| 3066 | 3066 | |
| 3067 | 3067 | /* |
@@ -3079,27 +3079,27 @@ discard block |
||
| 3079 | 3079 | * @param GetPaid_Form_Item|array $item |
| 3080 | 3080 | * @return WP_Error|Bool |
| 3081 | 3081 | */ |
| 3082 | - public function add_item( $item ) { |
|
| 3082 | + public function add_item($item) { |
|
| 3083 | 3083 | |
| 3084 | - if ( is_array( $item ) ) { |
|
| 3085 | - $item = $this->process_array_item( $item ); |
|
| 3084 | + if (is_array($item)) { |
|
| 3085 | + $item = $this->process_array_item($item); |
|
| 3086 | 3086 | } |
| 3087 | 3087 | |
| 3088 | - if ( is_numeric( $item ) ) { |
|
| 3089 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3088 | + if (is_numeric($item)) { |
|
| 3089 | + $item = new GetPaid_Form_Item($item); |
|
| 3090 | 3090 | } |
| 3091 | 3091 | |
| 3092 | 3092 | // Make sure that it is available for purchase. |
| 3093 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3094 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3093 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3094 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3095 | 3095 | } |
| 3096 | 3096 | |
| 3097 | 3097 | // Do we have a recurring item? |
| 3098 | - if ( $item->is_recurring() ) { |
|
| 3098 | + if ($item->is_recurring()) { |
|
| 3099 | 3099 | |
| 3100 | 3100 | // An invoice can only contain one recurring item. |
| 3101 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3102 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3101 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
| 3102 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
| 3103 | 3103 | } |
| 3104 | 3104 | |
| 3105 | 3105 | $this->recurring_item = $item->get_id(); |
@@ -3110,9 +3110,9 @@ discard block |
||
| 3110 | 3110 | |
| 3111 | 3111 | // Retrieve all items. |
| 3112 | 3112 | $items = $this->get_items(); |
| 3113 | - $items[ (int) $item->get_id() ] = $item; |
|
| 3113 | + $items[(int) $item->get_id()] = $item; |
|
| 3114 | 3114 | |
| 3115 | - $this->set_prop( 'items', $items ); |
|
| 3115 | + $this->set_prop('items', $items); |
|
| 3116 | 3116 | return true; |
| 3117 | 3117 | } |
| 3118 | 3118 | |
@@ -3122,26 +3122,26 @@ discard block |
||
| 3122 | 3122 | * @since 1.0.19 |
| 3123 | 3123 | * @return GetPaid_Form_Item |
| 3124 | 3124 | */ |
| 3125 | - protected function process_array_item( $array ) { |
|
| 3125 | + protected function process_array_item($array) { |
|
| 3126 | 3126 | |
| 3127 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3128 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3127 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
| 3128 | + $item = new GetPaid_Form_Item($item_id); |
|
| 3129 | 3129 | |
| 3130 | 3130 | // Set item data. |
| 3131 | - foreach( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3132 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3131 | + foreach (array('name', 'price', 'description') as $key) { |
|
| 3132 | + if (isset($array["item_$key"])) { |
|
| 3133 | 3133 | $method = "set_$key"; |
| 3134 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3134 | + $item->$method($array["item_$key"]); |
|
| 3135 | 3135 | } |
| 3136 | 3136 | } |
| 3137 | 3137 | |
| 3138 | - if ( isset( $array['quantity'] ) ) { |
|
| 3139 | - $item->set_quantity( $array['quantity'] ); |
|
| 3138 | + if (isset($array['quantity'])) { |
|
| 3139 | + $item->set_quantity($array['quantity']); |
|
| 3140 | 3140 | } |
| 3141 | 3141 | |
| 3142 | 3142 | // Set item meta. |
| 3143 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3144 | - $item->set_item_meta( $array['meta'] ); |
|
| 3143 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
| 3144 | + $item->set_item_meta($array['meta']); |
|
| 3145 | 3145 | } |
| 3146 | 3146 | |
| 3147 | 3147 | return $item; |
@@ -3153,10 +3153,10 @@ discard block |
||
| 3153 | 3153 | * |
| 3154 | 3154 | * @since 1.0.19 |
| 3155 | 3155 | */ |
| 3156 | - public function get_item( $item_id ) { |
|
| 3156 | + public function get_item($item_id) { |
|
| 3157 | 3157 | $items = $this->get_items(); |
| 3158 | 3158 | $item_id = (int) $item_id; |
| 3159 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3159 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
| 3160 | 3160 | } |
| 3161 | 3161 | |
| 3162 | 3162 | /** |
@@ -3164,17 +3164,17 @@ discard block |
||
| 3164 | 3164 | * |
| 3165 | 3165 | * @since 1.0.19 |
| 3166 | 3166 | */ |
| 3167 | - public function remove_item( $item_id ) { |
|
| 3167 | + public function remove_item($item_id) { |
|
| 3168 | 3168 | $items = $this->get_items(); |
| 3169 | 3169 | $item_id = (int) $item_id; |
| 3170 | 3170 | |
| 3171 | - if ( $item_id == $this->recurring_item ) { |
|
| 3171 | + if ($item_id == $this->recurring_item) { |
|
| 3172 | 3172 | $this->recurring_item = null; |
| 3173 | 3173 | } |
| 3174 | 3174 | |
| 3175 | - if ( isset( $items[ $item_id ] ) ) { |
|
| 3176 | - unset( $items[ $item_id ] ); |
|
| 3177 | - $this->set_prop( 'items', $items ); |
|
| 3175 | + if (isset($items[$item_id])) { |
|
| 3176 | + unset($items[$item_id]); |
|
| 3177 | + $this->set_prop('items', $items); |
|
| 3178 | 3178 | } |
| 3179 | 3179 | } |
| 3180 | 3180 | |
@@ -3185,27 +3185,27 @@ discard block |
||
| 3185 | 3185 | * @param float $value |
| 3186 | 3186 | * @return WP_Error|Bool |
| 3187 | 3187 | */ |
| 3188 | - public function add_fee( $fee, $value, $recurring = false ) { |
|
| 3188 | + public function add_fee($fee, $value, $recurring = false) { |
|
| 3189 | 3189 | |
| 3190 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3190 | + $amount = wpinv_sanitize_amount($value); |
|
| 3191 | 3191 | $fees = $this->get_fees(); |
| 3192 | 3192 | |
| 3193 | - if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
|
| 3193 | + if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) { |
|
| 3194 | 3194 | |
| 3195 | - $amount = $fees[ $fee ]['amount'] += $amount; |
|
| 3196 | - $fees[ $fee ] = array( |
|
| 3195 | + $amount = $fees[$fee]['amount'] += $amount; |
|
| 3196 | + $fees[$fee] = array( |
|
| 3197 | 3197 | 'amount' => $amount, |
| 3198 | 3198 | 'recurring' => (bool) $recurring, |
| 3199 | 3199 | ); |
| 3200 | 3200 | |
| 3201 | 3201 | } else { |
| 3202 | - $fees[ $fee ] = array( |
|
| 3202 | + $fees[$fee] = array( |
|
| 3203 | 3203 | 'amount' => $amount, |
| 3204 | 3204 | 'recurring' => (bool) $recurring, |
| 3205 | 3205 | ); |
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | - $this->set_prop( 'fees', $fee ); |
|
| 3208 | + $this->set_prop('fees', $fee); |
|
| 3209 | 3209 | |
| 3210 | 3210 | } |
| 3211 | 3211 | |
@@ -3214,9 +3214,9 @@ discard block |
||
| 3214 | 3214 | * |
| 3215 | 3215 | * @since 1.0.19 |
| 3216 | 3216 | */ |
| 3217 | - public function get_fee( $fee ) { |
|
| 3217 | + public function get_fee($fee) { |
|
| 3218 | 3218 | $fees = $this->get_fees(); |
| 3219 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3219 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3220 | 3220 | } |
| 3221 | 3221 | |
| 3222 | 3222 | /** |
@@ -3224,11 +3224,11 @@ discard block |
||
| 3224 | 3224 | * |
| 3225 | 3225 | * @since 1.0.19 |
| 3226 | 3226 | */ |
| 3227 | - public function remove_fee( $fee ) { |
|
| 3227 | + public function remove_fee($fee) { |
|
| 3228 | 3228 | $fees = $this->get_fees(); |
| 3229 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3230 | - unset( $fees[ $fee ] ); |
|
| 3231 | - $this->set_prop( 'fees', $fees ); |
|
| 3229 | + if (isset($fees[$fee])) { |
|
| 3230 | + unset($fees[$fee]); |
|
| 3231 | + $this->set_prop('fees', $fees); |
|
| 3232 | 3232 | } |
| 3233 | 3233 | } |
| 3234 | 3234 | |
@@ -3239,27 +3239,27 @@ discard block |
||
| 3239 | 3239 | * @param float $value |
| 3240 | 3240 | * @return WP_Error|Bool |
| 3241 | 3241 | */ |
| 3242 | - public function add_discount( $discount, $value, $recurring = false ) { |
|
| 3242 | + public function add_discount($discount, $value, $recurring = false) { |
|
| 3243 | 3243 | |
| 3244 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3244 | + $amount = wpinv_sanitize_amount($value); |
|
| 3245 | 3245 | $discounts = $this->get_discounts(); |
| 3246 | 3246 | |
| 3247 | - if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
|
| 3247 | + if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) { |
|
| 3248 | 3248 | |
| 3249 | - $amount = $discounts[ $discount ]['amount'] += $amount; |
|
| 3250 | - $discounts[ $discount ] = array( |
|
| 3249 | + $amount = $discounts[$discount]['amount'] += $amount; |
|
| 3250 | + $discounts[$discount] = array( |
|
| 3251 | 3251 | 'amount' => $amount, |
| 3252 | 3252 | 'recurring' => (bool) $recurring, |
| 3253 | 3253 | ); |
| 3254 | 3254 | |
| 3255 | 3255 | } else { |
| 3256 | - $discounts[ $discount ] = array( |
|
| 3256 | + $discounts[$discount] = array( |
|
| 3257 | 3257 | 'amount' => $amount, |
| 3258 | 3258 | 'recurring' => (bool) $recurring, |
| 3259 | 3259 | ); |
| 3260 | 3260 | } |
| 3261 | 3261 | |
| 3262 | - $this->set_prop( 'discounts', $discount ); |
|
| 3262 | + $this->set_prop('discounts', $discount); |
|
| 3263 | 3263 | |
| 3264 | 3264 | } |
| 3265 | 3265 | |
@@ -3268,15 +3268,15 @@ discard block |
||
| 3268 | 3268 | * |
| 3269 | 3269 | * @since 1.0.19 |
| 3270 | 3270 | */ |
| 3271 | - public function get_discount( $discount = false ) { |
|
| 3271 | + public function get_discount($discount = false) { |
|
| 3272 | 3272 | |
| 3273 | 3273 | // Backwards compatibilty. |
| 3274 | - if ( empty( $discount ) ) { |
|
| 3274 | + if (empty($discount)) { |
|
| 3275 | 3275 | return $this->get_total_discount(); |
| 3276 | 3276 | } |
| 3277 | 3277 | |
| 3278 | 3278 | $discounts = $this->get_discounts(); |
| 3279 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3279 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3280 | 3280 | } |
| 3281 | 3281 | |
| 3282 | 3282 | /** |
@@ -3284,11 +3284,11 @@ discard block |
||
| 3284 | 3284 | * |
| 3285 | 3285 | * @since 1.0.19 |
| 3286 | 3286 | */ |
| 3287 | - public function remove_discount( $discount ) { |
|
| 3287 | + public function remove_discount($discount) { |
|
| 3288 | 3288 | $discounts = $this->get_discounts(); |
| 3289 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3290 | - unset( $discounts[ $discount ] ); |
|
| 3291 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3289 | + if (isset($discounts[$discount])) { |
|
| 3290 | + unset($discounts[$discount]); |
|
| 3291 | + $this->set_prop('discounts', $discounts); |
|
| 3292 | 3292 | } |
| 3293 | 3293 | } |
| 3294 | 3294 | |
@@ -3298,31 +3298,31 @@ discard block |
||
| 3298 | 3298 | * @param string $tax |
| 3299 | 3299 | * @param float $value |
| 3300 | 3300 | */ |
| 3301 | - public function add_tax( $tax, $value, $recurring = true ) { |
|
| 3301 | + public function add_tax($tax, $value, $recurring = true) { |
|
| 3302 | 3302 | |
| 3303 | - if ( ! $this->is_taxable() ) { |
|
| 3303 | + if (!$this->is_taxable()) { |
|
| 3304 | 3304 | return; |
| 3305 | 3305 | } |
| 3306 | 3306 | |
| 3307 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3307 | + $amount = wpinv_sanitize_amount($value); |
|
| 3308 | 3308 | $taxes = $this->get_taxes(); |
| 3309 | 3309 | |
| 3310 | - if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
|
| 3310 | + if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) { |
|
| 3311 | 3311 | |
| 3312 | - $amount = $taxes[ $tax ]['amount'] += $amount; |
|
| 3313 | - $taxes[ $tax ] = array( |
|
| 3312 | + $amount = $taxes[$tax]['amount'] += $amount; |
|
| 3313 | + $taxes[$tax] = array( |
|
| 3314 | 3314 | 'amount' => $amount, |
| 3315 | 3315 | 'recurring' => (bool) $recurring, |
| 3316 | 3316 | ); |
| 3317 | 3317 | |
| 3318 | 3318 | } else { |
| 3319 | - $taxes[ $tax ] = array( |
|
| 3319 | + $taxes[$tax] = array( |
|
| 3320 | 3320 | 'amount' => $amount, |
| 3321 | 3321 | 'recurring' => (bool) $recurring, |
| 3322 | 3322 | ); |
| 3323 | 3323 | } |
| 3324 | 3324 | |
| 3325 | - $this->set_prop( 'taxes', $tax ); |
|
| 3325 | + $this->set_prop('taxes', $tax); |
|
| 3326 | 3326 | |
| 3327 | 3327 | } |
| 3328 | 3328 | |
@@ -3331,15 +3331,15 @@ discard block |
||
| 3331 | 3331 | * |
| 3332 | 3332 | * @since 1.0.19 |
| 3333 | 3333 | */ |
| 3334 | - public function get_tax( $tax = null ) { |
|
| 3334 | + public function get_tax($tax = null) { |
|
| 3335 | 3335 | |
| 3336 | 3336 | // Backwards compatility. |
| 3337 | - if ( empty( $tax ) ) { |
|
| 3337 | + if (empty($tax)) { |
|
| 3338 | 3338 | return $this->get_total_tax(); |
| 3339 | 3339 | } |
| 3340 | 3340 | |
| 3341 | 3341 | $taxes = $this->get_taxes(); |
| 3342 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3342 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3343 | 3343 | } |
| 3344 | 3344 | |
| 3345 | 3345 | /** |
@@ -3347,11 +3347,11 @@ discard block |
||
| 3347 | 3347 | * |
| 3348 | 3348 | * @since 1.0.19 |
| 3349 | 3349 | */ |
| 3350 | - public function remove_tax( $tax ) { |
|
| 3350 | + public function remove_tax($tax) { |
|
| 3351 | 3351 | $taxes = $this->get_discounts(); |
| 3352 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3353 | - unset( $taxes[ $tax ] ); |
|
| 3354 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3352 | + if (isset($taxes[$tax])) { |
|
| 3353 | + unset($taxes[$tax]); |
|
| 3354 | + $this->set_prop('taxes', $taxes); |
|
| 3355 | 3355 | } |
| 3356 | 3356 | } |
| 3357 | 3357 | |
@@ -3362,19 +3362,19 @@ discard block |
||
| 3362 | 3362 | * @return float The recalculated subtotal |
| 3363 | 3363 | */ |
| 3364 | 3364 | public function recalculate_subtotal() { |
| 3365 | - $items = $this->get_items(); |
|
| 3365 | + $items = $this->get_items(); |
|
| 3366 | 3366 | $subtotal = 0; |
| 3367 | 3367 | $recurring = 0; |
| 3368 | 3368 | |
| 3369 | - foreach ( $items as $item ) { |
|
| 3369 | + foreach ($items as $item) { |
|
| 3370 | 3370 | $subtotal += $item->get_sub_total(); |
| 3371 | 3371 | $recurring += $item->get_recurring_sub_total(); |
| 3372 | 3372 | } |
| 3373 | 3373 | |
| 3374 | - if ( $this->is_renewal() ) { |
|
| 3375 | - $this->set_subtotal( $recurring ); |
|
| 3374 | + if ($this->is_renewal()) { |
|
| 3375 | + $this->set_subtotal($recurring); |
|
| 3376 | 3376 | } else { |
| 3377 | - $this->set_subtotal( $subtotal ); |
|
| 3377 | + $this->set_subtotal($subtotal); |
|
| 3378 | 3378 | } |
| 3379 | 3379 | |
| 3380 | 3380 | $this->totals['subtotal'] = array( |
@@ -3396,9 +3396,9 @@ discard block |
||
| 3396 | 3396 | $discount = 0; |
| 3397 | 3397 | $recurring = 0; |
| 3398 | 3398 | |
| 3399 | - foreach ( $discounts as $data ) { |
|
| 3399 | + foreach ($discounts as $data) { |
|
| 3400 | 3400 | |
| 3401 | - if ( $data['recurring'] ) { |
|
| 3401 | + if ($data['recurring']) { |
|
| 3402 | 3402 | $recurring += $data['amount']; |
| 3403 | 3403 | } else { |
| 3404 | 3404 | $discount += $data['amount']; |
@@ -3406,10 +3406,10 @@ discard block |
||
| 3406 | 3406 | |
| 3407 | 3407 | } |
| 3408 | 3408 | |
| 3409 | - if ( $this->is_renewal() ) { |
|
| 3410 | - $this->set_total_discount( $recurring ); |
|
| 3409 | + if ($this->is_renewal()) { |
|
| 3410 | + $this->set_total_discount($recurring); |
|
| 3411 | 3411 | } else { |
| 3412 | - $this->set_total_discount( $discount ); |
|
| 3412 | + $this->set_total_discount($discount); |
|
| 3413 | 3413 | } |
| 3414 | 3414 | |
| 3415 | 3415 | $this->totals['discount'] = array( |
@@ -3428,13 +3428,13 @@ discard block |
||
| 3428 | 3428 | * @return float The recalculated tax |
| 3429 | 3429 | */ |
| 3430 | 3430 | public function recalculate_total_tax() { |
| 3431 | - $taxes = $this->get_taxes(); |
|
| 3431 | + $taxes = $this->get_taxes(); |
|
| 3432 | 3432 | $tax = 0; |
| 3433 | 3433 | $recurring = 0; |
| 3434 | 3434 | |
| 3435 | - foreach ( $taxes as $data ) { |
|
| 3435 | + foreach ($taxes as $data) { |
|
| 3436 | 3436 | |
| 3437 | - if ( $data['recurring'] ) { |
|
| 3437 | + if ($data['recurring']) { |
|
| 3438 | 3438 | $recurring += $data['amount']; |
| 3439 | 3439 | } else { |
| 3440 | 3440 | $tax += $data['amount']; |
@@ -3442,10 +3442,10 @@ discard block |
||
| 3442 | 3442 | |
| 3443 | 3443 | } |
| 3444 | 3444 | |
| 3445 | - if ( $this->is_renewal() ) { |
|
| 3446 | - $this->set_total_tax( $recurring ); |
|
| 3445 | + if ($this->is_renewal()) { |
|
| 3446 | + $this->set_total_tax($recurring); |
|
| 3447 | 3447 | } else { |
| 3448 | - $this->set_total_tax( $tax ); |
|
| 3448 | + $this->set_total_tax($tax); |
|
| 3449 | 3449 | } |
| 3450 | 3450 | |
| 3451 | 3451 | $this->totals['tax'] = array( |
@@ -3468,9 +3468,9 @@ discard block |
||
| 3468 | 3468 | $fee = 0; |
| 3469 | 3469 | $recurring = 0; |
| 3470 | 3470 | |
| 3471 | - foreach ( $fees as $data ) { |
|
| 3471 | + foreach ($fees as $data) { |
|
| 3472 | 3472 | |
| 3473 | - if ( $data['recurring'] ) { |
|
| 3473 | + if ($data['recurring']) { |
|
| 3474 | 3474 | $recurring += $data['amount']; |
| 3475 | 3475 | } else { |
| 3476 | 3476 | $fee += $data['amount']; |
@@ -3478,10 +3478,10 @@ discard block |
||
| 3478 | 3478 | |
| 3479 | 3479 | } |
| 3480 | 3480 | |
| 3481 | - if ( $this->is_renewal() ) { |
|
| 3482 | - $this->set_total_fees( $recurring ); |
|
| 3481 | + if ($this->is_renewal()) { |
|
| 3482 | + $this->set_total_fees($recurring); |
|
| 3483 | 3483 | } else { |
| 3484 | - $this->set_total_fees( $fee ); |
|
| 3484 | + $this->set_total_fees($fee); |
|
| 3485 | 3485 | } |
| 3486 | 3486 | |
| 3487 | 3487 | $this->totals['fee'] = array( |
@@ -3489,7 +3489,7 @@ discard block |
||
| 3489 | 3489 | 'recurring' => $recurring, |
| 3490 | 3490 | ); |
| 3491 | 3491 | |
| 3492 | - $this->set_total_fees( $fee ); |
|
| 3492 | + $this->set_total_fees($fee); |
|
| 3493 | 3493 | return $this->is_renewal() ? $recurring : $fee; |
| 3494 | 3494 | } |
| 3495 | 3495 | |
@@ -3510,9 +3510,9 @@ discard block |
||
| 3510 | 3510 | /** |
| 3511 | 3511 | * @deprecated |
| 3512 | 3512 | */ |
| 3513 | - public function recalculate_totals( $temp = false ) { |
|
| 3514 | - $this->update_items( $temp ); |
|
| 3515 | - $this->save( true ); |
|
| 3513 | + public function recalculate_totals($temp = false) { |
|
| 3514 | + $this->update_items($temp); |
|
| 3515 | + $this->save(true); |
|
| 3516 | 3516 | return $this; |
| 3517 | 3517 | } |
| 3518 | 3518 | |
@@ -3529,33 +3529,33 @@ discard block |
||
| 3529 | 3529 | * @param string $note The note being added. |
| 3530 | 3530 | * |
| 3531 | 3531 | */ |
| 3532 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3532 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3533 | 3533 | |
| 3534 | 3534 | // Bail if no note specified or this invoice is not yet saved. |
| 3535 | - if ( ! $note || $this->get_id() == 0 ) { |
|
| 3535 | + if (!$note || $this->get_id() == 0) { |
|
| 3536 | 3536 | return false; |
| 3537 | 3537 | } |
| 3538 | 3538 | |
| 3539 | - if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) { |
|
| 3540 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3539 | + if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) { |
|
| 3540 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3541 | 3541 | $comment_author = $user->display_name; |
| 3542 | 3542 | $comment_author_email = $user->user_email; |
| 3543 | 3543 | } else { |
| 3544 | 3544 | $comment_author = 'System'; |
| 3545 | 3545 | $comment_author_email = 'system@'; |
| 3546 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
| 3547 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
| 3546 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
| 3547 | + $comment_author_email = sanitize_email($comment_author_email); |
|
| 3548 | 3548 | } |
| 3549 | 3549 | |
| 3550 | - do_action( 'wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type ); |
|
| 3550 | + do_action('wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type); |
|
| 3551 | 3551 | |
| 3552 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 3552 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 3553 | 3553 | 'comment_post_ID' => $this->get_id(), |
| 3554 | 3554 | 'comment_content' => $note, |
| 3555 | 3555 | 'comment_agent' => 'GetPaid', |
| 3556 | 3556 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 3557 | - 'comment_date' => current_time( 'mysql' ), |
|
| 3558 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 3557 | + 'comment_date' => current_time('mysql'), |
|
| 3558 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 3559 | 3559 | 'comment_approved' => 1, |
| 3560 | 3560 | 'comment_parent' => 0, |
| 3561 | 3561 | 'comment_author' => $comment_author, |
@@ -3563,13 +3563,13 @@ discard block |
||
| 3563 | 3563 | 'comment_author_url' => '', |
| 3564 | 3564 | 'comment_author_email' => $comment_author_email, |
| 3565 | 3565 | 'comment_type' => 'wpinv_note' |
| 3566 | - ) ) ); |
|
| 3566 | + ))); |
|
| 3567 | 3567 | |
| 3568 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->get_id(), $note ); |
|
| 3568 | + do_action('wpinv_insert_payment_note', $note_id, $this->get_id(), $note); |
|
| 3569 | 3569 | |
| 3570 | - if ( $customer_type ) { |
|
| 3571 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 3572 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->get_id(), 'user_note' => $note ) ); |
|
| 3570 | + if ($customer_type) { |
|
| 3571 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
| 3572 | + do_action('wpinv_new_customer_note', array('invoice_id' => $this->get_id(), 'user_note' => $note)); |
|
| 3573 | 3573 | } |
| 3574 | 3574 | |
| 3575 | 3575 | return $note_id; |
@@ -3578,10 +3578,10 @@ discard block |
||
| 3578 | 3578 | /** |
| 3579 | 3579 | * Generates a unique key for the invoice. |
| 3580 | 3580 | */ |
| 3581 | - public function generate_key( $string = '' ) { |
|
| 3582 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3581 | + public function generate_key($string = '') { |
|
| 3582 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3583 | 3583 | return strtolower( |
| 3584 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3584 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3585 | 3585 | ); |
| 3586 | 3586 | } |
| 3587 | 3587 | |
@@ -3591,11 +3591,11 @@ discard block |
||
| 3591 | 3591 | public function generate_number() { |
| 3592 | 3592 | $number = $this->get_id(); |
| 3593 | 3593 | |
| 3594 | - if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) { |
|
| 3595 | - $number = wpinv_get_next_invoice_number( $this->post_type ); |
|
| 3594 | + if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) { |
|
| 3595 | + $number = wpinv_get_next_invoice_number($this->post_type); |
|
| 3596 | 3596 | } |
| 3597 | 3597 | |
| 3598 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3598 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
| 3599 | 3599 | |
| 3600 | 3600 | return $number; |
| 3601 | 3601 | } |
@@ -3609,47 +3609,47 @@ discard block |
||
| 3609 | 3609 | // Reset status transition variable. |
| 3610 | 3610 | $this->status_transition = false; |
| 3611 | 3611 | |
| 3612 | - if ( $status_transition ) { |
|
| 3612 | + if ($status_transition) { |
|
| 3613 | 3613 | try { |
| 3614 | 3614 | |
| 3615 | 3615 | // Fire a hook for the status change. |
| 3616 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3616 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
| 3617 | 3617 | |
| 3618 | 3618 | // @deprecated this is deprecated and will be removed in the future. |
| 3619 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3619 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3620 | 3620 | |
| 3621 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3621 | + if (!empty($status_transition['from'])) { |
|
| 3622 | 3622 | |
| 3623 | 3623 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3624 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3624 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
| 3625 | 3625 | |
| 3626 | 3626 | // Fire another hook. |
| 3627 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3628 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3627 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
| 3628 | + do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this); |
|
| 3629 | 3629 | |
| 3630 | 3630 | // @deprecated this is deprecated and will be removed in the future. |
| 3631 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3631 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3632 | 3632 | |
| 3633 | 3633 | // Note the transition occurred. |
| 3634 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3634 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3635 | 3635 | |
| 3636 | 3636 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3637 | 3637 | if ( |
| 3638 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
| 3639 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3638 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true) |
|
| 3639 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3640 | 3640 | ) { |
| 3641 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3641 | + do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition); |
|
| 3642 | 3642 | } |
| 3643 | 3643 | } else { |
| 3644 | 3644 | /* translators: %s: new invoice status */ |
| 3645 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3645 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
| 3646 | 3646 | |
| 3647 | 3647 | // Note the transition occurred. |
| 3648 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3648 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3649 | 3649 | |
| 3650 | 3650 | } |
| 3651 | - } catch ( Exception $e ) { |
|
| 3652 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3651 | + } catch (Exception $e) { |
|
| 3652 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3653 | 3653 | } |
| 3654 | 3654 | } |
| 3655 | 3655 | } |
@@ -3657,13 +3657,13 @@ discard block |
||
| 3657 | 3657 | /** |
| 3658 | 3658 | * Updates an invoice status. |
| 3659 | 3659 | */ |
| 3660 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3660 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3661 | 3661 | |
| 3662 | 3662 | // Fires before updating a status. |
| 3663 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3663 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3664 | 3664 | |
| 3665 | 3665 | // Update the status. |
| 3666 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3666 | + $this->set_status($new_status, $note, $manual); |
|
| 3667 | 3667 | |
| 3668 | 3668 | // Save the order. |
| 3669 | 3669 | return $this->save(); |
@@ -3674,18 +3674,18 @@ discard block |
||
| 3674 | 3674 | * @deprecated |
| 3675 | 3675 | */ |
| 3676 | 3676 | public function refresh_item_ids() { |
| 3677 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
| 3678 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3677 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
| 3678 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3679 | 3679 | } |
| 3680 | 3680 | |
| 3681 | 3681 | /** |
| 3682 | 3682 | * @deprecated |
| 3683 | 3683 | */ |
| 3684 | - public function update_items( $temp = false ) { |
|
| 3684 | + public function update_items($temp = false) { |
|
| 3685 | 3685 | |
| 3686 | - $this->set_items( $this->get_items() ); |
|
| 3686 | + $this->set_items($this->get_items()); |
|
| 3687 | 3687 | |
| 3688 | - if ( ! $temp ) { |
|
| 3688 | + if (!$temp) { |
|
| 3689 | 3689 | $this->save(); |
| 3690 | 3690 | } |
| 3691 | 3691 | |
@@ -3699,11 +3699,11 @@ discard block |
||
| 3699 | 3699 | |
| 3700 | 3700 | $discount_code = $this->get_discount_code(); |
| 3701 | 3701 | |
| 3702 | - if ( empty( $discount_code ) ) { |
|
| 3702 | + if (empty($discount_code)) { |
|
| 3703 | 3703 | return false; |
| 3704 | 3704 | } |
| 3705 | 3705 | |
| 3706 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3706 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3707 | 3707 | |
| 3708 | 3708 | // Ensure it is active. |
| 3709 | 3709 | return $discount->exists(); |
@@ -3714,7 +3714,7 @@ discard block |
||
| 3714 | 3714 | * Refunds an invoice. |
| 3715 | 3715 | */ |
| 3716 | 3716 | public function refund() { |
| 3717 | - $this->set_status( 'wpi-refunded' ); |
|
| 3717 | + $this->set_status('wpi-refunded'); |
|
| 3718 | 3718 | $this->save(); |
| 3719 | 3719 | } |
| 3720 | 3720 | |
@@ -3723,56 +3723,56 @@ discard block |
||
| 3723 | 3723 | * |
| 3724 | 3724 | * @param string $transaction_id |
| 3725 | 3725 | */ |
| 3726 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3726 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3727 | 3727 | |
| 3728 | 3728 | // Set the transaction id. |
| 3729 | - if ( empty( $transaction_id ) ) { |
|
| 3729 | + if (empty($transaction_id)) { |
|
| 3730 | 3730 | $transaction_id = $this->generate_key('trans_'); |
| 3731 | 3731 | } |
| 3732 | 3732 | |
| 3733 | - if ( ! $this->get_transaction_id() ) { |
|
| 3734 | - $this->set_transaction_id( $transaction_id ); |
|
| 3733 | + if (!$this->get_transaction_id()) { |
|
| 3734 | + $this->set_transaction_id($transaction_id); |
|
| 3735 | 3735 | } |
| 3736 | 3736 | |
| 3737 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3737 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3738 | 3738 | return $this->save(); |
| 3739 | 3739 | } |
| 3740 | 3740 | |
| 3741 | 3741 | // Set the completed date. |
| 3742 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3742 | + $this->set_date_completed(current_time('mysql')); |
|
| 3743 | 3743 | |
| 3744 | 3744 | // Set the new status. |
| 3745 | - if ( $this->is_renewal() ) { |
|
| 3745 | + if ($this->is_renewal()) { |
|
| 3746 | 3746 | |
| 3747 | 3747 | $_note = sprintf( |
| 3748 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3749 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3748 | + __('Renewed via %s', 'invoicing'), |
|
| 3749 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3750 | 3750 | ); |
| 3751 | 3751 | |
| 3752 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3752 | + if ('none' == $this->get_gateway()) { |
|
| 3753 | 3753 | $_note = $note; |
| 3754 | 3754 | } |
| 3755 | 3755 | |
| 3756 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3756 | + $this->set_status('wpi-renewal', $_note); |
|
| 3757 | 3757 | |
| 3758 | 3758 | } else { |
| 3759 | 3759 | |
| 3760 | 3760 | $_note = sprintf( |
| 3761 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3762 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3761 | + __('Paid via %s', 'invoicing'), |
|
| 3762 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3763 | 3763 | ); |
| 3764 | 3764 | |
| 3765 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3765 | + if ('none' == $this->get_gateway()) { |
|
| 3766 | 3766 | $_note = $note; |
| 3767 | 3767 | } |
| 3768 | 3768 | |
| 3769 | - $this->set_status( 'publish',$_note ); |
|
| 3769 | + $this->set_status('publish', $_note); |
|
| 3770 | 3770 | |
| 3771 | 3771 | } |
| 3772 | 3772 | |
| 3773 | 3773 | // Set checkout mode. |
| 3774 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3775 | - $this->set_mode( $mode ); |
|
| 3774 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3775 | + $this->set_mode($mode); |
|
| 3776 | 3776 | |
| 3777 | 3777 | // Save the invoice. |
| 3778 | 3778 | $this->save(); |
@@ -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,32 +95,32 @@ 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 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * Retrieves the default currency code. |
| 130 | 130 | */ |
| 131 | 131 | function wpinv_get_currency() { |
| 132 | - return apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
| 132 | + return apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,61 +137,61 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @param string|null $currency The currency code. Defaults to the default currency. |
| 139 | 139 | */ |
| 140 | -function wpinv_currency_symbol( $currency = null ) { |
|
| 140 | +function wpinv_currency_symbol($currency = null) { |
|
| 141 | 141 | |
| 142 | 142 | // Prepare the currency. |
| 143 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
| 143 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
| 144 | 144 | |
| 145 | 145 | // Fetch all symbols. |
| 146 | 146 | $symbols = wpinv_get_currency_symbols(); |
| 147 | 147 | |
| 148 | 148 | // Fetch this currencies symbol. |
| 149 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 149 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 150 | 150 | |
| 151 | 151 | // Filter the symbol. |
| 152 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 152 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | function wpinv_currency_position() { |
| 156 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 156 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 157 | 157 | |
| 158 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 158 | + return apply_filters('wpinv_currency_position', $position); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | function wpinv_thousands_separator() { |
| 162 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 162 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
| 164 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function wpinv_decimal_separator() { |
| 168 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 168 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
| 169 | 169 | |
| 170 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
| 170 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | function wpinv_decimals() { |
| 174 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
| 174 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
| 175 | 175 | |
| 176 | - return absint( $decimals ); |
|
| 176 | + return absint($decimals); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * Retrieves a list of all supported currencies. |
| 181 | 181 | */ |
| 182 | 182 | function wpinv_get_currencies() { |
| 183 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
| 183 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * Retrieves a list of all currency symbols. |
| 188 | 188 | */ |
| 189 | 189 | function wpinv_get_currency_symbols() { |
| 190 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
| 190 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
| 194 | - if( empty( $currency ) ) { |
|
| 193 | +function wpinv_price($amount = '', $currency = '') { |
|
| 194 | + if (empty($currency)) { |
|
| 195 | 195 | $currency = wpinv_get_currency(); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $negative = $amount < 0; |
| 201 | 201 | |
| 202 | - if ( $negative ) { |
|
| 203 | - $amount = substr( $amount, 1 ); |
|
| 202 | + if ($negative) { |
|
| 203 | + $amount = substr($amount, 1); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $symbol = wpinv_currency_symbol( $currency ); |
|
| 206 | + $symbol = wpinv_currency_symbol($currency); |
|
| 207 | 207 | |
| 208 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
| 209 | - switch ( $currency ) { |
|
| 208 | + if ($position == 'left' || $position == 'left_space') { |
|
| 209 | + switch ($currency) { |
|
| 210 | 210 | case "GBP" : |
| 211 | 211 | case "BRL" : |
| 212 | 212 | case "EUR" : |
@@ -218,15 +218,15 @@ discard block |
||
| 218 | 218 | case "NZD" : |
| 219 | 219 | case "SGD" : |
| 220 | 220 | case "JPY" : |
| 221 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 221 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 222 | 222 | break; |
| 223 | 223 | default : |
| 224 | 224 | //$price = $currency . ' ' . $amount; |
| 225 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 225 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 226 | 226 | break; |
| 227 | 227 | } |
| 228 | 228 | } else { |
| 229 | - switch ( $currency ) { |
|
| 229 | + switch ($currency) { |
|
| 230 | 230 | case "GBP" : |
| 231 | 231 | case "BRL" : |
| 232 | 232 | case "EUR" : |
@@ -237,83 +237,83 @@ discard block |
||
| 237 | 237 | case "MXN" : |
| 238 | 238 | case "SGD" : |
| 239 | 239 | case "JPY" : |
| 240 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 240 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 241 | 241 | break; |
| 242 | 242 | default : |
| 243 | 243 | //$price = $amount . ' ' . $currency; |
| 244 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 244 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 245 | 245 | break; |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( $negative ) { |
|
| 249 | + if ($negative) { |
|
| 250 | 250 | $price = '-' . $price; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
| 253 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
| 254 | 254 | |
| 255 | 255 | return $price; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
| 258 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
| 259 | 259 | $thousands_sep = wpinv_thousands_separator(); |
| 260 | 260 | $decimal_sep = wpinv_decimal_separator(); |
| 261 | 261 | |
| 262 | - if ( $decimals === NULL ) { |
|
| 262 | + if ($decimals === NULL) { |
|
| 263 | 263 | $decimals = wpinv_decimals(); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 267 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 268 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 266 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 267 | + $whole = substr($amount, 0, $sep_found); |
|
| 268 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 269 | 269 | $amount = $whole . '.' . $part; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 273 | - $amount = str_replace( ',', '', $amount ); |
|
| 272 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 273 | + $amount = str_replace(',', '', $amount); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 277 | - $amount = str_replace( ' ', '', $amount ); |
|
| 276 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 277 | + $amount = str_replace(' ', '', $amount); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( empty( $amount ) ) { |
|
| 280 | + if (empty($amount)) { |
|
| 281 | 281 | $amount = 0; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
| 285 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 284 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
| 285 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 286 | 286 | |
| 287 | - if ( $calculate ) { |
|
| 288 | - if ( $thousands_sep === "," ) { |
|
| 289 | - $formatted = str_replace( ",", "", $formatted ); |
|
| 287 | + if ($calculate) { |
|
| 288 | + if ($thousands_sep === ",") { |
|
| 289 | + $formatted = str_replace(",", "", $formatted); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if ( $decimal_sep === "," ) { |
|
| 293 | - $formatted = str_replace( ",", ".", $formatted ); |
|
| 292 | + if ($decimal_sep === ",") { |
|
| 293 | + $formatted = str_replace(",", ".", $formatted); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
| 297 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
| 298 | 298 | } |
| 299 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 299 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 300 | 300 | |
| 301 | -function wpinv_sanitize_key( $key ) { |
|
| 301 | +function wpinv_sanitize_key($key) { |
|
| 302 | 302 | $raw_key = $key; |
| 303 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 303 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 304 | 304 | |
| 305 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 305 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | -function wpinv_get_file_extension( $str ) { |
|
| 309 | - $parts = explode( '.', $str ); |
|
| 310 | - return end( $parts ); |
|
| 308 | +function wpinv_get_file_extension($str) { |
|
| 309 | + $parts = explode('.', $str); |
|
| 310 | + return end($parts); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | -function wpinv_string_is_image_url( $str ) { |
|
| 314 | - $ext = wpinv_get_file_extension( $str ); |
|
| 313 | +function wpinv_string_is_image_url($str) { |
|
| 314 | + $ext = wpinv_get_file_extension($str); |
|
| 315 | 315 | |
| 316 | - switch ( strtolower( $ext ) ) { |
|
| 316 | + switch (strtolower($ext)) { |
|
| 317 | 317 | case 'jpeg'; |
| 318 | 318 | case 'jpg'; |
| 319 | 319 | $return = true; |
@@ -329,33 +329,33 @@ discard block |
||
| 329 | 329 | break; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
| 332 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 336 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
| 335 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 336 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
| 337 | 337 | |
| 338 | - if ( true === $should_log ) { |
|
| 338 | + if (true === $should_log) { |
|
| 339 | 339 | $label = ''; |
| 340 | - if ( $file && $file !== '' ) { |
|
| 341 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
| 340 | + if ($file && $file !== '') { |
|
| 341 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( $title && $title !== '' ) { |
|
| 344 | + if ($title && $title !== '') { |
|
| 345 | 345 | $label = $label !== '' ? $label . ' ' : ''; |
| 346 | 346 | $label .= $title . ' '; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
| 349 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
| 350 | 350 | |
| 351 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
| 352 | - error_log( $label . print_r( $log, true ) ); |
|
| 351 | + if (is_array($log) || is_object($log)) { |
|
| 352 | + error_log($label . print_r($log, true)); |
|
| 353 | 353 | } else { |
| 354 | - error_log( $label . $log ); |
|
| 354 | + error_log($label . $log); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - error_log( wp_debug_backtrace_summary() ); |
|
| 358 | - if ( $exit ) { |
|
| 357 | + error_log(wp_debug_backtrace_summary()); |
|
| 358 | + if ($exit) { |
|
| 359 | 359 | exit; |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -363,32 +363,32 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | function wpinv_is_ajax_disabled() { |
| 365 | 365 | $retval = false; |
| 366 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
| 366 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
| 369 | +function wpinv_get_current_page_url($nocache = false) { |
|
| 370 | 370 | global $wp; |
| 371 | 371 | |
| 372 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 373 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 372 | + if (get_option('permalink_structure')) { |
|
| 373 | + $base = trailingslashit(home_url($wp->request)); |
|
| 374 | 374 | } else { |
| 375 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 376 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 375 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 376 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $scheme = is_ssl() ? 'https' : 'http'; |
| 380 | - $uri = set_url_scheme( $base, $scheme ); |
|
| 380 | + $uri = set_url_scheme($base, $scheme); |
|
| 381 | 381 | |
| 382 | - if ( is_front_page() ) { |
|
| 383 | - $uri = home_url( '/' ); |
|
| 384 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
| 382 | + if (is_front_page()) { |
|
| 383 | + $uri = home_url('/'); |
|
| 384 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
| 385 | 385 | $uri = wpinv_get_checkout_uri(); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
| 388 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
| 389 | 389 | |
| 390 | - if ( $nocache ) { |
|
| 391 | - $uri = wpinv_add_cache_busting( $uri ); |
|
| 390 | + if ($nocache) { |
|
| 391 | + $uri = wpinv_add_cache_busting($uri); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | return $uri; |
@@ -401,46 +401,46 @@ discard block |
||
| 401 | 401 | * @param string $name Constant name. |
| 402 | 402 | * @param mixed $value Value. |
| 403 | 403 | */ |
| 404 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
| 405 | - if ( ! defined( $name ) ) { |
|
| 406 | - define( $name, $value ); |
|
| 404 | +function getpaid_maybe_define_constant($name, $value) { |
|
| 405 | + if (!defined($name)) { |
|
| 406 | + define($name, $value); |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | function wpinv_get_php_arg_separator_output() { |
| 411 | - return ini_get( 'arg_separator.output' ); |
|
| 411 | + return ini_get('arg_separator.output'); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | -function wpinv_rgb_from_hex( $color ) { |
|
| 415 | - $color = str_replace( '#', '', $color ); |
|
| 414 | +function wpinv_rgb_from_hex($color) { |
|
| 415 | + $color = str_replace('#', '', $color); |
|
| 416 | 416 | |
| 417 | 417 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 418 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 419 | - if ( empty( $color ) ) { |
|
| 418 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 419 | + if (empty($color)) { |
|
| 420 | 420 | return NULL; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $color = str_split( $color ); |
|
| 423 | + $color = str_split($color); |
|
| 424 | 424 | |
| 425 | 425 | $rgb = array(); |
| 426 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
| 427 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
| 428 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
| 426 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
| 427 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
| 428 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
| 429 | 429 | |
| 430 | 430 | return $rgb; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 434 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 433 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 434 | + $base = wpinv_rgb_from_hex($color); |
|
| 435 | 435 | $color = '#'; |
| 436 | 436 | |
| 437 | - foreach ( $base as $k => $v ) { |
|
| 437 | + foreach ($base as $k => $v) { |
|
| 438 | 438 | $amount = $v / 100; |
| 439 | - $amount = round( $amount * $factor ); |
|
| 439 | + $amount = round($amount * $factor); |
|
| 440 | 440 | $new_decimal = $v - $amount; |
| 441 | 441 | |
| 442 | - $new_hex_component = dechex( $new_decimal ); |
|
| 443 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 442 | + $new_hex_component = dechex($new_decimal); |
|
| 443 | + if (strlen($new_hex_component) < 2) { |
|
| 444 | 444 | $new_hex_component = "0" . $new_hex_component; |
| 445 | 445 | } |
| 446 | 446 | $color .= $new_hex_component; |
@@ -449,18 +449,18 @@ discard block |
||
| 449 | 449 | return $color; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 453 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 452 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 453 | + $base = wpinv_rgb_from_hex($color); |
|
| 454 | 454 | $color = '#'; |
| 455 | 455 | |
| 456 | - foreach ( $base as $k => $v ) { |
|
| 456 | + foreach ($base as $k => $v) { |
|
| 457 | 457 | $amount = 255 - $v; |
| 458 | 458 | $amount = $amount / 100; |
| 459 | - $amount = round( $amount * $factor ); |
|
| 459 | + $amount = round($amount * $factor); |
|
| 460 | 460 | $new_decimal = $v + $amount; |
| 461 | 461 | |
| 462 | - $new_hex_component = dechex( $new_decimal ); |
|
| 463 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 462 | + $new_hex_component = dechex($new_decimal); |
|
| 463 | + if (strlen($new_hex_component) < 2) { |
|
| 464 | 464 | $new_hex_component = "0" . $new_hex_component; |
| 465 | 465 | } |
| 466 | 466 | $color .= $new_hex_component; |
@@ -469,22 +469,22 @@ discard block |
||
| 469 | 469 | return $color; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 473 | - $hex = str_replace( '#', '', $color ); |
|
| 472 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 473 | + $hex = str_replace('#', '', $color); |
|
| 474 | 474 | |
| 475 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 476 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 477 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 475 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 476 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 477 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 478 | 478 | |
| 479 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 479 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 480 | 480 | |
| 481 | 481 | return $brightness > 155 ? $dark : $light; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | -function wpinv_format_hex( $hex ) { |
|
| 485 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 484 | +function wpinv_format_hex($hex) { |
|
| 485 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 486 | 486 | |
| 487 | - if ( strlen( $hex ) == 3 ) { |
|
| 487 | + if (strlen($hex) == 3) { |
|
| 488 | 488 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 505 | 505 | * @return string |
| 506 | 506 | */ |
| 507 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 508 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 509 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 507 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 508 | + if (function_exists('mb_strimwidth')) { |
|
| 509 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 512 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
@@ -521,28 +521,28 @@ discard block |
||
| 521 | 521 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 522 | 522 | * @return int Returns the number of characters in string. |
| 523 | 523 | */ |
| 524 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 525 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 526 | - return mb_strlen( $str, $encoding ); |
|
| 524 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 525 | + if (function_exists('mb_strlen')) { |
|
| 526 | + return mb_strlen($str, $encoding); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - return strlen( $str ); |
|
| 529 | + return strlen($str); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 533 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 534 | - return mb_strtolower( $str, $encoding ); |
|
| 532 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 533 | + if (function_exists('mb_strtolower')) { |
|
| 534 | + return mb_strtolower($str, $encoding); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - return strtolower( $str ); |
|
| 537 | + return strtolower($str); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 541 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 542 | - return mb_strtoupper( $str, $encoding ); |
|
| 540 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 541 | + if (function_exists('mb_strtoupper')) { |
|
| 542 | + return mb_strtoupper($str, $encoding); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - return strtoupper( $str ); |
|
| 545 | + return strtoupper($str); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -556,12 +556,12 @@ discard block |
||
| 556 | 556 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 557 | 557 | * @return int Returns the position of the first occurrence of search in the string. |
| 558 | 558 | */ |
| 559 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 560 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 561 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 559 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 560 | + if (function_exists('mb_strpos')) { |
|
| 561 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - return strpos( $str, $find, $offset ); |
|
| 564 | + return strpos($str, $find, $offset); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -575,12 +575,12 @@ discard block |
||
| 575 | 575 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 576 | 576 | * @return int Returns the position of the last occurrence of search. |
| 577 | 577 | */ |
| 578 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 579 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 580 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 578 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 579 | + if (function_exists('mb_strrpos')) { |
|
| 580 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - return strrpos( $str, $find, $offset ); |
|
| 583 | + return strrpos($str, $find, $offset); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -595,16 +595,16 @@ discard block |
||
| 595 | 595 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 596 | 596 | * @return string |
| 597 | 597 | */ |
| 598 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 599 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 600 | - if ( $length === null ) { |
|
| 601 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 598 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 599 | + if (function_exists('mb_substr')) { |
|
| 600 | + if ($length === null) { |
|
| 601 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 602 | 602 | } else { |
| 603 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 603 | + return mb_substr($str, $start, $length, $encoding); |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - return substr( $str, $start, $length ); |
|
| 607 | + return substr($str, $start, $length); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
@@ -616,48 +616,48 @@ discard block |
||
| 616 | 616 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 617 | 617 | * @return string The width of string. |
| 618 | 618 | */ |
| 619 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 620 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 621 | - return mb_strwidth( $str, $encoding ); |
|
| 619 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 620 | + if (function_exists('mb_strwidth')) { |
|
| 621 | + return mb_strwidth($str, $encoding); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 624 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 628 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 629 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 627 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 628 | + if (function_exists('mb_strlen')) { |
|
| 629 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 630 | 630 | $str_end = ""; |
| 631 | 631 | |
| 632 | - if ( $lower_str_end ) { |
|
| 633 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 632 | + if ($lower_str_end) { |
|
| 633 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 634 | 634 | } else { |
| 635 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 635 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | return $first_letter . $str_end; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - return ucfirst( $str ); |
|
| 641 | + return ucfirst($str); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 645 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 646 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 644 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 645 | + if (function_exists('mb_convert_case')) { |
|
| 646 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - return ucwords( $str ); |
|
| 649 | + return ucwords($str); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 653 | - $period = absint( $period ); |
|
| 652 | +function wpinv_period_in_days($period, $unit) { |
|
| 653 | + $period = absint($period); |
|
| 654 | 654 | |
| 655 | - if ( $period > 0 ) { |
|
| 656 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 655 | + if ($period > 0) { |
|
| 656 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 657 | 657 | $period = $period * 7; |
| 658 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 658 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 659 | 659 | $period = $period * 30; |
| 660 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 660 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 661 | 661 | $period = $period * 365; |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -665,14 +665,14 @@ discard block |
||
| 665 | 665 | return $period; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
| 669 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
| 670 | - return cal_days_in_month( $calendar, $month, $year ); |
|
| 668 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
| 669 | + if (function_exists('cal_days_in_month')) { |
|
| 670 | + return cal_days_in_month($calendar, $month, $year); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | // Fallback in case the calendar extension is not loaded in PHP |
| 674 | 674 | // Only supports Gregorian calendar |
| 675 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 675 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | * |
| 684 | 684 | * @return string |
| 685 | 685 | */ |
| 686 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
| 687 | - if ( $allow_html ) { |
|
| 688 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
| 686 | +function wpi_help_tip($tip, $allow_html = false) { |
|
| 687 | + if ($allow_html) { |
|
| 688 | + $tip = wpi_sanitize_tooltip($tip); |
|
| 689 | 689 | } else { |
| 690 | - $tip = esc_attr( $tip ); |
|
| 690 | + $tip = esc_attr($tip); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -701,8 +701,8 @@ discard block |
||
| 701 | 701 | * @param string $var |
| 702 | 702 | * @return string |
| 703 | 703 | */ |
| 704 | -function wpi_sanitize_tooltip( $var ) { |
|
| 705 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 704 | +function wpi_sanitize_tooltip($var) { |
|
| 705 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 706 | 706 | 'br' => array(), |
| 707 | 707 | 'em' => array(), |
| 708 | 708 | 'strong' => array(), |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | 'li' => array(), |
| 713 | 713 | 'ol' => array(), |
| 714 | 714 | 'p' => array(), |
| 715 | - ) ) ); |
|
| 715 | + ))); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | */ |
| 723 | 723 | function wpinv_get_screen_ids() { |
| 724 | 724 | |
| 725 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
| 725 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
| 726 | 726 | |
| 727 | 727 | $screen_ids = array( |
| 728 | 728 | 'toplevel_page_' . $screen_id, |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | 'invoicing_page_wpi-addons', |
| 741 | 741 | ); |
| 742 | 742 | |
| 743 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
| 743 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | /** |
@@ -751,14 +751,14 @@ discard block |
||
| 751 | 751 | * @param array|string $list List of values. |
| 752 | 752 | * @return array Sanitized array of values. |
| 753 | 753 | */ |
| 754 | -function wpinv_parse_list( $list ) { |
|
| 754 | +function wpinv_parse_list($list) { |
|
| 755 | 755 | |
| 756 | - if ( empty( $list ) ) { |
|
| 756 | + if (empty($list)) { |
|
| 757 | 757 | $list = array(); |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - if ( ! is_array( $list ) ) { |
|
| 761 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 760 | + if (!is_array($list)) { |
|
| 761 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | return $list; |
@@ -772,16 +772,16 @@ discard block |
||
| 772 | 772 | * @param string $key Type of data to fetch. |
| 773 | 773 | * @return mixed Fetched data. |
| 774 | 774 | */ |
| 775 | -function wpinv_get_data( $key ) { |
|
| 775 | +function wpinv_get_data($key) { |
|
| 776 | 776 | |
| 777 | 777 | // Try fetching it from the cache. |
| 778 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
| 779 | - if( $data ) { |
|
| 778 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
| 779 | + if ($data) { |
|
| 780 | 780 | return $data; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
| 784 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 783 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
| 784 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
| 785 | 785 | |
| 786 | 786 | return $data; |
| 787 | 787 | } |
@@ -795,10 +795,10 @@ discard block |
||
| 795 | 795 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 796 | 796 | * @return mixed Fetched data. |
| 797 | 797 | */ |
| 798 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
| 798 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
| 799 | 799 | |
| 800 | - if ( ! empty( $options ) && $first_empty ) { |
|
| 801 | - return array_merge( array( '' => '' ), $options ); |
|
| 800 | + if (!empty($options) && $first_empty) { |
|
| 801 | + return array_merge(array('' => ''), $options); |
|
| 802 | 802 | } |
| 803 | 803 | return $options; |
| 804 | 804 | |
@@ -810,21 +810,21 @@ discard block |
||
| 810 | 810 | * @param mixed $var Data to sanitize. |
| 811 | 811 | * @return string|array |
| 812 | 812 | */ |
| 813 | -function wpinv_clean( $var ) { |
|
| 813 | +function wpinv_clean($var) { |
|
| 814 | 814 | |
| 815 | - if ( is_array( $var ) ) { |
|
| 816 | - return array_map( 'wpinv_clean', $var ); |
|
| 815 | + if (is_array($var)) { |
|
| 816 | + return array_map('wpinv_clean', $var); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - if ( is_object( $var ) ) { |
|
| 820 | - $object_vars = get_object_vars( $var ); |
|
| 821 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 822 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 819 | + if (is_object($var)) { |
|
| 820 | + $object_vars = get_object_vars($var); |
|
| 821 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 822 | + $var->$property_name = wpinv_clean($property_value); |
|
| 823 | 823 | } |
| 824 | 824 | return $var; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 827 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | /** |
@@ -833,43 +833,43 @@ discard block |
||
| 833 | 833 | * @param string $str Data to convert. |
| 834 | 834 | * @return string|array |
| 835 | 835 | */ |
| 836 | -function getpaid_convert_price_string_to_options( $str ) { |
|
| 836 | +function getpaid_convert_price_string_to_options($str) { |
|
| 837 | 837 | |
| 838 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 839 | - $options = array(); |
|
| 838 | + $raw_options = array_map('trim', explode(',', $str)); |
|
| 839 | + $options = array(); |
|
| 840 | 840 | |
| 841 | - foreach ( $raw_options as $option ) { |
|
| 841 | + foreach ($raw_options as $option) { |
|
| 842 | 842 | |
| 843 | - if ( '' == $option ) { |
|
| 843 | + if ('' == $option) { |
|
| 844 | 844 | continue; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
| 847 | + $option = array_map('trim', explode('|', $option)); |
|
| 848 | 848 | |
| 849 | 849 | $price = null; |
| 850 | 850 | $label = null; |
| 851 | 851 | |
| 852 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
| 853 | - $label = $option[0]; |
|
| 852 | + if (isset($option[0]) && '' != $option[0]) { |
|
| 853 | + $label = $option[0]; |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
| 856 | + if (isset($option[1]) && '' != $option[1]) { |
|
| 857 | 857 | $price = $option[1]; |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - if ( ! isset( $price ) ) { |
|
| 860 | + if (!isset($price)) { |
|
| 861 | 861 | $price = $label; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
| 864 | + if (!isset($price) || !is_numeric($price)) { |
|
| 865 | 865 | continue; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - if ( ! isset( $label ) ) { |
|
| 868 | + if (!isset($label)) { |
|
| 869 | 869 | $label = $price; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - $options[ $price ] = $label; |
|
| 872 | + $options[$price] = $label; |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | return $options; |
@@ -878,23 +878,23 @@ discard block |
||
| 878 | 878 | /** |
| 879 | 879 | * Returns the help tip. |
| 880 | 880 | */ |
| 881 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
| 882 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
| 883 | - $tip = esc_attr__( $tip ); |
|
| 881 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
| 882 | + $additional_classes = sanitize_html_class($additional_classes); |
|
| 883 | + $tip = esc_attr__($tip); |
|
| 884 | 884 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | /** |
| 888 | 888 | * Formats a date |
| 889 | 889 | */ |
| 890 | -function getpaid_format_date( $date ) { |
|
| 890 | +function getpaid_format_date($date) { |
|
| 891 | 891 | |
| 892 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
| 892 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
| 893 | 893 | return ''; |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
| 897 | - return date_i18n( get_option( 'date_format' ), strtotime( $date ) ); |
|
| 897 | + return date_i18n(get_option('date_format'), strtotime($date)); |
|
| 898 | 898 | |
| 899 | 899 | } |
| 900 | 900 | |
@@ -905,16 +905,16 @@ discard block |
||
| 905 | 905 | * @param integer $limit Limit size in characters. |
| 906 | 906 | * @return string |
| 907 | 907 | */ |
| 908 | -function getpaid_limit_length( $string, $limit ) { |
|
| 908 | +function getpaid_limit_length($string, $limit) { |
|
| 909 | 909 | $str_limit = $limit - 3; |
| 910 | 910 | |
| 911 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 912 | - if ( mb_strlen( $string ) > $limit ) { |
|
| 913 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 911 | + if (function_exists('mb_strimwidth')) { |
|
| 912 | + if (mb_strlen($string) > $limit) { |
|
| 913 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
| 914 | 914 | } |
| 915 | 915 | } else { |
| 916 | - if ( strlen( $string ) > $limit ) { |
|
| 917 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 916 | + if (strlen($string) > $limit) { |
|
| 917 | + $string = substr($string, 0, $str_limit) . '...'; |
|
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | 920 | return $string; |
@@ -13,53 +13,53 @@ discard block |
||
| 13 | 13 | class WPInv_Plugin { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * GetPaid version. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * GetPaid version. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $version; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * Session instance. |
|
| 24 | - * |
|
| 25 | - * @var WPInv_Session|WPInv_Session_Handler |
|
| 26 | - */ |
|
| 23 | + * Session instance. |
|
| 24 | + * |
|
| 25 | + * @var WPInv_Session|WPInv_Session_Handler |
|
| 26 | + */ |
|
| 27 | 27 | public $session; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Notes instance. |
|
| 31 | - * |
|
| 32 | - * @var WPInv_Notes |
|
| 33 | - */ |
|
| 30 | + * Notes instance. |
|
| 31 | + * |
|
| 32 | + * @var WPInv_Notes |
|
| 33 | + */ |
|
| 34 | 34 | public $notes; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Reports instance. |
|
| 38 | - * |
|
| 39 | - * @var WPInv_Reports |
|
| 40 | - */ |
|
| 37 | + * Reports instance. |
|
| 38 | + * |
|
| 39 | + * @var WPInv_Reports |
|
| 40 | + */ |
|
| 41 | 41 | public $reports; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * API instance. |
|
| 45 | - * |
|
| 46 | - * @var WPInv_API |
|
| 47 | - */ |
|
| 44 | + * API instance. |
|
| 45 | + * |
|
| 46 | + * @var WPInv_API |
|
| 47 | + */ |
|
| 48 | 48 | public $api; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * Form elements instance. |
|
| 52 | - * |
|
| 53 | - * @var WPInv_Payment_Form_Elements |
|
| 54 | - */ |
|
| 51 | + * Form elements instance. |
|
| 52 | + * |
|
| 53 | + * @var WPInv_Payment_Form_Elements |
|
| 54 | + */ |
|
| 55 | 55 | public $form_elements; |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Tax instance. |
|
| 59 | - * |
|
| 60 | - * @var WPInv_EUVat |
|
| 61 | - */ |
|
| 62 | - public $tax; |
|
| 58 | + * Tax instance. |
|
| 59 | + * |
|
| 60 | + * @var WPInv_EUVat |
|
| 61 | + */ |
|
| 62 | + public $tax; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @param array An array of payment gateways. |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | public $options; |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * Class constructor. |
|
| 76 | - */ |
|
| 75 | + * Class constructor. |
|
| 76 | + */ |
|
| 77 | 77 | public function __construct() { |
| 78 | 78 | $this->define_constants(); |
| 79 | 79 | $this->includes(); |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * Define class properties. |
|
| 86 | - */ |
|
| 85 | + * Define class properties. |
|
| 86 | + */ |
|
| 87 | 87 | public function set_properties() { |
| 88 | 88 | |
| 89 | 89 | $this->session = new WPInv_Session_Handler(); |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Define plugin constants. |
|
| 103 | - */ |
|
| 101 | + /** |
|
| 102 | + * Define plugin constants. |
|
| 103 | + */ |
|
| 104 | 104 | public function define_constants() { |
| 105 | 105 | define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
| 106 | 106 | define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * Hook into actions and filters. |
|
| 112 | - * |
|
| 113 | - * @since 1.0.19 |
|
| 114 | - */ |
|
| 111 | + * Hook into actions and filters. |
|
| 112 | + * |
|
| 113 | + * @since 1.0.19 |
|
| 114 | + */ |
|
| 115 | 115 | protected function init_hooks() { |
| 116 | 116 | /* Internationalize the text strings used. */ |
| 117 | 117 | add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | - * Include required core files used in admin and on the frontend. |
|
| 213 | - */ |
|
| 212 | + * Include required core files used in admin and on the frontend. |
|
| 213 | + */ |
|
| 214 | 214 | public function includes() { |
| 215 | 215 | |
| 216 | 216 | // Start with the settings. |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
| 241 | 241 | |
| 242 | 242 | // Register autoloader. |
| 243 | - try { |
|
| 244 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
| 245 | - } catch ( Exception $e ) { |
|
| 246 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
| 243 | + try { |
|
| 244 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
| 245 | + } catch ( Exception $e ) { |
|
| 246 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' ); |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
| 269 | 269 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
| 270 | 270 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
| 271 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 272 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 273 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 274 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 275 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 271 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 272 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 273 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 274 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 275 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 276 | 276 | require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
| 277 | 277 | require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
| 278 | 278 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
@@ -334,49 +334,49 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | - * Class autoloader |
|
| 338 | - * |
|
| 339 | - * @param string $class_name The name of the class to load. |
|
| 340 | - * @access public |
|
| 341 | - * @since 1.0.19 |
|
| 342 | - * @return void |
|
| 343 | - */ |
|
| 344 | - public function autoload( $class_name ) { |
|
| 345 | - |
|
| 346 | - // Normalize the class name... |
|
| 347 | - $class_name = strtolower( $class_name ); |
|
| 348 | - |
|
| 349 | - // ... and make sure it is our class. |
|
| 350 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 351 | - return; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - // Next, prepare the file name from the class. |
|
| 355 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 337 | + * Class autoloader |
|
| 338 | + * |
|
| 339 | + * @param string $class_name The name of the class to load. |
|
| 340 | + * @access public |
|
| 341 | + * @since 1.0.19 |
|
| 342 | + * @return void |
|
| 343 | + */ |
|
| 344 | + public function autoload( $class_name ) { |
|
| 345 | + |
|
| 346 | + // Normalize the class name... |
|
| 347 | + $class_name = strtolower( $class_name ); |
|
| 348 | + |
|
| 349 | + // ... and make sure it is our class. |
|
| 350 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 351 | + return; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + // Next, prepare the file name from the class. |
|
| 355 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 356 | 356 | |
| 357 | 357 | // Base path of the classes. |
| 358 | 358 | $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
| 359 | 359 | |
| 360 | - // And an array of possible locations in order of importance. |
|
| 361 | - $locations = array( |
|
| 360 | + // And an array of possible locations in order of importance. |
|
| 361 | + $locations = array( |
|
| 362 | 362 | "$plugin_path/includes", |
| 363 | 363 | "$plugin_path/includes/data-stores", |
| 364 | 364 | "$plugin_path/includes/gateways", |
| 365 | 365 | "$plugin_path/includes/api", |
| 366 | 366 | "$plugin_path/includes/admin", |
| 367 | 367 | "$plugin_path/includes/admin/meta-boxes", |
| 368 | - ); |
|
| 368 | + ); |
|
| 369 | 369 | |
| 370 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 370 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 371 | 371 | |
| 372 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 373 | - include trailingslashit( $location ) . $file_name; |
|
| 374 | - break; |
|
| 375 | - } |
|
| 372 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 373 | + include trailingslashit( $location ) . $file_name; |
|
| 374 | + break; |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - } |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * Inits hooks etc. |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
| 514 | 514 | wp_enqueue_style( 'jquery-ui-css' ); |
| 515 | 515 | wp_deregister_style( 'yoast-seo-select2' ); |
| 516 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
| 516 | + wp_deregister_style( 'yoast-seo-monorepo' ); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | if ( $page == 'wpinv-subscriptions' ) { |
| 528 | 528 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
| 529 | 529 | wp_deregister_style( 'yoast-seo-select2' ); |
| 530 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
| 530 | + wp_deregister_style( 'yoast-seo-monorepo' ); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
@@ -696,19 +696,19 @@ discard block |
||
| 696 | 696 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - /** |
|
| 700 | - * Register widgets |
|
| 701 | - * |
|
| 702 | - */ |
|
| 703 | - public function register_widgets() { |
|
| 704 | - register_widget( "WPInv_Checkout_Widget" ); |
|
| 705 | - register_widget( "WPInv_History_Widget" ); |
|
| 706 | - register_widget( "WPInv_Receipt_Widget" ); |
|
| 707 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 708 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 699 | + /** |
|
| 700 | + * Register widgets |
|
| 701 | + * |
|
| 702 | + */ |
|
| 703 | + public function register_widgets() { |
|
| 704 | + register_widget( "WPInv_Checkout_Widget" ); |
|
| 705 | + register_widget( "WPInv_History_Widget" ); |
|
| 706 | + register_widget( "WPInv_Receipt_Widget" ); |
|
| 707 | + register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 708 | + register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 709 | 709 | register_widget( "WPInv_Messages_Widget" ); |
| 710 | 710 | register_widget( 'WPInv_GetPaid_Widget' ); |
| 711 | - } |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | 713 | /** |
| 714 | 714 | * Remove our pages from yoast sitemaps. |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Registers routes |
|
| 62 | - * |
|
| 60 | + /** |
|
| 61 | + * Registers routes |
|
| 62 | + * |
|
| 63 | 63 | * @since 1.0.13 |
| 64 | - */ |
|
| 65 | - public function register_rest_routes() { |
|
| 64 | + */ |
|
| 65 | + public function register_rest_routes() { |
|
| 66 | 66 | |
| 67 | 67 | // Items. |
| 68 | 68 | $this->items_controller->register_routes(); |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $this->discounts_controller->register_routes(); |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Fires when registering Invoicing REST routes. |
|
| 75 | - * |
|
| 76 | - * |
|
| 77 | - * @since 1.0.15 |
|
| 78 | - * |
|
| 79 | - * |
|
| 80 | - * @param array $invoice_data Invoice properties. |
|
| 81 | - * @param WP_REST_Request $request The request used. |
|
| 82 | - */ |
|
| 74 | + * Fires when registering Invoicing REST routes. |
|
| 75 | + * |
|
| 76 | + * |
|
| 77 | + * @since 1.0.15 |
|
| 78 | + * |
|
| 79 | + * |
|
| 80 | + * @param array $invoice_data Invoice properties. |
|
| 81 | + * @param WP_REST_Request $request The request used. |
|
| 82 | + */ |
|
| 83 | 83 | do_action( "wpinv_register_rest_routes", $this ); |
| 84 | 84 | |
| 85 | 85 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @param string A prefix for our REST routes |
| 21 | 21 | */ |
| 22 | - public $api_namespace = ''; |
|
| 22 | + public $api_namespace = ''; |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @param WPInv_REST_Invoice_Controller Invoices controller |
@@ -42,19 +42,19 @@ discard block |
||
| 42 | 42 | * @since 1.0.13 |
| 43 | 43 | * Sets the API namespace and inits hooks |
| 44 | 44 | */ |
| 45 | - public function __construct( $api_namespace = 'invoicing/v1' ) { |
|
| 45 | + public function __construct($api_namespace = 'invoicing/v1') { |
|
| 46 | 46 | |
| 47 | 47 | // Include controllers and related files |
| 48 | 48 | $this->includes(); |
| 49 | 49 | |
| 50 | 50 | // Set up class variables |
| 51 | - $this->api_namespace = apply_filters( 'wpinv_rest_api_namespace', $api_namespace ); |
|
| 51 | + $this->api_namespace = apply_filters('wpinv_rest_api_namespace', $api_namespace); |
|
| 52 | 52 | $this->invoices_controller = new WPInv_REST_Invoice_Controller(); |
| 53 | - $this->items_controller = new WPInv_REST_Items_Controller( $this->api_namespace ); |
|
| 54 | - $this->discounts_controller= new WPInv_REST_Discounts_Controller( $this->api_namespace ); |
|
| 53 | + $this->items_controller = new WPInv_REST_Items_Controller($this->api_namespace); |
|
| 54 | + $this->discounts_controller = new WPInv_REST_Discounts_Controller($this->api_namespace); |
|
| 55 | 55 | |
| 56 | 56 | //Register REST routes |
| 57 | - add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) ); |
|
| 57 | + add_action('rest_api_init', array($this, 'register_rest_routes')); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param array $invoice_data Invoice properties. |
| 81 | 81 | * @param WP_REST_Request $request The request used. |
| 82 | 82 | */ |
| 83 | - do_action( "wpinv_register_rest_routes", $this ); |
|
| 83 | + do_action("wpinv_register_rest_routes", $this); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | protected function includes() { |
| 94 | 94 | |
| 95 | 95 | // Invoices |
| 96 | - require_once( WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-invoice-controller.php' ); |
|
| 96 | + require_once(WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-invoice-controller.php'); |
|
| 97 | 97 | |
| 98 | 98 | // Items |
| 99 | - require_once( WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-items-controller.php' ); |
|
| 99 | + require_once(WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-items-controller.php'); |
|
| 100 | 100 | |
| 101 | 101 | // Discounts |
| 102 | - require_once( WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-discounts-controller.php' ); |
|
| 102 | + require_once(WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-discounts-controller.php'); |
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
@@ -21,519 +21,519 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class GetPaid_REST_Controller extends WP_REST_Controller { |
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * The namespaces of this controller's route. |
| 26 | 26 | * |
| 27 | 27 | * @since 1.0.19 |
| 28 | 28 | * @var array |
| 29 | 29 | */ |
| 30 | - protected $namespaces; |
|
| 30 | + protected $namespaces; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * The official namespace of this controller's route. |
| 34 | 34 | * |
| 35 | 35 | * @since 1.0.19 |
| 36 | 36 | * @var string |
| 37 | 37 | */ |
| 38 | - protected $namespace = 'getpaid/v1'; |
|
| 38 | + protected $namespace = 'getpaid/v1'; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | + /** |
|
| 41 | 41 | * Cached results of get_item_schema. |
| 42 | 42 | * |
| 43 | 43 | * @since 1.0.19 |
| 44 | 44 | * @var array |
| 45 | 45 | */ |
| 46 | - protected $schema; |
|
| 46 | + protected $schema; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * Constructor. |
|
| 50 | - * |
|
| 51 | - * @since 1.0.19 |
|
| 52 | - * |
|
| 53 | - */ |
|
| 54 | - public function __construct() { |
|
| 55 | - |
|
| 56 | - // Offer several namespaces for backwards compatibility. |
|
| 57 | - $this->namespaces = apply_filters( |
|
| 58 | - 'getpaid_rest_api_namespaces', |
|
| 59 | - array( |
|
| 60 | - 'getpaid/v1', |
|
| 61 | - 'invoicing/v1', |
|
| 62 | - 'wpi/v1' |
|
| 63 | - ) |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - // Register REST routes. |
|
| 49 | + * Constructor. |
|
| 50 | + * |
|
| 51 | + * @since 1.0.19 |
|
| 52 | + * |
|
| 53 | + */ |
|
| 54 | + public function __construct() { |
|
| 55 | + |
|
| 56 | + // Offer several namespaces for backwards compatibility. |
|
| 57 | + $this->namespaces = apply_filters( |
|
| 58 | + 'getpaid_rest_api_namespaces', |
|
| 59 | + array( |
|
| 60 | + 'getpaid/v1', |
|
| 61 | + 'invoicing/v1', |
|
| 62 | + 'wpi/v1' |
|
| 63 | + ) |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + // Register REST routes. |
|
| 67 | 67 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 68 | 68 | |
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Registers routes for each namespace. |
|
| 73 | - * |
|
| 74 | - * @since 1.0.19 |
|
| 75 | - * |
|
| 76 | - */ |
|
| 77 | - public function register_routes() { |
|
| 78 | - |
|
| 79 | - foreach ( $this->namespaces as $namespace ) { |
|
| 80 | - $this->register_namespace_routes( $namespace ); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Registers routes for a namespace. |
|
| 87 | - * |
|
| 88 | - * @since 1.0.19 |
|
| 89 | - * |
|
| 90 | - * @param string $namespace |
|
| 91 | - */ |
|
| 92 | - public function register_namespace_routes( $namespace ) { |
|
| 93 | - |
|
| 94 | - getpaid_doing_it_wrong( |
|
| 95 | - __CLASS__ . '::' .__METHOD__, |
|
| 96 | - /* translators: %s: register_namespace_routes() */ |
|
| 97 | - sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), |
|
| 98 | - '1.0.19' |
|
| 99 | - ); |
|
| 100 | - |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Get normalized rest base. |
|
| 105 | - * |
|
| 106 | - * @return string |
|
| 107 | - */ |
|
| 108 | - protected function get_normalized_rest_base() { |
|
| 109 | - return preg_replace( '/\(.*\)\//i', '', $this->rest_base ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Check batch limit. |
|
| 114 | - * |
|
| 115 | - * @param array $items Request items. |
|
| 116 | - * @return bool|WP_Error |
|
| 117 | - */ |
|
| 118 | - protected function check_batch_limit( $items ) { |
|
| 119 | - $limit = apply_filters( 'getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base() ); |
|
| 120 | - $total = 0; |
|
| 121 | - |
|
| 122 | - if ( ! empty( $items['create'] ) ) { |
|
| 123 | - $total += count( $items['create'] ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - if ( ! empty( $items['update'] ) ) { |
|
| 127 | - $total += count( $items['update'] ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if ( ! empty( $items['delete'] ) ) { |
|
| 131 | - $total += count( $items['delete'] ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if ( $total > $limit ) { |
|
| 135 | - /* translators: %s: items limit */ |
|
| 136 | - return new WP_Error( 'getpaid_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'invoicing' ), $limit ), array( 'status' => 413 ) ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return true; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Bulk create, update and delete items. |
|
| 144 | - * |
|
| 145 | - * @param WP_REST_Request $request Full details about the request. |
|
| 146 | - * @return array Of WP_Error or WP_REST_Response. |
|
| 147 | - */ |
|
| 148 | - public function batch_items( $request ) { |
|
| 149 | - /** |
|
| 150 | - * REST Server |
|
| 151 | - * |
|
| 152 | - * @var WP_REST_Server $wp_rest_server |
|
| 153 | - */ |
|
| 154 | - global $wp_rest_server; |
|
| 155 | - |
|
| 156 | - // Get the request params. |
|
| 157 | - $items = array_filter( $request->get_params() ); |
|
| 158 | - $query = $request->get_query_params(); |
|
| 159 | - $response = array(); |
|
| 160 | - |
|
| 161 | - // Check batch limit. |
|
| 162 | - $limit = $this->check_batch_limit( $items ); |
|
| 163 | - if ( is_wp_error( $limit ) ) { |
|
| 164 | - return $limit; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if ( ! empty( $items['create'] ) ) { |
|
| 168 | - foreach ( $items['create'] as $item ) { |
|
| 169 | - $_item = new WP_REST_Request( 'POST' ); |
|
| 170 | - |
|
| 171 | - // Default parameters. |
|
| 172 | - $defaults = array(); |
|
| 173 | - $schema = $this->get_public_item_schema(); |
|
| 174 | - foreach ( $schema['properties'] as $arg => $options ) { |
|
| 175 | - if ( isset( $options['default'] ) ) { |
|
| 176 | - $defaults[ $arg ] = $options['default']; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - $_item->set_default_params( $defaults ); |
|
| 180 | - |
|
| 181 | - // Set request parameters. |
|
| 182 | - $_item->set_body_params( $item ); |
|
| 183 | - |
|
| 184 | - // Set query (GET) parameters. |
|
| 185 | - $_item->set_query_params( $query ); |
|
| 186 | - |
|
| 187 | - $_response = $this->create_item( $_item ); |
|
| 188 | - |
|
| 189 | - if ( is_wp_error( $_response ) ) { |
|
| 190 | - $response['create'][] = array( |
|
| 191 | - 'id' => 0, |
|
| 192 | - 'error' => array( |
|
| 193 | - 'code' => $_response->get_error_code(), |
|
| 194 | - 'message' => $_response->get_error_message(), |
|
| 195 | - 'data' => $_response->get_error_data(), |
|
| 196 | - ), |
|
| 197 | - ); |
|
| 198 | - } else { |
|
| 199 | - $response['create'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if ( ! empty( $items['update'] ) ) { |
|
| 205 | - foreach ( $items['update'] as $item ) { |
|
| 206 | - $_item = new WP_REST_Request( 'PUT' ); |
|
| 207 | - $_item->set_body_params( $item ); |
|
| 208 | - $_response = $this->update_item( $_item ); |
|
| 209 | - |
|
| 210 | - if ( is_wp_error( $_response ) ) { |
|
| 211 | - $response['update'][] = array( |
|
| 212 | - 'id' => $item['id'], |
|
| 213 | - 'error' => array( |
|
| 214 | - 'code' => $_response->get_error_code(), |
|
| 215 | - 'message' => $_response->get_error_message(), |
|
| 216 | - 'data' => $_response->get_error_data(), |
|
| 217 | - ), |
|
| 218 | - ); |
|
| 219 | - } else { |
|
| 220 | - $response['update'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if ( ! empty( $items['delete'] ) ) { |
|
| 226 | - foreach ( $items['delete'] as $id ) { |
|
| 227 | - $id = (int) $id; |
|
| 228 | - |
|
| 229 | - if ( 0 === $id ) { |
|
| 230 | - continue; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - $_item = new WP_REST_Request( 'DELETE' ); |
|
| 234 | - $_item->set_query_params( |
|
| 235 | - array( |
|
| 236 | - 'id' => $id, |
|
| 237 | - 'force' => true, |
|
| 238 | - ) |
|
| 239 | - ); |
|
| 240 | - $_response = $this->delete_item( $_item ); |
|
| 241 | - |
|
| 242 | - if ( is_wp_error( $_response ) ) { |
|
| 243 | - $response['delete'][] = array( |
|
| 244 | - 'id' => $id, |
|
| 245 | - 'error' => array( |
|
| 246 | - 'code' => $_response->get_error_code(), |
|
| 247 | - 'message' => $_response->get_error_message(), |
|
| 248 | - 'data' => $_response->get_error_data(), |
|
| 249 | - ), |
|
| 250 | - ); |
|
| 251 | - } else { |
|
| 252 | - $response['delete'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - return $response; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Validate a text value for a text based setting. |
|
| 262 | - * |
|
| 263 | - * @since 1.0.19 |
|
| 264 | - * @param string $value Value. |
|
| 265 | - * @param array $setting Setting. |
|
| 266 | - * @return string |
|
| 267 | - */ |
|
| 268 | - public function validate_setting_text_field( $value, $setting ) { |
|
| 269 | - $value = is_null( $value ) ? '' : $value; |
|
| 270 | - return wp_kses_post( trim( stripslashes( $value ) ) ); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Validate select based settings. |
|
| 275 | - * |
|
| 276 | - * @since 1.0.19 |
|
| 277 | - * @param string $value Value. |
|
| 278 | - * @param array $setting Setting. |
|
| 279 | - * @return string|WP_Error |
|
| 280 | - */ |
|
| 281 | - public function validate_setting_select_field( $value, $setting ) { |
|
| 282 | - if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 283 | - return $value; |
|
| 284 | - } else { |
|
| 285 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Validate multiselect based settings. |
|
| 291 | - * |
|
| 292 | - * @since 1.0.19 |
|
| 293 | - * @param array $values Values. |
|
| 294 | - * @param array $setting Setting. |
|
| 295 | - * @return array|WP_Error |
|
| 296 | - */ |
|
| 297 | - public function validate_setting_multiselect_field( $values, $setting ) { |
|
| 298 | - |
|
| 299 | - if ( empty( $values ) ) { |
|
| 300 | - return array(); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - if ( ! is_array( $values ) ) { |
|
| 304 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - $final_values = array(); |
|
| 308 | - foreach ( $values as $value ) { |
|
| 309 | - if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 310 | - $final_values[] = $value; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - return $final_values; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * Validate radio based settings. |
|
| 319 | - * |
|
| 320 | - * @since 1.0.19 |
|
| 321 | - * @param string $value Value. |
|
| 322 | - * @param array $setting Setting. |
|
| 323 | - * @return string|WP_Error |
|
| 324 | - */ |
|
| 325 | - public function validate_setting_radio_field( $value, $setting ) { |
|
| 326 | - return $this->validate_setting_select_field( $value, $setting ); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Validate checkbox based settings. |
|
| 331 | - * |
|
| 332 | - * @since 1.0.19 |
|
| 333 | - * @param string $value Value. |
|
| 334 | - * @param array $setting Setting. |
|
| 335 | - * @return string|WP_Error |
|
| 336 | - */ |
|
| 337 | - public function validate_setting_checkbox_field( $value, $setting ) { |
|
| 338 | - if ( in_array( $value, array( 'yes', 'no' ) ) ) { |
|
| 339 | - return $value; |
|
| 340 | - } elseif ( is_bool( $value ) || is_numeric( $value ) ) { |
|
| 341 | - return empty( $value ) ? 'no' : 'yes'; |
|
| 342 | - } elseif ( empty( $value ) ) { |
|
| 343 | - $value = isset( $setting['default'] ) ? $setting['default'] : 'no'; |
|
| 344 | - return $value; |
|
| 345 | - } else { |
|
| 346 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Validate textarea based settings. |
|
| 352 | - * |
|
| 353 | - * @since 1.0.19 |
|
| 354 | - * @param string $value Value. |
|
| 355 | - * @param array $setting Setting. |
|
| 356 | - * @return string |
|
| 357 | - */ |
|
| 358 | - public function validate_setting_textarea_field( $value, $setting ) { |
|
| 359 | - $value = is_null( $value ) ? '' : $value; |
|
| 360 | - return wp_kses( |
|
| 361 | - trim( stripslashes( $value ) ), |
|
| 362 | - array_merge( |
|
| 363 | - array( |
|
| 364 | - 'iframe' => array( |
|
| 365 | - 'src' => true, |
|
| 366 | - 'style' => true, |
|
| 367 | - 'id' => true, |
|
| 368 | - 'class' => true, |
|
| 369 | - ), |
|
| 370 | - ), |
|
| 371 | - wp_kses_allowed_html( 'post' ) |
|
| 372 | - ) |
|
| 373 | - ); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Add meta query. |
|
| 378 | - * |
|
| 379 | - * @since 1.0.19 |
|
| 380 | - * @param array $args Query args. |
|
| 381 | - * @param array $meta_query Meta query. |
|
| 382 | - * @return array |
|
| 383 | - */ |
|
| 384 | - protected function add_meta_query( $args, $meta_query ) { |
|
| 385 | - if ( empty( $args['meta_query'] ) ) { |
|
| 386 | - $args['meta_query'] = array(); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - $args['meta_query'][] = $meta_query; |
|
| 390 | - |
|
| 391 | - return $args['meta_query']; |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Get the batch schema, conforming to JSON Schema. |
|
| 396 | - * |
|
| 397 | - * @return array |
|
| 398 | - */ |
|
| 399 | - public function get_public_batch_schema() { |
|
| 400 | - $schema = array( |
|
| 401 | - '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
| 402 | - 'title' => 'batch', |
|
| 403 | - 'type' => 'object', |
|
| 404 | - 'properties' => array( |
|
| 405 | - 'create' => array( |
|
| 406 | - 'description' => __( 'List of created resources.', 'invoicing' ), |
|
| 407 | - 'type' => 'array', |
|
| 408 | - 'context' => array( 'view', 'edit' ), |
|
| 409 | - 'items' => array( |
|
| 410 | - 'type' => 'object', |
|
| 411 | - ), |
|
| 412 | - ), |
|
| 413 | - 'update' => array( |
|
| 414 | - 'description' => __( 'List of updated resources.', 'invoicing' ), |
|
| 415 | - 'type' => 'array', |
|
| 416 | - 'context' => array( 'view', 'edit' ), |
|
| 417 | - 'items' => array( |
|
| 418 | - 'type' => 'object', |
|
| 419 | - ), |
|
| 420 | - ), |
|
| 421 | - 'delete' => array( |
|
| 422 | - 'description' => __( 'List of deleted resources.', 'invoicing' ), |
|
| 423 | - 'type' => 'array', |
|
| 424 | - 'context' => array( 'view', 'edit' ), |
|
| 425 | - 'items' => array( |
|
| 426 | - 'type' => 'integer', |
|
| 427 | - ), |
|
| 428 | - ), |
|
| 429 | - ), |
|
| 430 | - ); |
|
| 431 | - |
|
| 432 | - return $schema; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * Gets an array of fields to be included on the response. |
|
| 437 | - * |
|
| 438 | - * Included fields are based on item schema and `_fields=` request argument. |
|
| 439 | - * Copied from WordPress 5.3 to support old versions. |
|
| 440 | - * |
|
| 441 | - * @since 1.0.19 |
|
| 442 | - * @param WP_REST_Request $request Full details about the request. |
|
| 443 | - * @return array Fields to be included in the response. |
|
| 444 | - */ |
|
| 445 | - public function get_fields_for_response( $request ) { |
|
| 446 | - $schema = $this->get_item_schema(); |
|
| 447 | - $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); |
|
| 448 | - |
|
| 449 | - $additional_fields = $this->get_additional_fields(); |
|
| 450 | - foreach ( $additional_fields as $field_name => $field_options ) { |
|
| 451 | - // For back-compat, include any field with an empty schema |
|
| 452 | - // because it won't be present in $this->get_item_schema(). |
|
| 453 | - if ( is_null( $field_options['schema'] ) ) { |
|
| 454 | - $properties[ $field_name ] = $field_options; |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - // Exclude fields that specify a different context than the request context. |
|
| 459 | - $context = $request['context']; |
|
| 460 | - if ( $context ) { |
|
| 461 | - foreach ( $properties as $name => $options ) { |
|
| 462 | - if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) { |
|
| 463 | - unset( $properties[ $name ] ); |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - $fields = array_keys( $properties ); |
|
| 469 | - |
|
| 470 | - if ( ! isset( $request['_fields'] ) ) { |
|
| 471 | - return $fields; |
|
| 472 | - } |
|
| 473 | - $requested_fields = wpinv_parse_list( $request['_fields'] ); |
|
| 474 | - if ( 0 === count( $requested_fields ) ) { |
|
| 475 | - return $fields; |
|
| 476 | - } |
|
| 477 | - // Trim off outside whitespace from the comma delimited list. |
|
| 478 | - $requested_fields = array_map( 'trim', $requested_fields ); |
|
| 479 | - // Always persist 'id', because it can be needed for add_additional_fields_to_object(). |
|
| 480 | - if ( in_array( 'id', $fields, true ) ) { |
|
| 481 | - $requested_fields[] = 'id'; |
|
| 482 | - } |
|
| 483 | - // Return the list of all requested fields which appear in the schema. |
|
| 484 | - return array_reduce( |
|
| 485 | - $requested_fields, |
|
| 486 | - function( $response_fields, $field ) use ( $fields ) { |
|
| 487 | - if ( in_array( $field, $fields, true ) ) { |
|
| 488 | - $response_fields[] = $field; |
|
| 489 | - return $response_fields; |
|
| 490 | - } |
|
| 491 | - // Check for nested fields if $field is not a direct match. |
|
| 492 | - $nested_fields = explode( '.', $field ); |
|
| 493 | - // A nested field is included so long as its top-level property is |
|
| 494 | - // present in the schema. |
|
| 495 | - if ( in_array( $nested_fields[0], $fields, true ) ) { |
|
| 496 | - $response_fields[] = $field; |
|
| 497 | - } |
|
| 498 | - return $response_fields; |
|
| 499 | - }, |
|
| 500 | - array() |
|
| 501 | - ); |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - /** |
|
| 505 | - * Given an array of fields to include in a response, some of which may be |
|
| 506 | - * `nested.fields`, determine whether the provided field should be included |
|
| 507 | - * in the response body. |
|
| 508 | - * |
|
| 509 | - * Copied from WordPress 5.3 to support old versions. |
|
| 510 | - * |
|
| 511 | - * @since 1.0.19 |
|
| 512 | - * |
|
| 513 | - * @param string $field A field to test for inclusion in the response body. |
|
| 514 | - * @param array $fields An array of string fields supported by the endpoint. |
|
| 515 | - * @return bool Whether to include the field or not. |
|
| 516 | - * @see rest_is_field_included() |
|
| 517 | - */ |
|
| 518 | - public function is_field_included( $field, $fields ) { |
|
| 519 | - if ( in_array( $field, $fields, true ) ) { |
|
| 520 | - return true; |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - foreach ( $fields as $accepted_field ) { |
|
| 524 | - // Check to see if $field is the parent of any item in $fields. |
|
| 525 | - // A field "parent" should be accepted if "parent.child" is accepted. |
|
| 526 | - if ( strpos( $accepted_field, "$field." ) === 0 ) { |
|
| 527 | - return true; |
|
| 528 | - } |
|
| 529 | - // Conversely, if "parent" is accepted, all "parent.child" fields |
|
| 530 | - // should also be accepted. |
|
| 531 | - if ( strpos( $field, "$accepted_field." ) === 0 ) { |
|
| 532 | - return true; |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - return false; |
|
| 537 | - } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Registers routes for each namespace. |
|
| 73 | + * |
|
| 74 | + * @since 1.0.19 |
|
| 75 | + * |
|
| 76 | + */ |
|
| 77 | + public function register_routes() { |
|
| 78 | + |
|
| 79 | + foreach ( $this->namespaces as $namespace ) { |
|
| 80 | + $this->register_namespace_routes( $namespace ); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Registers routes for a namespace. |
|
| 87 | + * |
|
| 88 | + * @since 1.0.19 |
|
| 89 | + * |
|
| 90 | + * @param string $namespace |
|
| 91 | + */ |
|
| 92 | + public function register_namespace_routes( $namespace ) { |
|
| 93 | + |
|
| 94 | + getpaid_doing_it_wrong( |
|
| 95 | + __CLASS__ . '::' .__METHOD__, |
|
| 96 | + /* translators: %s: register_namespace_routes() */ |
|
| 97 | + sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), |
|
| 98 | + '1.0.19' |
|
| 99 | + ); |
|
| 100 | + |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Get normalized rest base. |
|
| 105 | + * |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 108 | + protected function get_normalized_rest_base() { |
|
| 109 | + return preg_replace( '/\(.*\)\//i', '', $this->rest_base ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Check batch limit. |
|
| 114 | + * |
|
| 115 | + * @param array $items Request items. |
|
| 116 | + * @return bool|WP_Error |
|
| 117 | + */ |
|
| 118 | + protected function check_batch_limit( $items ) { |
|
| 119 | + $limit = apply_filters( 'getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base() ); |
|
| 120 | + $total = 0; |
|
| 121 | + |
|
| 122 | + if ( ! empty( $items['create'] ) ) { |
|
| 123 | + $total += count( $items['create'] ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + if ( ! empty( $items['update'] ) ) { |
|
| 127 | + $total += count( $items['update'] ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if ( ! empty( $items['delete'] ) ) { |
|
| 131 | + $total += count( $items['delete'] ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if ( $total > $limit ) { |
|
| 135 | + /* translators: %s: items limit */ |
|
| 136 | + return new WP_Error( 'getpaid_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'invoicing' ), $limit ), array( 'status' => 413 ) ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return true; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Bulk create, update and delete items. |
|
| 144 | + * |
|
| 145 | + * @param WP_REST_Request $request Full details about the request. |
|
| 146 | + * @return array Of WP_Error or WP_REST_Response. |
|
| 147 | + */ |
|
| 148 | + public function batch_items( $request ) { |
|
| 149 | + /** |
|
| 150 | + * REST Server |
|
| 151 | + * |
|
| 152 | + * @var WP_REST_Server $wp_rest_server |
|
| 153 | + */ |
|
| 154 | + global $wp_rest_server; |
|
| 155 | + |
|
| 156 | + // Get the request params. |
|
| 157 | + $items = array_filter( $request->get_params() ); |
|
| 158 | + $query = $request->get_query_params(); |
|
| 159 | + $response = array(); |
|
| 160 | + |
|
| 161 | + // Check batch limit. |
|
| 162 | + $limit = $this->check_batch_limit( $items ); |
|
| 163 | + if ( is_wp_error( $limit ) ) { |
|
| 164 | + return $limit; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if ( ! empty( $items['create'] ) ) { |
|
| 168 | + foreach ( $items['create'] as $item ) { |
|
| 169 | + $_item = new WP_REST_Request( 'POST' ); |
|
| 170 | + |
|
| 171 | + // Default parameters. |
|
| 172 | + $defaults = array(); |
|
| 173 | + $schema = $this->get_public_item_schema(); |
|
| 174 | + foreach ( $schema['properties'] as $arg => $options ) { |
|
| 175 | + if ( isset( $options['default'] ) ) { |
|
| 176 | + $defaults[ $arg ] = $options['default']; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + $_item->set_default_params( $defaults ); |
|
| 180 | + |
|
| 181 | + // Set request parameters. |
|
| 182 | + $_item->set_body_params( $item ); |
|
| 183 | + |
|
| 184 | + // Set query (GET) parameters. |
|
| 185 | + $_item->set_query_params( $query ); |
|
| 186 | + |
|
| 187 | + $_response = $this->create_item( $_item ); |
|
| 188 | + |
|
| 189 | + if ( is_wp_error( $_response ) ) { |
|
| 190 | + $response['create'][] = array( |
|
| 191 | + 'id' => 0, |
|
| 192 | + 'error' => array( |
|
| 193 | + 'code' => $_response->get_error_code(), |
|
| 194 | + 'message' => $_response->get_error_message(), |
|
| 195 | + 'data' => $_response->get_error_data(), |
|
| 196 | + ), |
|
| 197 | + ); |
|
| 198 | + } else { |
|
| 199 | + $response['create'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if ( ! empty( $items['update'] ) ) { |
|
| 205 | + foreach ( $items['update'] as $item ) { |
|
| 206 | + $_item = new WP_REST_Request( 'PUT' ); |
|
| 207 | + $_item->set_body_params( $item ); |
|
| 208 | + $_response = $this->update_item( $_item ); |
|
| 209 | + |
|
| 210 | + if ( is_wp_error( $_response ) ) { |
|
| 211 | + $response['update'][] = array( |
|
| 212 | + 'id' => $item['id'], |
|
| 213 | + 'error' => array( |
|
| 214 | + 'code' => $_response->get_error_code(), |
|
| 215 | + 'message' => $_response->get_error_message(), |
|
| 216 | + 'data' => $_response->get_error_data(), |
|
| 217 | + ), |
|
| 218 | + ); |
|
| 219 | + } else { |
|
| 220 | + $response['update'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if ( ! empty( $items['delete'] ) ) { |
|
| 226 | + foreach ( $items['delete'] as $id ) { |
|
| 227 | + $id = (int) $id; |
|
| 228 | + |
|
| 229 | + if ( 0 === $id ) { |
|
| 230 | + continue; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + $_item = new WP_REST_Request( 'DELETE' ); |
|
| 234 | + $_item->set_query_params( |
|
| 235 | + array( |
|
| 236 | + 'id' => $id, |
|
| 237 | + 'force' => true, |
|
| 238 | + ) |
|
| 239 | + ); |
|
| 240 | + $_response = $this->delete_item( $_item ); |
|
| 241 | + |
|
| 242 | + if ( is_wp_error( $_response ) ) { |
|
| 243 | + $response['delete'][] = array( |
|
| 244 | + 'id' => $id, |
|
| 245 | + 'error' => array( |
|
| 246 | + 'code' => $_response->get_error_code(), |
|
| 247 | + 'message' => $_response->get_error_message(), |
|
| 248 | + 'data' => $_response->get_error_data(), |
|
| 249 | + ), |
|
| 250 | + ); |
|
| 251 | + } else { |
|
| 252 | + $response['delete'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + return $response; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Validate a text value for a text based setting. |
|
| 262 | + * |
|
| 263 | + * @since 1.0.19 |
|
| 264 | + * @param string $value Value. |
|
| 265 | + * @param array $setting Setting. |
|
| 266 | + * @return string |
|
| 267 | + */ |
|
| 268 | + public function validate_setting_text_field( $value, $setting ) { |
|
| 269 | + $value = is_null( $value ) ? '' : $value; |
|
| 270 | + return wp_kses_post( trim( stripslashes( $value ) ) ); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Validate select based settings. |
|
| 275 | + * |
|
| 276 | + * @since 1.0.19 |
|
| 277 | + * @param string $value Value. |
|
| 278 | + * @param array $setting Setting. |
|
| 279 | + * @return string|WP_Error |
|
| 280 | + */ |
|
| 281 | + public function validate_setting_select_field( $value, $setting ) { |
|
| 282 | + if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 283 | + return $value; |
|
| 284 | + } else { |
|
| 285 | + return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Validate multiselect based settings. |
|
| 291 | + * |
|
| 292 | + * @since 1.0.19 |
|
| 293 | + * @param array $values Values. |
|
| 294 | + * @param array $setting Setting. |
|
| 295 | + * @return array|WP_Error |
|
| 296 | + */ |
|
| 297 | + public function validate_setting_multiselect_field( $values, $setting ) { |
|
| 298 | + |
|
| 299 | + if ( empty( $values ) ) { |
|
| 300 | + return array(); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + if ( ! is_array( $values ) ) { |
|
| 304 | + return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + $final_values = array(); |
|
| 308 | + foreach ( $values as $value ) { |
|
| 309 | + if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 310 | + $final_values[] = $value; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + return $final_values; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * Validate radio based settings. |
|
| 319 | + * |
|
| 320 | + * @since 1.0.19 |
|
| 321 | + * @param string $value Value. |
|
| 322 | + * @param array $setting Setting. |
|
| 323 | + * @return string|WP_Error |
|
| 324 | + */ |
|
| 325 | + public function validate_setting_radio_field( $value, $setting ) { |
|
| 326 | + return $this->validate_setting_select_field( $value, $setting ); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Validate checkbox based settings. |
|
| 331 | + * |
|
| 332 | + * @since 1.0.19 |
|
| 333 | + * @param string $value Value. |
|
| 334 | + * @param array $setting Setting. |
|
| 335 | + * @return string|WP_Error |
|
| 336 | + */ |
|
| 337 | + public function validate_setting_checkbox_field( $value, $setting ) { |
|
| 338 | + if ( in_array( $value, array( 'yes', 'no' ) ) ) { |
|
| 339 | + return $value; |
|
| 340 | + } elseif ( is_bool( $value ) || is_numeric( $value ) ) { |
|
| 341 | + return empty( $value ) ? 'no' : 'yes'; |
|
| 342 | + } elseif ( empty( $value ) ) { |
|
| 343 | + $value = isset( $setting['default'] ) ? $setting['default'] : 'no'; |
|
| 344 | + return $value; |
|
| 345 | + } else { |
|
| 346 | + return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Validate textarea based settings. |
|
| 352 | + * |
|
| 353 | + * @since 1.0.19 |
|
| 354 | + * @param string $value Value. |
|
| 355 | + * @param array $setting Setting. |
|
| 356 | + * @return string |
|
| 357 | + */ |
|
| 358 | + public function validate_setting_textarea_field( $value, $setting ) { |
|
| 359 | + $value = is_null( $value ) ? '' : $value; |
|
| 360 | + return wp_kses( |
|
| 361 | + trim( stripslashes( $value ) ), |
|
| 362 | + array_merge( |
|
| 363 | + array( |
|
| 364 | + 'iframe' => array( |
|
| 365 | + 'src' => true, |
|
| 366 | + 'style' => true, |
|
| 367 | + 'id' => true, |
|
| 368 | + 'class' => true, |
|
| 369 | + ), |
|
| 370 | + ), |
|
| 371 | + wp_kses_allowed_html( 'post' ) |
|
| 372 | + ) |
|
| 373 | + ); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Add meta query. |
|
| 378 | + * |
|
| 379 | + * @since 1.0.19 |
|
| 380 | + * @param array $args Query args. |
|
| 381 | + * @param array $meta_query Meta query. |
|
| 382 | + * @return array |
|
| 383 | + */ |
|
| 384 | + protected function add_meta_query( $args, $meta_query ) { |
|
| 385 | + if ( empty( $args['meta_query'] ) ) { |
|
| 386 | + $args['meta_query'] = array(); |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + $args['meta_query'][] = $meta_query; |
|
| 390 | + |
|
| 391 | + return $args['meta_query']; |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Get the batch schema, conforming to JSON Schema. |
|
| 396 | + * |
|
| 397 | + * @return array |
|
| 398 | + */ |
|
| 399 | + public function get_public_batch_schema() { |
|
| 400 | + $schema = array( |
|
| 401 | + '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
| 402 | + 'title' => 'batch', |
|
| 403 | + 'type' => 'object', |
|
| 404 | + 'properties' => array( |
|
| 405 | + 'create' => array( |
|
| 406 | + 'description' => __( 'List of created resources.', 'invoicing' ), |
|
| 407 | + 'type' => 'array', |
|
| 408 | + 'context' => array( 'view', 'edit' ), |
|
| 409 | + 'items' => array( |
|
| 410 | + 'type' => 'object', |
|
| 411 | + ), |
|
| 412 | + ), |
|
| 413 | + 'update' => array( |
|
| 414 | + 'description' => __( 'List of updated resources.', 'invoicing' ), |
|
| 415 | + 'type' => 'array', |
|
| 416 | + 'context' => array( 'view', 'edit' ), |
|
| 417 | + 'items' => array( |
|
| 418 | + 'type' => 'object', |
|
| 419 | + ), |
|
| 420 | + ), |
|
| 421 | + 'delete' => array( |
|
| 422 | + 'description' => __( 'List of deleted resources.', 'invoicing' ), |
|
| 423 | + 'type' => 'array', |
|
| 424 | + 'context' => array( 'view', 'edit' ), |
|
| 425 | + 'items' => array( |
|
| 426 | + 'type' => 'integer', |
|
| 427 | + ), |
|
| 428 | + ), |
|
| 429 | + ), |
|
| 430 | + ); |
|
| 431 | + |
|
| 432 | + return $schema; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * Gets an array of fields to be included on the response. |
|
| 437 | + * |
|
| 438 | + * Included fields are based on item schema and `_fields=` request argument. |
|
| 439 | + * Copied from WordPress 5.3 to support old versions. |
|
| 440 | + * |
|
| 441 | + * @since 1.0.19 |
|
| 442 | + * @param WP_REST_Request $request Full details about the request. |
|
| 443 | + * @return array Fields to be included in the response. |
|
| 444 | + */ |
|
| 445 | + public function get_fields_for_response( $request ) { |
|
| 446 | + $schema = $this->get_item_schema(); |
|
| 447 | + $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); |
|
| 448 | + |
|
| 449 | + $additional_fields = $this->get_additional_fields(); |
|
| 450 | + foreach ( $additional_fields as $field_name => $field_options ) { |
|
| 451 | + // For back-compat, include any field with an empty schema |
|
| 452 | + // because it won't be present in $this->get_item_schema(). |
|
| 453 | + if ( is_null( $field_options['schema'] ) ) { |
|
| 454 | + $properties[ $field_name ] = $field_options; |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + // Exclude fields that specify a different context than the request context. |
|
| 459 | + $context = $request['context']; |
|
| 460 | + if ( $context ) { |
|
| 461 | + foreach ( $properties as $name => $options ) { |
|
| 462 | + if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) { |
|
| 463 | + unset( $properties[ $name ] ); |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + $fields = array_keys( $properties ); |
|
| 469 | + |
|
| 470 | + if ( ! isset( $request['_fields'] ) ) { |
|
| 471 | + return $fields; |
|
| 472 | + } |
|
| 473 | + $requested_fields = wpinv_parse_list( $request['_fields'] ); |
|
| 474 | + if ( 0 === count( $requested_fields ) ) { |
|
| 475 | + return $fields; |
|
| 476 | + } |
|
| 477 | + // Trim off outside whitespace from the comma delimited list. |
|
| 478 | + $requested_fields = array_map( 'trim', $requested_fields ); |
|
| 479 | + // Always persist 'id', because it can be needed for add_additional_fields_to_object(). |
|
| 480 | + if ( in_array( 'id', $fields, true ) ) { |
|
| 481 | + $requested_fields[] = 'id'; |
|
| 482 | + } |
|
| 483 | + // Return the list of all requested fields which appear in the schema. |
|
| 484 | + return array_reduce( |
|
| 485 | + $requested_fields, |
|
| 486 | + function( $response_fields, $field ) use ( $fields ) { |
|
| 487 | + if ( in_array( $field, $fields, true ) ) { |
|
| 488 | + $response_fields[] = $field; |
|
| 489 | + return $response_fields; |
|
| 490 | + } |
|
| 491 | + // Check for nested fields if $field is not a direct match. |
|
| 492 | + $nested_fields = explode( '.', $field ); |
|
| 493 | + // A nested field is included so long as its top-level property is |
|
| 494 | + // present in the schema. |
|
| 495 | + if ( in_array( $nested_fields[0], $fields, true ) ) { |
|
| 496 | + $response_fields[] = $field; |
|
| 497 | + } |
|
| 498 | + return $response_fields; |
|
| 499 | + }, |
|
| 500 | + array() |
|
| 501 | + ); |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + /** |
|
| 505 | + * Given an array of fields to include in a response, some of which may be |
|
| 506 | + * `nested.fields`, determine whether the provided field should be included |
|
| 507 | + * in the response body. |
|
| 508 | + * |
|
| 509 | + * Copied from WordPress 5.3 to support old versions. |
|
| 510 | + * |
|
| 511 | + * @since 1.0.19 |
|
| 512 | + * |
|
| 513 | + * @param string $field A field to test for inclusion in the response body. |
|
| 514 | + * @param array $fields An array of string fields supported by the endpoint. |
|
| 515 | + * @return bool Whether to include the field or not. |
|
| 516 | + * @see rest_is_field_included() |
|
| 517 | + */ |
|
| 518 | + public function is_field_included( $field, $fields ) { |
|
| 519 | + if ( in_array( $field, $fields, true ) ) { |
|
| 520 | + return true; |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + foreach ( $fields as $accepted_field ) { |
|
| 524 | + // Check to see if $field is the parent of any item in $fields. |
|
| 525 | + // A field "parent" should be accepted if "parent.child" is accepted. |
|
| 526 | + if ( strpos( $accepted_field, "$field." ) === 0 ) { |
|
| 527 | + return true; |
|
| 528 | + } |
|
| 529 | + // Conversely, if "parent" is accepted, all "parent.child" fields |
|
| 530 | + // should also be accepted. |
|
| 531 | + if ( strpos( $field, "$accepted_field." ) === 0 ) { |
|
| 532 | + return true; |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + return false; |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | 539 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Core class to access posts via the REST API. |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | // Register REST routes. |
| 67 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 67 | + add_action('rest_api_init', array($this, 'register_routes')); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function register_routes() { |
| 78 | 78 | |
| 79 | - foreach ( $this->namespaces as $namespace ) { |
|
| 80 | - $this->register_namespace_routes( $namespace ); |
|
| 79 | + foreach ($this->namespaces as $namespace) { |
|
| 80 | + $this->register_namespace_routes($namespace); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | } |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @param string $namespace |
| 91 | 91 | */ |
| 92 | - public function register_namespace_routes( $namespace ) { |
|
| 92 | + public function register_namespace_routes($namespace) { |
|
| 93 | 93 | |
| 94 | 94 | getpaid_doing_it_wrong( |
| 95 | - __CLASS__ . '::' .__METHOD__, |
|
| 95 | + __CLASS__ . '::' . __METHOD__, |
|
| 96 | 96 | /* translators: %s: register_namespace_routes() */ |
| 97 | - sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), |
|
| 97 | + sprintf(__("Method '%s' must be overridden."), __METHOD__), |
|
| 98 | 98 | '1.0.19' |
| 99 | 99 | ); |
| 100 | 100 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | 108 | protected function get_normalized_rest_base() { |
| 109 | - return preg_replace( '/\(.*\)\//i', '', $this->rest_base ); |
|
| 109 | + return preg_replace('/\(.*\)\//i', '', $this->rest_base); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -115,25 +115,25 @@ discard block |
||
| 115 | 115 | * @param array $items Request items. |
| 116 | 116 | * @return bool|WP_Error |
| 117 | 117 | */ |
| 118 | - protected function check_batch_limit( $items ) { |
|
| 119 | - $limit = apply_filters( 'getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base() ); |
|
| 118 | + protected function check_batch_limit($items) { |
|
| 119 | + $limit = apply_filters('getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base()); |
|
| 120 | 120 | $total = 0; |
| 121 | 121 | |
| 122 | - if ( ! empty( $items['create'] ) ) { |
|
| 123 | - $total += count( $items['create'] ); |
|
| 122 | + if (!empty($items['create'])) { |
|
| 123 | + $total += count($items['create']); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( ! empty( $items['update'] ) ) { |
|
| 127 | - $total += count( $items['update'] ); |
|
| 126 | + if (!empty($items['update'])) { |
|
| 127 | + $total += count($items['update']); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( ! empty( $items['delete'] ) ) { |
|
| 131 | - $total += count( $items['delete'] ); |
|
| 130 | + if (!empty($items['delete'])) { |
|
| 131 | + $total += count($items['delete']); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( $total > $limit ) { |
|
| 134 | + if ($total > $limit) { |
|
| 135 | 135 | /* translators: %s: items limit */ |
| 136 | - return new WP_Error( 'getpaid_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'invoicing' ), $limit ), array( 'status' => 413 ) ); |
|
| 136 | + return new WP_Error('getpaid_rest_request_entity_too_large', sprintf(__('Unable to accept more than %s items for this request.', 'invoicing'), $limit), array('status' => 413)); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return true; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param WP_REST_Request $request Full details about the request. |
| 146 | 146 | * @return array Of WP_Error or WP_REST_Response. |
| 147 | 147 | */ |
| 148 | - public function batch_items( $request ) { |
|
| 148 | + public function batch_items($request) { |
|
| 149 | 149 | /** |
| 150 | 150 | * REST Server |
| 151 | 151 | * |
@@ -154,39 +154,39 @@ discard block |
||
| 154 | 154 | global $wp_rest_server; |
| 155 | 155 | |
| 156 | 156 | // Get the request params. |
| 157 | - $items = array_filter( $request->get_params() ); |
|
| 157 | + $items = array_filter($request->get_params()); |
|
| 158 | 158 | $query = $request->get_query_params(); |
| 159 | 159 | $response = array(); |
| 160 | 160 | |
| 161 | 161 | // Check batch limit. |
| 162 | - $limit = $this->check_batch_limit( $items ); |
|
| 163 | - if ( is_wp_error( $limit ) ) { |
|
| 162 | + $limit = $this->check_batch_limit($items); |
|
| 163 | + if (is_wp_error($limit)) { |
|
| 164 | 164 | return $limit; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( ! empty( $items['create'] ) ) { |
|
| 168 | - foreach ( $items['create'] as $item ) { |
|
| 169 | - $_item = new WP_REST_Request( 'POST' ); |
|
| 167 | + if (!empty($items['create'])) { |
|
| 168 | + foreach ($items['create'] as $item) { |
|
| 169 | + $_item = new WP_REST_Request('POST'); |
|
| 170 | 170 | |
| 171 | 171 | // Default parameters. |
| 172 | 172 | $defaults = array(); |
| 173 | 173 | $schema = $this->get_public_item_schema(); |
| 174 | - foreach ( $schema['properties'] as $arg => $options ) { |
|
| 175 | - if ( isset( $options['default'] ) ) { |
|
| 176 | - $defaults[ $arg ] = $options['default']; |
|
| 174 | + foreach ($schema['properties'] as $arg => $options) { |
|
| 175 | + if (isset($options['default'])) { |
|
| 176 | + $defaults[$arg] = $options['default']; |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - $_item->set_default_params( $defaults ); |
|
| 179 | + $_item->set_default_params($defaults); |
|
| 180 | 180 | |
| 181 | 181 | // Set request parameters. |
| 182 | - $_item->set_body_params( $item ); |
|
| 182 | + $_item->set_body_params($item); |
|
| 183 | 183 | |
| 184 | 184 | // Set query (GET) parameters. |
| 185 | - $_item->set_query_params( $query ); |
|
| 185 | + $_item->set_query_params($query); |
|
| 186 | 186 | |
| 187 | - $_response = $this->create_item( $_item ); |
|
| 187 | + $_response = $this->create_item($_item); |
|
| 188 | 188 | |
| 189 | - if ( is_wp_error( $_response ) ) { |
|
| 189 | + if (is_wp_error($_response)) { |
|
| 190 | 190 | $response['create'][] = array( |
| 191 | 191 | 'id' => 0, |
| 192 | 192 | 'error' => array( |
@@ -196,18 +196,18 @@ discard block |
||
| 196 | 196 | ), |
| 197 | 197 | ); |
| 198 | 198 | } else { |
| 199 | - $response['create'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 199 | + $response['create'][] = $wp_rest_server->response_to_data($_response, ''); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ( ! empty( $items['update'] ) ) { |
|
| 205 | - foreach ( $items['update'] as $item ) { |
|
| 206 | - $_item = new WP_REST_Request( 'PUT' ); |
|
| 207 | - $_item->set_body_params( $item ); |
|
| 208 | - $_response = $this->update_item( $_item ); |
|
| 204 | + if (!empty($items['update'])) { |
|
| 205 | + foreach ($items['update'] as $item) { |
|
| 206 | + $_item = new WP_REST_Request('PUT'); |
|
| 207 | + $_item->set_body_params($item); |
|
| 208 | + $_response = $this->update_item($_item); |
|
| 209 | 209 | |
| 210 | - if ( is_wp_error( $_response ) ) { |
|
| 210 | + if (is_wp_error($_response)) { |
|
| 211 | 211 | $response['update'][] = array( |
| 212 | 212 | 'id' => $item['id'], |
| 213 | 213 | 'error' => array( |
@@ -217,29 +217,29 @@ discard block |
||
| 217 | 217 | ), |
| 218 | 218 | ); |
| 219 | 219 | } else { |
| 220 | - $response['update'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 220 | + $response['update'][] = $wp_rest_server->response_to_data($_response, ''); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( ! empty( $items['delete'] ) ) { |
|
| 226 | - foreach ( $items['delete'] as $id ) { |
|
| 225 | + if (!empty($items['delete'])) { |
|
| 226 | + foreach ($items['delete'] as $id) { |
|
| 227 | 227 | $id = (int) $id; |
| 228 | 228 | |
| 229 | - if ( 0 === $id ) { |
|
| 229 | + if (0 === $id) { |
|
| 230 | 230 | continue; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $_item = new WP_REST_Request( 'DELETE' ); |
|
| 233 | + $_item = new WP_REST_Request('DELETE'); |
|
| 234 | 234 | $_item->set_query_params( |
| 235 | 235 | array( |
| 236 | 236 | 'id' => $id, |
| 237 | 237 | 'force' => true, |
| 238 | 238 | ) |
| 239 | 239 | ); |
| 240 | - $_response = $this->delete_item( $_item ); |
|
| 240 | + $_response = $this->delete_item($_item); |
|
| 241 | 241 | |
| 242 | - if ( is_wp_error( $_response ) ) { |
|
| 242 | + if (is_wp_error($_response)) { |
|
| 243 | 243 | $response['delete'][] = array( |
| 244 | 244 | 'id' => $id, |
| 245 | 245 | 'error' => array( |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | ), |
| 250 | 250 | ); |
| 251 | 251 | } else { |
| 252 | - $response['delete'][] = $wp_rest_server->response_to_data( $_response, '' ); |
|
| 252 | + $response['delete'][] = $wp_rest_server->response_to_data($_response, ''); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | * @param array $setting Setting. |
| 266 | 266 | * @return string |
| 267 | 267 | */ |
| 268 | - public function validate_setting_text_field( $value, $setting ) { |
|
| 269 | - $value = is_null( $value ) ? '' : $value; |
|
| 270 | - return wp_kses_post( trim( stripslashes( $value ) ) ); |
|
| 268 | + public function validate_setting_text_field($value, $setting) { |
|
| 269 | + $value = is_null($value) ? '' : $value; |
|
| 270 | + return wp_kses_post(trim(stripslashes($value))); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | * @param array $setting Setting. |
| 279 | 279 | * @return string|WP_Error |
| 280 | 280 | */ |
| 281 | - public function validate_setting_select_field( $value, $setting ) { |
|
| 282 | - if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 281 | + public function validate_setting_select_field($value, $setting) { |
|
| 282 | + if (array_key_exists($value, $setting['options'])) { |
|
| 283 | 283 | return $value; |
| 284 | 284 | } else { |
| 285 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 285 | + return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'invoicing'), array('status' => 400)); |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -294,19 +294,19 @@ discard block |
||
| 294 | 294 | * @param array $setting Setting. |
| 295 | 295 | * @return array|WP_Error |
| 296 | 296 | */ |
| 297 | - public function validate_setting_multiselect_field( $values, $setting ) { |
|
| 297 | + public function validate_setting_multiselect_field($values, $setting) { |
|
| 298 | 298 | |
| 299 | - if ( empty( $values ) ) { |
|
| 299 | + if (empty($values)) { |
|
| 300 | 300 | return array(); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( ! is_array( $values ) ) { |
|
| 304 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 303 | + if (!is_array($values)) { |
|
| 304 | + return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'invoicing'), array('status' => 400)); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $final_values = array(); |
| 308 | - foreach ( $values as $value ) { |
|
| 309 | - if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 308 | + foreach ($values as $value) { |
|
| 309 | + if (array_key_exists($value, $setting['options'])) { |
|
| 310 | 310 | $final_values[] = $value; |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @param array $setting Setting. |
| 323 | 323 | * @return string|WP_Error |
| 324 | 324 | */ |
| 325 | - public function validate_setting_radio_field( $value, $setting ) { |
|
| 326 | - return $this->validate_setting_select_field( $value, $setting ); |
|
| 325 | + public function validate_setting_radio_field($value, $setting) { |
|
| 326 | + return $this->validate_setting_select_field($value, $setting); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -334,16 +334,16 @@ discard block |
||
| 334 | 334 | * @param array $setting Setting. |
| 335 | 335 | * @return string|WP_Error |
| 336 | 336 | */ |
| 337 | - public function validate_setting_checkbox_field( $value, $setting ) { |
|
| 338 | - if ( in_array( $value, array( 'yes', 'no' ) ) ) { |
|
| 337 | + public function validate_setting_checkbox_field($value, $setting) { |
|
| 338 | + if (in_array($value, array('yes', 'no'))) { |
|
| 339 | 339 | return $value; |
| 340 | - } elseif ( is_bool( $value ) || is_numeric( $value ) ) { |
|
| 341 | - return empty( $value ) ? 'no' : 'yes'; |
|
| 342 | - } elseif ( empty( $value ) ) { |
|
| 343 | - $value = isset( $setting['default'] ) ? $setting['default'] : 'no'; |
|
| 340 | + } elseif (is_bool($value) || is_numeric($value)) { |
|
| 341 | + return empty($value) ? 'no' : 'yes'; |
|
| 342 | + } elseif (empty($value)) { |
|
| 343 | + $value = isset($setting['default']) ? $setting['default'] : 'no'; |
|
| 344 | 344 | return $value; |
| 345 | 345 | } else { |
| 346 | - return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 346 | + return new WP_Error('rest_setting_value_invalid', __('An invalid setting value was passed.', 'invoicing'), array('status' => 400)); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
@@ -355,10 +355,10 @@ discard block |
||
| 355 | 355 | * @param array $setting Setting. |
| 356 | 356 | * @return string |
| 357 | 357 | */ |
| 358 | - public function validate_setting_textarea_field( $value, $setting ) { |
|
| 359 | - $value = is_null( $value ) ? '' : $value; |
|
| 358 | + public function validate_setting_textarea_field($value, $setting) { |
|
| 359 | + $value = is_null($value) ? '' : $value; |
|
| 360 | 360 | return wp_kses( |
| 361 | - trim( stripslashes( $value ) ), |
|
| 361 | + trim(stripslashes($value)), |
|
| 362 | 362 | array_merge( |
| 363 | 363 | array( |
| 364 | 364 | 'iframe' => array( |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | 'class' => true, |
| 369 | 369 | ), |
| 370 | 370 | ), |
| 371 | - wp_kses_allowed_html( 'post' ) |
|
| 371 | + wp_kses_allowed_html('post') |
|
| 372 | 372 | ) |
| 373 | 373 | ); |
| 374 | 374 | } |
@@ -381,8 +381,8 @@ discard block |
||
| 381 | 381 | * @param array $meta_query Meta query. |
| 382 | 382 | * @return array |
| 383 | 383 | */ |
| 384 | - protected function add_meta_query( $args, $meta_query ) { |
|
| 385 | - if ( empty( $args['meta_query'] ) ) { |
|
| 384 | + protected function add_meta_query($args, $meta_query) { |
|
| 385 | + if (empty($args['meta_query'])) { |
|
| 386 | 386 | $args['meta_query'] = array(); |
| 387 | 387 | } |
| 388 | 388 | |
@@ -403,25 +403,25 @@ discard block |
||
| 403 | 403 | 'type' => 'object', |
| 404 | 404 | 'properties' => array( |
| 405 | 405 | 'create' => array( |
| 406 | - 'description' => __( 'List of created resources.', 'invoicing' ), |
|
| 406 | + 'description' => __('List of created resources.', 'invoicing'), |
|
| 407 | 407 | 'type' => 'array', |
| 408 | - 'context' => array( 'view', 'edit' ), |
|
| 408 | + 'context' => array('view', 'edit'), |
|
| 409 | 409 | 'items' => array( |
| 410 | 410 | 'type' => 'object', |
| 411 | 411 | ), |
| 412 | 412 | ), |
| 413 | 413 | 'update' => array( |
| 414 | - 'description' => __( 'List of updated resources.', 'invoicing' ), |
|
| 414 | + 'description' => __('List of updated resources.', 'invoicing'), |
|
| 415 | 415 | 'type' => 'array', |
| 416 | - 'context' => array( 'view', 'edit' ), |
|
| 416 | + 'context' => array('view', 'edit'), |
|
| 417 | 417 | 'items' => array( |
| 418 | 418 | 'type' => 'object', |
| 419 | 419 | ), |
| 420 | 420 | ), |
| 421 | 421 | 'delete' => array( |
| 422 | - 'description' => __( 'List of deleted resources.', 'invoicing' ), |
|
| 422 | + 'description' => __('List of deleted resources.', 'invoicing'), |
|
| 423 | 423 | 'type' => 'array', |
| 424 | - 'context' => array( 'view', 'edit' ), |
|
| 424 | + 'context' => array('view', 'edit'), |
|
| 425 | 425 | 'items' => array( |
| 426 | 426 | 'type' => 'integer', |
| 427 | 427 | ), |
@@ -442,57 +442,57 @@ discard block |
||
| 442 | 442 | * @param WP_REST_Request $request Full details about the request. |
| 443 | 443 | * @return array Fields to be included in the response. |
| 444 | 444 | */ |
| 445 | - public function get_fields_for_response( $request ) { |
|
| 445 | + public function get_fields_for_response($request) { |
|
| 446 | 446 | $schema = $this->get_item_schema(); |
| 447 | - $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); |
|
| 447 | + $properties = isset($schema['properties']) ? $schema['properties'] : array(); |
|
| 448 | 448 | |
| 449 | 449 | $additional_fields = $this->get_additional_fields(); |
| 450 | - foreach ( $additional_fields as $field_name => $field_options ) { |
|
| 450 | + foreach ($additional_fields as $field_name => $field_options) { |
|
| 451 | 451 | // For back-compat, include any field with an empty schema |
| 452 | 452 | // because it won't be present in $this->get_item_schema(). |
| 453 | - if ( is_null( $field_options['schema'] ) ) { |
|
| 454 | - $properties[ $field_name ] = $field_options; |
|
| 453 | + if (is_null($field_options['schema'])) { |
|
| 454 | + $properties[$field_name] = $field_options; |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Exclude fields that specify a different context than the request context. |
| 459 | 459 | $context = $request['context']; |
| 460 | - if ( $context ) { |
|
| 461 | - foreach ( $properties as $name => $options ) { |
|
| 462 | - if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) { |
|
| 463 | - unset( $properties[ $name ] ); |
|
| 460 | + if ($context) { |
|
| 461 | + foreach ($properties as $name => $options) { |
|
| 462 | + if (!empty($options['context']) && !in_array($context, $options['context'], true)) { |
|
| 463 | + unset($properties[$name]); |
|
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $fields = array_keys( $properties ); |
|
| 468 | + $fields = array_keys($properties); |
|
| 469 | 469 | |
| 470 | - if ( ! isset( $request['_fields'] ) ) { |
|
| 470 | + if (!isset($request['_fields'])) { |
|
| 471 | 471 | return $fields; |
| 472 | 472 | } |
| 473 | - $requested_fields = wpinv_parse_list( $request['_fields'] ); |
|
| 474 | - if ( 0 === count( $requested_fields ) ) { |
|
| 473 | + $requested_fields = wpinv_parse_list($request['_fields']); |
|
| 474 | + if (0 === count($requested_fields)) { |
|
| 475 | 475 | return $fields; |
| 476 | 476 | } |
| 477 | 477 | // Trim off outside whitespace from the comma delimited list. |
| 478 | - $requested_fields = array_map( 'trim', $requested_fields ); |
|
| 478 | + $requested_fields = array_map('trim', $requested_fields); |
|
| 479 | 479 | // Always persist 'id', because it can be needed for add_additional_fields_to_object(). |
| 480 | - if ( in_array( 'id', $fields, true ) ) { |
|
| 480 | + if (in_array('id', $fields, true)) { |
|
| 481 | 481 | $requested_fields[] = 'id'; |
| 482 | 482 | } |
| 483 | 483 | // Return the list of all requested fields which appear in the schema. |
| 484 | 484 | return array_reduce( |
| 485 | 485 | $requested_fields, |
| 486 | - function( $response_fields, $field ) use ( $fields ) { |
|
| 487 | - if ( in_array( $field, $fields, true ) ) { |
|
| 486 | + function($response_fields, $field) use ($fields) { |
|
| 487 | + if (in_array($field, $fields, true)) { |
|
| 488 | 488 | $response_fields[] = $field; |
| 489 | 489 | return $response_fields; |
| 490 | 490 | } |
| 491 | 491 | // Check for nested fields if $field is not a direct match. |
| 492 | - $nested_fields = explode( '.', $field ); |
|
| 492 | + $nested_fields = explode('.', $field); |
|
| 493 | 493 | // A nested field is included so long as its top-level property is |
| 494 | 494 | // present in the schema. |
| 495 | - if ( in_array( $nested_fields[0], $fields, true ) ) { |
|
| 495 | + if (in_array($nested_fields[0], $fields, true)) { |
|
| 496 | 496 | $response_fields[] = $field; |
| 497 | 497 | } |
| 498 | 498 | return $response_fields; |
@@ -515,20 +515,20 @@ discard block |
||
| 515 | 515 | * @return bool Whether to include the field or not. |
| 516 | 516 | * @see rest_is_field_included() |
| 517 | 517 | */ |
| 518 | - public function is_field_included( $field, $fields ) { |
|
| 519 | - if ( in_array( $field, $fields, true ) ) { |
|
| 518 | + public function is_field_included($field, $fields) { |
|
| 519 | + if (in_array($field, $fields, true)) { |
|
| 520 | 520 | return true; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - foreach ( $fields as $accepted_field ) { |
|
| 523 | + foreach ($fields as $accepted_field) { |
|
| 524 | 524 | // Check to see if $field is the parent of any item in $fields. |
| 525 | 525 | // A field "parent" should be accepted if "parent.child" is accepted. |
| 526 | - if ( strpos( $accepted_field, "$field." ) === 0 ) { |
|
| 526 | + if (strpos($accepted_field, "$field.") === 0) { |
|
| 527 | 527 | return true; |
| 528 | 528 | } |
| 529 | 529 | // Conversely, if "parent" is accepted, all "parent.child" fields |
| 530 | 530 | // should also be accepted. |
| 531 | - if ( strpos( $field, "$accepted_field." ) === 0 ) { |
|
| 531 | + if (strpos($field, "$accepted_field.") === 0) { |
|
| 532 | 532 | return true; |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -15,136 +15,136 @@ |
||
| 15 | 15 | class WPInv_REST_Invoice_Controller extends GetPaid_REST_Posts_Controller { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Post type. |
|
| 19 | - * |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - protected $post_type = 'wpi_invoice'; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * The base of this controller's route. |
|
| 26 | - * |
|
| 27 | - * @since 1.0.13 |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - protected $rest_base = 'invoices'; |
|
| 31 | - |
|
| 32 | - /** Contains this controller's class name. |
|
| 33 | - * |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - public $crud_class = 'WPInv_Invoice'; |
|
| 18 | + * Post type. |
|
| 19 | + * |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + protected $post_type = 'wpi_invoice'; |
|
| 37 | 23 | |
| 38 | 24 | /** |
| 39 | - * Retrieves the query params for the invoices collection. |
|
| 40 | - * |
|
| 41 | - * @since 1.0.13 |
|
| 42 | - * |
|
| 43 | - * @return array Collection parameters. |
|
| 44 | - */ |
|
| 45 | - public function get_collection_params() { |
|
| 46 | - |
|
| 47 | - $params = array_merge( |
|
| 48 | - |
|
| 49 | - parent::get_collection_params(), |
|
| 50 | - |
|
| 51 | - array( |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - 'customers' => array( |
|
| 55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 56 | - 'type' => 'array', |
|
| 57 | - 'items' => array( |
|
| 58 | - 'type' => 'integer', |
|
| 59 | - ), |
|
| 60 | - 'default' => array(), |
|
| 61 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 62 | - ), |
|
| 63 | - |
|
| 64 | - 'exclude_customers' => array( |
|
| 65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 66 | - 'type' => 'array', |
|
| 67 | - 'items' => array( |
|
| 68 | - 'type' => 'integer', |
|
| 69 | - ), |
|
| 70 | - 'default' => array(), |
|
| 71 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 72 | - ) |
|
| 73 | - |
|
| 74 | - ) |
|
| 75 | - |
|
| 76 | - ); |
|
| 77 | - |
|
| 78 | - // Filter collection parameters for the invoices controller. |
|
| 79 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Get all the WP Query vars that are allowed for the API request. |
|
| 84 | - * |
|
| 85 | - * @return array |
|
| 86 | - */ |
|
| 87 | - protected function get_allowed_query_vars() { |
|
| 88 | - |
|
| 89 | - $vars = array_merge( |
|
| 90 | - array( |
|
| 91 | - 'customers', |
|
| 92 | - 'exclude_customers' |
|
| 93 | - ), |
|
| 94 | - parent::get_allowed_query_vars() |
|
| 95 | - ); |
|
| 96 | - |
|
| 97 | - return apply_filters( 'getpaid_rest_invoices_allowed_query_vars', $vars, $this ); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Determine the allowed query_vars for a get_items() response and |
|
| 102 | - * prepare for WP_Query. |
|
| 103 | - * |
|
| 104 | - * @param array $prepared_args Prepared arguments. |
|
| 105 | - * @param WP_REST_Request $request Request object. |
|
| 106 | - * @return array $query_args |
|
| 107 | - */ |
|
| 108 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 109 | - |
|
| 110 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 111 | - |
|
| 112 | - // Retrieve invoices for specific customers. |
|
| 113 | - if ( isset( $query_args['customers'] ) ) { |
|
| 114 | - $query_args['author__in'] = $query_args['customers']; |
|
| 115 | - unset( $query_args['customers'] ); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // Skip invoices for specific customers. |
|
| 119 | - if ( isset( $query_args['exclude_customers'] ) ) { |
|
| 120 | - $query_args['author__not_in'] = $query_args['exclude_customers']; |
|
| 121 | - unset( $query_args['exclude_customers'] ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 125 | - |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * Retrieves a valid list of post statuses. |
|
| 130 | - * |
|
| 131 | - * @since 1.0.15 |
|
| 132 | - * |
|
| 133 | - * @return array A list of registered item statuses. |
|
| 134 | - */ |
|
| 135 | - public function get_post_statuses() { |
|
| 136 | - return array_keys( wpinv_get_invoice_statuses( true ) ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Saves a single invoice. |
|
| 141 | - * |
|
| 142 | - * @param WPInv_Invoice $invoice Invoice to save. |
|
| 143 | - * @return WP_Error|WPInv_Invoice |
|
| 144 | - */ |
|
| 145 | - protected function save_object( $invoice ) { |
|
| 146 | - $invoice->recalculate_total(); |
|
| 147 | - return parent::save_object( $invoice ); |
|
| 148 | - } |
|
| 25 | + * The base of this controller's route. |
|
| 26 | + * |
|
| 27 | + * @since 1.0.13 |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + protected $rest_base = 'invoices'; |
|
| 31 | + |
|
| 32 | + /** Contains this controller's class name. |
|
| 33 | + * |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + public $crud_class = 'WPInv_Invoice'; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Retrieves the query params for the invoices collection. |
|
| 40 | + * |
|
| 41 | + * @since 1.0.13 |
|
| 42 | + * |
|
| 43 | + * @return array Collection parameters. |
|
| 44 | + */ |
|
| 45 | + public function get_collection_params() { |
|
| 46 | + |
|
| 47 | + $params = array_merge( |
|
| 48 | + |
|
| 49 | + parent::get_collection_params(), |
|
| 50 | + |
|
| 51 | + array( |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + 'customers' => array( |
|
| 55 | + 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 56 | + 'type' => 'array', |
|
| 57 | + 'items' => array( |
|
| 58 | + 'type' => 'integer', |
|
| 59 | + ), |
|
| 60 | + 'default' => array(), |
|
| 61 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 62 | + ), |
|
| 63 | + |
|
| 64 | + 'exclude_customers' => array( |
|
| 65 | + 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 66 | + 'type' => 'array', |
|
| 67 | + 'items' => array( |
|
| 68 | + 'type' => 'integer', |
|
| 69 | + ), |
|
| 70 | + 'default' => array(), |
|
| 71 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 72 | + ) |
|
| 73 | + |
|
| 74 | + ) |
|
| 75 | + |
|
| 76 | + ); |
|
| 77 | + |
|
| 78 | + // Filter collection parameters for the invoices controller. |
|
| 79 | + return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Get all the WP Query vars that are allowed for the API request. |
|
| 84 | + * |
|
| 85 | + * @return array |
|
| 86 | + */ |
|
| 87 | + protected function get_allowed_query_vars() { |
|
| 88 | + |
|
| 89 | + $vars = array_merge( |
|
| 90 | + array( |
|
| 91 | + 'customers', |
|
| 92 | + 'exclude_customers' |
|
| 93 | + ), |
|
| 94 | + parent::get_allowed_query_vars() |
|
| 95 | + ); |
|
| 96 | + |
|
| 97 | + return apply_filters( 'getpaid_rest_invoices_allowed_query_vars', $vars, $this ); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Determine the allowed query_vars for a get_items() response and |
|
| 102 | + * prepare for WP_Query. |
|
| 103 | + * |
|
| 104 | + * @param array $prepared_args Prepared arguments. |
|
| 105 | + * @param WP_REST_Request $request Request object. |
|
| 106 | + * @return array $query_args |
|
| 107 | + */ |
|
| 108 | + protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 109 | + |
|
| 110 | + $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 111 | + |
|
| 112 | + // Retrieve invoices for specific customers. |
|
| 113 | + if ( isset( $query_args['customers'] ) ) { |
|
| 114 | + $query_args['author__in'] = $query_args['customers']; |
|
| 115 | + unset( $query_args['customers'] ); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // Skip invoices for specific customers. |
|
| 119 | + if ( isset( $query_args['exclude_customers'] ) ) { |
|
| 120 | + $query_args['author__not_in'] = $query_args['exclude_customers']; |
|
| 121 | + unset( $query_args['exclude_customers'] ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 125 | + |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Retrieves a valid list of post statuses. |
|
| 130 | + * |
|
| 131 | + * @since 1.0.15 |
|
| 132 | + * |
|
| 133 | + * @return array A list of registered item statuses. |
|
| 134 | + */ |
|
| 135 | + public function get_post_statuses() { |
|
| 136 | + return array_keys( wpinv_get_invoice_statuses( true ) ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Saves a single invoice. |
|
| 141 | + * |
|
| 142 | + * @param WPInv_Invoice $invoice Invoice to save. |
|
| 143 | + * @return WP_Error|WPInv_Invoice |
|
| 144 | + */ |
|
| 145 | + protected function save_object( $invoice ) { |
|
| 146 | + $invoice->recalculate_total(); |
|
| 147 | + return parent::save_object( $invoice ); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.0.19 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * REST API invoices controller class. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | 'customers' => array( |
| 55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 55 | + 'description' => __('Limit result set to invoices for specific user ids.', 'invoicing'), |
|
| 56 | 56 | 'type' => 'array', |
| 57 | 57 | 'items' => array( |
| 58 | 58 | 'type' => 'integer', |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ), |
| 63 | 63 | |
| 64 | 64 | 'exclude_customers' => array( |
| 65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 65 | + 'description' => __('Exclude invoices to specific users.', 'invoicing'), |
|
| 66 | 66 | 'type' => 'array', |
| 67 | 67 | 'items' => array( |
| 68 | 68 | 'type' => 'integer', |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | // Filter collection parameters for the invoices controller. |
| 79 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 79 | + return apply_filters('getpaid_rest_invoices_collection_params', $params, $this); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | parent::get_allowed_query_vars() |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - return apply_filters( 'getpaid_rest_invoices_allowed_query_vars', $vars, $this ); |
|
| 97 | + return apply_filters('getpaid_rest_invoices_allowed_query_vars', $vars, $this); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -105,23 +105,23 @@ discard block |
||
| 105 | 105 | * @param WP_REST_Request $request Request object. |
| 106 | 106 | * @return array $query_args |
| 107 | 107 | */ |
| 108 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 108 | + protected function prepare_items_query($prepared_args = array(), $request = null) { |
|
| 109 | 109 | |
| 110 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 110 | + $query_args = parent::prepare_items_query($prepared_args); |
|
| 111 | 111 | |
| 112 | 112 | // Retrieve invoices for specific customers. |
| 113 | - if ( isset( $query_args['customers'] ) ) { |
|
| 113 | + if (isset($query_args['customers'])) { |
|
| 114 | 114 | $query_args['author__in'] = $query_args['customers']; |
| 115 | - unset( $query_args['customers'] ); |
|
| 115 | + unset($query_args['customers']); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Skip invoices for specific customers. |
| 119 | - if ( isset( $query_args['exclude_customers'] ) ) { |
|
| 119 | + if (isset($query_args['exclude_customers'])) { |
|
| 120 | 120 | $query_args['author__not_in'] = $query_args['exclude_customers']; |
| 121 | - unset( $query_args['exclude_customers'] ); |
|
| 121 | + unset($query_args['exclude_customers']); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 124 | + return apply_filters('getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this); |
|
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @return array A list of registered item statuses. |
| 134 | 134 | */ |
| 135 | 135 | public function get_post_statuses() { |
| 136 | - return array_keys( wpinv_get_invoice_statuses( true ) ); |
|
| 136 | + return array_keys(wpinv_get_invoice_statuses(true)); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * @param WPInv_Invoice $invoice Invoice to save. |
| 143 | 143 | * @return WP_Error|WPInv_Invoice |
| 144 | 144 | */ |
| 145 | - protected function save_object( $invoice ) { |
|
| 145 | + protected function save_object($invoice) { |
|
| 146 | 146 | $invoice->recalculate_total(); |
| 147 | - return parent::save_object( $invoice ); |
|
| 147 | + return parent::save_object($invoice); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
@@ -18,977 +18,977 @@ |
||
| 18 | 18 | class GetPaid_REST_Posts_Controller extends GetPaid_REST_Controller { |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Post type. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $post_type; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Controls visibility on frontend. |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - public $public = false; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Contains this controller's class name. |
|
| 36 | - * |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - public $crud_class; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Registers the routes for the objects of the controller. |
|
| 43 | - * |
|
| 44 | - * @since 1.0.19 |
|
| 45 | - * |
|
| 46 | - * @see register_rest_route() |
|
| 47 | - */ |
|
| 48 | - public function register_namespace_routes( $namespace ) { |
|
| 49 | - |
|
| 50 | - register_rest_route( |
|
| 51 | - $namespace, |
|
| 52 | - '/' . $this->rest_base, |
|
| 53 | - array( |
|
| 54 | - array( |
|
| 55 | - 'methods' => WP_REST_Server::READABLE, |
|
| 56 | - 'callback' => array( $this, 'get_items' ), |
|
| 57 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 58 | - 'args' => $this->get_collection_params(), |
|
| 59 | - ), |
|
| 60 | - array( |
|
| 61 | - 'methods' => WP_REST_Server::CREATABLE, |
|
| 62 | - 'callback' => array( $this, 'create_item' ), |
|
| 63 | - 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 64 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 65 | - ), |
|
| 66 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 67 | - ) |
|
| 68 | - ); |
|
| 69 | - |
|
| 70 | - $get_item_args = array( |
|
| 71 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 72 | - ); |
|
| 73 | - |
|
| 74 | - register_rest_route( |
|
| 75 | - $namespace, |
|
| 76 | - '/' . $this->rest_base . '/(?P<id>[\d]+)', |
|
| 77 | - array( |
|
| 78 | - 'args' => array( |
|
| 79 | - 'id' => array( |
|
| 80 | - 'description' => __( 'Unique identifier for the object.', 'invoicing' ), |
|
| 81 | - 'type' => 'integer', |
|
| 82 | - ), |
|
| 83 | - ), |
|
| 84 | - array( |
|
| 85 | - 'methods' => WP_REST_Server::READABLE, |
|
| 86 | - 'callback' => array( $this, 'get_item' ), |
|
| 87 | - 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 88 | - 'args' => $get_item_args, |
|
| 89 | - ), |
|
| 90 | - array( |
|
| 91 | - 'methods' => WP_REST_Server::EDITABLE, |
|
| 92 | - 'callback' => array( $this, 'update_item' ), |
|
| 93 | - 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 94 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 95 | - ), |
|
| 96 | - array( |
|
| 97 | - 'methods' => WP_REST_Server::DELETABLE, |
|
| 98 | - 'callback' => array( $this, 'delete_item' ), |
|
| 99 | - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 100 | - 'args' => array( |
|
| 101 | - 'force' => array( |
|
| 102 | - 'type' => 'boolean', |
|
| 103 | - 'default' => false, |
|
| 104 | - 'description' => __( 'Whether to bypass Trash and force deletion.', 'invoicing' ), |
|
| 105 | - ), |
|
| 106 | - ), |
|
| 107 | - ), |
|
| 108 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 109 | - ) |
|
| 110 | - ); |
|
| 111 | - |
|
| 112 | - register_rest_route( |
|
| 113 | - $namespace, |
|
| 114 | - '/' . $this->rest_base . '/batch', |
|
| 115 | - array( |
|
| 116 | - array( |
|
| 117 | - 'methods' => WP_REST_Server::EDITABLE, |
|
| 118 | - 'callback' => array( $this, 'batch_items' ), |
|
| 119 | - 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 120 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 121 | - ), |
|
| 122 | - 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 123 | - ) |
|
| 124 | - ); |
|
| 125 | - |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * Check permissions of items on REST API. |
|
| 130 | - * |
|
| 131 | - * @since 1.0.19 |
|
| 132 | - * @param string $context Request context. |
|
| 133 | - * @param int $object_id Post ID. |
|
| 134 | - * @return bool |
|
| 135 | - */ |
|
| 136 | - public function check_post_permissions( $context = 'read', $object_id = 0 ) { |
|
| 137 | - return true; |
|
| 138 | - $contexts = array( |
|
| 139 | - 'read' => 'read_private_posts', |
|
| 140 | - 'create' => 'publish_posts', |
|
| 141 | - 'edit' => 'edit_post', |
|
| 142 | - 'delete' => 'delete_post', |
|
| 143 | - 'batch' => 'edit_others_posts', |
|
| 144 | - ); |
|
| 145 | - |
|
| 146 | - if ( 'revision' === $this->post_type ) { |
|
| 147 | - $permission = false; |
|
| 148 | - } else { |
|
| 149 | - $cap = $contexts[ $context ]; |
|
| 150 | - $post_type_object = get_post_type_object( $this->post_type ); |
|
| 151 | - $permission = current_user_can( $post_type_object->cap->$cap, $object_id ); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return apply_filters( 'getpaid_rest_check_permissions', $permission, $context, $object_id, $this->post_type ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Check if a given request has access to read items. |
|
| 159 | - * |
|
| 160 | - * @param WP_REST_Request $request Full details about the request. |
|
| 161 | - * @return WP_Error|boolean |
|
| 162 | - */ |
|
| 163 | - public function get_items_permissions_check( $request ) { |
|
| 164 | - return $this->check_post_permissions() ? true : new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot list resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Check if a given request has access to create an item. |
|
| 169 | - * |
|
| 170 | - * @param WP_REST_Request $request Full details about the request. |
|
| 171 | - * @return WP_Error|boolean |
|
| 172 | - */ |
|
| 173 | - public function create_item_permissions_check( $request ) { |
|
| 174 | - return $this->check_post_permissions( 'create' ) ? true : new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Check if a given request has access to read an item. |
|
| 179 | - * |
|
| 180 | - * @param WP_REST_Request $request Full details about the request. |
|
| 181 | - * @return WP_Error|boolean |
|
| 182 | - */ |
|
| 183 | - public function get_item_permissions_check( $request ) { |
|
| 184 | - $post = get_post( (int) $request['id'] ); |
|
| 185 | - |
|
| 186 | - if ( $post && ! $this->check_post_permissions( 'read', $post->ID ) ) { |
|
| 187 | - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Check if a given request has access to update an item. |
|
| 195 | - * |
|
| 196 | - * @param WP_REST_Request $request Full details about the request. |
|
| 197 | - * @return WP_Error|boolean |
|
| 198 | - */ |
|
| 199 | - public function update_item_permissions_check( $request ) { |
|
| 200 | - $post = get_post( (int) $request['id'] ); |
|
| 201 | - |
|
| 202 | - if ( $post && ! $this->check_post_permissions( 'edit', $post->ID ) ) { |
|
| 203 | - return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - return true; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Check if a given request has access to delete an item. |
|
| 211 | - * |
|
| 212 | - * @param WP_REST_Request $request Full details about the request. |
|
| 213 | - * @return bool|WP_Error |
|
| 214 | - */ |
|
| 215 | - public function delete_item_permissions_check( $request ) { |
|
| 216 | - $post = get_post( (int) $request['id'] ); |
|
| 217 | - |
|
| 218 | - if ( $post && ! $this->check_post_permissions( 'delete', $post->ID ) ) { |
|
| 219 | - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - return true; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Check if a given request has access batch create, update and delete items. |
|
| 227 | - * |
|
| 228 | - * @param WP_REST_Request $request Full details about the request. |
|
| 229 | - * |
|
| 230 | - * @return boolean|WP_Error |
|
| 231 | - */ |
|
| 232 | - public function batch_items_permissions_check( $request ) { |
|
| 233 | - return $this->check_post_permissions( 'batch' ) ? true : new WP_Error( 'rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Saves a single object. |
|
| 238 | - * |
|
| 239 | - * @param GetPaid_Data $object Object to save. |
|
| 240 | - * @return WP_Error|GetPaid_Data |
|
| 241 | - */ |
|
| 242 | - protected function save_object( $object ) { |
|
| 243 | - $object->save(); |
|
| 244 | - |
|
| 245 | - if ( ! empty( $object->last_error ) ) { |
|
| 246 | - return new WP_Error( 'rest_cannot_save', $object->last_error, array( 'status' => 400 ) ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return new $this->crud_class( $object->get_id() ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Returns the item's object. |
|
| 254 | - * |
|
| 255 | - * Child classes must implement this method. |
|
| 256 | - * @since 1.0.13 |
|
| 257 | - * |
|
| 258 | - * @param int|WP_Post $object_id Supplied ID. |
|
| 259 | - * @return GetPaid_Data|WP_Error GetPaid_Data object if ID is valid, WP_Error otherwise. |
|
| 260 | - */ |
|
| 261 | - protected function get_object( $object_id ) { |
|
| 262 | - |
|
| 263 | - // Do we have an object? |
|
| 264 | - if ( empty( $this->crud_class ) || ! class_exists( $this->crud_class ) ) { |
|
| 265 | - return new WP_Error( 'no_crud_class', __( 'You need to specify a CRUD class for this controller', 'invoicing' ) ); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - // Fetch the object. |
|
| 269 | - $object = new $this->crud_class( $object_id ); |
|
| 270 | - if ( ! empty( $object->last_error ) ) { |
|
| 271 | - return new WP_Error( 'rest_object_invalid_id', $object->last_error, array( 'status' => 404 ) ); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - return $object->get_id() ? $object : new WP_Error( 'rest_object_invalid_id', __( 'Invalid ID.', 'invoicing' ), array( 'status' => 404 ) ); |
|
| 275 | - |
|
| 276 | - } |
|
| 21 | + * Post type. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $post_type; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Controls visibility on frontend. |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + public $public = false; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Contains this controller's class name. |
|
| 36 | + * |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + public $crud_class; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Registers the routes for the objects of the controller. |
|
| 43 | + * |
|
| 44 | + * @since 1.0.19 |
|
| 45 | + * |
|
| 46 | + * @see register_rest_route() |
|
| 47 | + */ |
|
| 48 | + public function register_namespace_routes( $namespace ) { |
|
| 49 | + |
|
| 50 | + register_rest_route( |
|
| 51 | + $namespace, |
|
| 52 | + '/' . $this->rest_base, |
|
| 53 | + array( |
|
| 54 | + array( |
|
| 55 | + 'methods' => WP_REST_Server::READABLE, |
|
| 56 | + 'callback' => array( $this, 'get_items' ), |
|
| 57 | + 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 58 | + 'args' => $this->get_collection_params(), |
|
| 59 | + ), |
|
| 60 | + array( |
|
| 61 | + 'methods' => WP_REST_Server::CREATABLE, |
|
| 62 | + 'callback' => array( $this, 'create_item' ), |
|
| 63 | + 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 64 | + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 65 | + ), |
|
| 66 | + 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 67 | + ) |
|
| 68 | + ); |
|
| 69 | + |
|
| 70 | + $get_item_args = array( |
|
| 71 | + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 72 | + ); |
|
| 73 | + |
|
| 74 | + register_rest_route( |
|
| 75 | + $namespace, |
|
| 76 | + '/' . $this->rest_base . '/(?P<id>[\d]+)', |
|
| 77 | + array( |
|
| 78 | + 'args' => array( |
|
| 79 | + 'id' => array( |
|
| 80 | + 'description' => __( 'Unique identifier for the object.', 'invoicing' ), |
|
| 81 | + 'type' => 'integer', |
|
| 82 | + ), |
|
| 83 | + ), |
|
| 84 | + array( |
|
| 85 | + 'methods' => WP_REST_Server::READABLE, |
|
| 86 | + 'callback' => array( $this, 'get_item' ), |
|
| 87 | + 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 88 | + 'args' => $get_item_args, |
|
| 89 | + ), |
|
| 90 | + array( |
|
| 91 | + 'methods' => WP_REST_Server::EDITABLE, |
|
| 92 | + 'callback' => array( $this, 'update_item' ), |
|
| 93 | + 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 94 | + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 95 | + ), |
|
| 96 | + array( |
|
| 97 | + 'methods' => WP_REST_Server::DELETABLE, |
|
| 98 | + 'callback' => array( $this, 'delete_item' ), |
|
| 99 | + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 100 | + 'args' => array( |
|
| 101 | + 'force' => array( |
|
| 102 | + 'type' => 'boolean', |
|
| 103 | + 'default' => false, |
|
| 104 | + 'description' => __( 'Whether to bypass Trash and force deletion.', 'invoicing' ), |
|
| 105 | + ), |
|
| 106 | + ), |
|
| 107 | + ), |
|
| 108 | + 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 109 | + ) |
|
| 110 | + ); |
|
| 111 | + |
|
| 112 | + register_rest_route( |
|
| 113 | + $namespace, |
|
| 114 | + '/' . $this->rest_base . '/batch', |
|
| 115 | + array( |
|
| 116 | + array( |
|
| 117 | + 'methods' => WP_REST_Server::EDITABLE, |
|
| 118 | + 'callback' => array( $this, 'batch_items' ), |
|
| 119 | + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 120 | + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 121 | + ), |
|
| 122 | + 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 123 | + ) |
|
| 124 | + ); |
|
| 125 | + |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Check permissions of items on REST API. |
|
| 130 | + * |
|
| 131 | + * @since 1.0.19 |
|
| 132 | + * @param string $context Request context. |
|
| 133 | + * @param int $object_id Post ID. |
|
| 134 | + * @return bool |
|
| 135 | + */ |
|
| 136 | + public function check_post_permissions( $context = 'read', $object_id = 0 ) { |
|
| 137 | + return true; |
|
| 138 | + $contexts = array( |
|
| 139 | + 'read' => 'read_private_posts', |
|
| 140 | + 'create' => 'publish_posts', |
|
| 141 | + 'edit' => 'edit_post', |
|
| 142 | + 'delete' => 'delete_post', |
|
| 143 | + 'batch' => 'edit_others_posts', |
|
| 144 | + ); |
|
| 145 | + |
|
| 146 | + if ( 'revision' === $this->post_type ) { |
|
| 147 | + $permission = false; |
|
| 148 | + } else { |
|
| 149 | + $cap = $contexts[ $context ]; |
|
| 150 | + $post_type_object = get_post_type_object( $this->post_type ); |
|
| 151 | + $permission = current_user_can( $post_type_object->cap->$cap, $object_id ); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return apply_filters( 'getpaid_rest_check_permissions', $permission, $context, $object_id, $this->post_type ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Check if a given request has access to read items. |
|
| 159 | + * |
|
| 160 | + * @param WP_REST_Request $request Full details about the request. |
|
| 161 | + * @return WP_Error|boolean |
|
| 162 | + */ |
|
| 163 | + public function get_items_permissions_check( $request ) { |
|
| 164 | + return $this->check_post_permissions() ? true : new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot list resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Check if a given request has access to create an item. |
|
| 169 | + * |
|
| 170 | + * @param WP_REST_Request $request Full details about the request. |
|
| 171 | + * @return WP_Error|boolean |
|
| 172 | + */ |
|
| 173 | + public function create_item_permissions_check( $request ) { |
|
| 174 | + return $this->check_post_permissions( 'create' ) ? true : new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Check if a given request has access to read an item. |
|
| 179 | + * |
|
| 180 | + * @param WP_REST_Request $request Full details about the request. |
|
| 181 | + * @return WP_Error|boolean |
|
| 182 | + */ |
|
| 183 | + public function get_item_permissions_check( $request ) { |
|
| 184 | + $post = get_post( (int) $request['id'] ); |
|
| 185 | + |
|
| 186 | + if ( $post && ! $this->check_post_permissions( 'read', $post->ID ) ) { |
|
| 187 | + return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Check if a given request has access to update an item. |
|
| 195 | + * |
|
| 196 | + * @param WP_REST_Request $request Full details about the request. |
|
| 197 | + * @return WP_Error|boolean |
|
| 198 | + */ |
|
| 199 | + public function update_item_permissions_check( $request ) { |
|
| 200 | + $post = get_post( (int) $request['id'] ); |
|
| 201 | + |
|
| 202 | + if ( $post && ! $this->check_post_permissions( 'edit', $post->ID ) ) { |
|
| 203 | + return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + return true; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Check if a given request has access to delete an item. |
|
| 211 | + * |
|
| 212 | + * @param WP_REST_Request $request Full details about the request. |
|
| 213 | + * @return bool|WP_Error |
|
| 214 | + */ |
|
| 215 | + public function delete_item_permissions_check( $request ) { |
|
| 216 | + $post = get_post( (int) $request['id'] ); |
|
| 217 | + |
|
| 218 | + if ( $post && ! $this->check_post_permissions( 'delete', $post->ID ) ) { |
|
| 219 | + return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + return true; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Check if a given request has access batch create, update and delete items. |
|
| 227 | + * |
|
| 228 | + * @param WP_REST_Request $request Full details about the request. |
|
| 229 | + * |
|
| 230 | + * @return boolean|WP_Error |
|
| 231 | + */ |
|
| 232 | + public function batch_items_permissions_check( $request ) { |
|
| 233 | + return $this->check_post_permissions( 'batch' ) ? true : new WP_Error( 'rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Saves a single object. |
|
| 238 | + * |
|
| 239 | + * @param GetPaid_Data $object Object to save. |
|
| 240 | + * @return WP_Error|GetPaid_Data |
|
| 241 | + */ |
|
| 242 | + protected function save_object( $object ) { |
|
| 243 | + $object->save(); |
|
| 244 | + |
|
| 245 | + if ( ! empty( $object->last_error ) ) { |
|
| 246 | + return new WP_Error( 'rest_cannot_save', $object->last_error, array( 'status' => 400 ) ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return new $this->crud_class( $object->get_id() ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Returns the item's object. |
|
| 254 | + * |
|
| 255 | + * Child classes must implement this method. |
|
| 256 | + * @since 1.0.13 |
|
| 257 | + * |
|
| 258 | + * @param int|WP_Post $object_id Supplied ID. |
|
| 259 | + * @return GetPaid_Data|WP_Error GetPaid_Data object if ID is valid, WP_Error otherwise. |
|
| 260 | + */ |
|
| 261 | + protected function get_object( $object_id ) { |
|
| 262 | + |
|
| 263 | + // Do we have an object? |
|
| 264 | + if ( empty( $this->crud_class ) || ! class_exists( $this->crud_class ) ) { |
|
| 265 | + return new WP_Error( 'no_crud_class', __( 'You need to specify a CRUD class for this controller', 'invoicing' ) ); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + // Fetch the object. |
|
| 269 | + $object = new $this->crud_class( $object_id ); |
|
| 270 | + if ( ! empty( $object->last_error ) ) { |
|
| 271 | + return new WP_Error( 'rest_object_invalid_id', $object->last_error, array( 'status' => 404 ) ); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + return $object->get_id() ? $object : new WP_Error( 'rest_object_invalid_id', __( 'Invalid ID.', 'invoicing' ), array( 'status' => 404 ) ); |
|
| 275 | + |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * @deprecated |
|
| 280 | - */ |
|
| 281 | - public function get_post( $object_id ) { |
|
| 282 | - return $this->get_object( $object_id ); |
|
| 278 | + /** |
|
| 279 | + * @deprecated |
|
| 280 | + */ |
|
| 281 | + public function get_post( $object_id ) { |
|
| 282 | + return $this->get_object( $object_id ); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Get a single object. |
|
| 287 | + * |
|
| 288 | + * @param WP_REST_Request $request Full details about the request. |
|
| 289 | + * @return WP_Error|WP_REST_Response |
|
| 290 | + */ |
|
| 291 | + public function get_item( $request ) { |
|
| 292 | + |
|
| 293 | + // Fetch the item. |
|
| 294 | + $object = $this->get_object( $request['id'] ); |
|
| 295 | + |
|
| 296 | + if ( is_wp_error( $object ) ) { |
|
| 297 | + return $object; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + // Generate a response. |
|
| 301 | + $data = $this->prepare_item_for_response( $object, $request ); |
|
| 302 | + $response = rest_ensure_response( $data ); |
|
| 303 | + |
|
| 304 | + // (Maybe) add a link to the html pagee. |
|
| 305 | + if ( $this->public && ! is_wp_error( $response ) ) { |
|
| 306 | + $response->link_header( 'alternate', get_permalink( $object->get_id() ), array( 'type' => 'text/html' ) ); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $response; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Create a single object. |
|
| 314 | + * |
|
| 315 | + * @param WP_REST_Request $request Full details about the request. |
|
| 316 | + * @return WP_Error|WP_REST_Response |
|
| 317 | + */ |
|
| 318 | + public function create_item( $request ) { |
|
| 319 | + |
|
| 320 | + // Can not create an existing item. |
|
| 321 | + if ( ! empty( $request['id'] ) ) { |
|
| 322 | + /* translators: %s: post type */ |
|
| 323 | + return new WP_Error( "getpaid_rest_{$this->post_type}_exists", __( 'Cannot create existing resource.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + // Generate a GetPaid_Data object from the request. |
|
| 327 | + $object = $this->prepare_item_for_database( $request ); |
|
| 328 | + if ( is_wp_error( $object ) ) { |
|
| 329 | + return $object; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + // Save the object. |
|
| 333 | + $object = $this->save_object( $object ); |
|
| 334 | + if ( is_wp_error( $object ) ) { |
|
| 335 | + return $object; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + // Save special fields. |
|
| 339 | + $save_special = $this->update_additional_fields_for_object( $object, $request ); |
|
| 340 | + if ( is_wp_error( $save_special ) ) { |
|
| 341 | + $object->delete( true ); |
|
| 342 | + return $save_special; |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * Fires after a single item is created or updated via the REST API. |
|
| 347 | + * |
|
| 348 | + * @param WP_Post $post Post object. |
|
| 349 | + * @param WP_REST_Request $request Request object. |
|
| 350 | + * @param boolean $creating True when creating item, false when updating. |
|
| 351 | + */ |
|
| 352 | + do_action( "getpaid_rest_insert_{$this->post_type}", $object, $request, true ); |
|
| 353 | + |
|
| 354 | + $request->set_param( 'context', 'edit' ); |
|
| 355 | + $response = $this->prepare_item_for_response( $object, $request ); |
|
| 356 | + $response = rest_ensure_response( $response ); |
|
| 357 | + $response->set_status( 201 ); |
|
| 358 | + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ) ); |
|
| 359 | + |
|
| 360 | + return $response; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * Update a single object. |
|
| 365 | + * |
|
| 366 | + * @param WP_REST_Request $request Full details about the request. |
|
| 367 | + * @return WP_Error|WP_REST_Response |
|
| 368 | + */ |
|
| 369 | + public function update_item( $request ) { |
|
| 370 | + |
|
| 371 | + // Fetch the item. |
|
| 372 | + $object = $this->get_object( $request['id'] ); |
|
| 373 | + if ( is_wp_error( $object ) ) { |
|
| 374 | + return $object; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + // Prepare the item for saving. |
|
| 378 | + $object = $this->prepare_item_for_database( $request ); |
|
| 379 | + if ( is_wp_error( $object ) ) { |
|
| 380 | + return $object; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + // Save the item. |
|
| 384 | + $object = $this->save_object( $object ); |
|
| 385 | + if ( is_wp_error( $object ) ) { |
|
| 386 | + return $object; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + // Save special fields (those added via hooks). |
|
| 390 | + $save_special = $this->update_additional_fields_for_object( $object, $request ); |
|
| 391 | + if ( is_wp_error( $save_special ) ) { |
|
| 392 | + return $save_special; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Fires after a single item is created or updated via the REST API. |
|
| 397 | + * |
|
| 398 | + * @param GetPaid_Data $object GetPaid_Data object. |
|
| 399 | + * @param WP_REST_Request $request Request object. |
|
| 400 | + * @param boolean $creating True when creating item, false when updating. |
|
| 401 | + */ |
|
| 402 | + do_action( "getpaid_rest_insert_{$this->post_type}", $object, $request, false ); |
|
| 403 | + |
|
| 404 | + $request->set_param( 'context', 'edit' ); |
|
| 405 | + $response = $this->prepare_item_for_response( $object, $request ); |
|
| 406 | + return rest_ensure_response( $response ); |
|
| 283 | 407 | } |
| 284 | 408 | |
| 285 | - /** |
|
| 286 | - * Get a single object. |
|
| 287 | - * |
|
| 288 | - * @param WP_REST_Request $request Full details about the request. |
|
| 289 | - * @return WP_Error|WP_REST_Response |
|
| 290 | - */ |
|
| 291 | - public function get_item( $request ) { |
|
| 292 | - |
|
| 293 | - // Fetch the item. |
|
| 294 | - $object = $this->get_object( $request['id'] ); |
|
| 295 | - |
|
| 296 | - if ( is_wp_error( $object ) ) { |
|
| 297 | - return $object; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // Generate a response. |
|
| 301 | - $data = $this->prepare_item_for_response( $object, $request ); |
|
| 302 | - $response = rest_ensure_response( $data ); |
|
| 303 | - |
|
| 304 | - // (Maybe) add a link to the html pagee. |
|
| 305 | - if ( $this->public && ! is_wp_error( $response ) ) { |
|
| 306 | - $response->link_header( 'alternate', get_permalink( $object->get_id() ), array( 'type' => 'text/html' ) ); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $response; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Create a single object. |
|
| 314 | - * |
|
| 315 | - * @param WP_REST_Request $request Full details about the request. |
|
| 316 | - * @return WP_Error|WP_REST_Response |
|
| 317 | - */ |
|
| 318 | - public function create_item( $request ) { |
|
| 319 | - |
|
| 320 | - // Can not create an existing item. |
|
| 321 | - if ( ! empty( $request['id'] ) ) { |
|
| 322 | - /* translators: %s: post type */ |
|
| 323 | - return new WP_Error( "getpaid_rest_{$this->post_type}_exists", __( 'Cannot create existing resource.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - // Generate a GetPaid_Data object from the request. |
|
| 327 | - $object = $this->prepare_item_for_database( $request ); |
|
| 328 | - if ( is_wp_error( $object ) ) { |
|
| 329 | - return $object; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - // Save the object. |
|
| 333 | - $object = $this->save_object( $object ); |
|
| 334 | - if ( is_wp_error( $object ) ) { |
|
| 335 | - return $object; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - // Save special fields. |
|
| 339 | - $save_special = $this->update_additional_fields_for_object( $object, $request ); |
|
| 340 | - if ( is_wp_error( $save_special ) ) { |
|
| 341 | - $object->delete( true ); |
|
| 342 | - return $save_special; |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * Fires after a single item is created or updated via the REST API. |
|
| 347 | - * |
|
| 348 | - * @param WP_Post $post Post object. |
|
| 349 | - * @param WP_REST_Request $request Request object. |
|
| 350 | - * @param boolean $creating True when creating item, false when updating. |
|
| 351 | - */ |
|
| 352 | - do_action( "getpaid_rest_insert_{$this->post_type}", $object, $request, true ); |
|
| 353 | - |
|
| 354 | - $request->set_param( 'context', 'edit' ); |
|
| 355 | - $response = $this->prepare_item_for_response( $object, $request ); |
|
| 356 | - $response = rest_ensure_response( $response ); |
|
| 357 | - $response->set_status( 201 ); |
|
| 358 | - $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ) ); |
|
| 359 | - |
|
| 360 | - return $response; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * Update a single object. |
|
| 365 | - * |
|
| 366 | - * @param WP_REST_Request $request Full details about the request. |
|
| 367 | - * @return WP_Error|WP_REST_Response |
|
| 368 | - */ |
|
| 369 | - public function update_item( $request ) { |
|
| 370 | - |
|
| 371 | - // Fetch the item. |
|
| 372 | - $object = $this->get_object( $request['id'] ); |
|
| 373 | - if ( is_wp_error( $object ) ) { |
|
| 374 | - return $object; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - // Prepare the item for saving. |
|
| 378 | - $object = $this->prepare_item_for_database( $request ); |
|
| 379 | - if ( is_wp_error( $object ) ) { |
|
| 380 | - return $object; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - // Save the item. |
|
| 384 | - $object = $this->save_object( $object ); |
|
| 385 | - if ( is_wp_error( $object ) ) { |
|
| 386 | - return $object; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - // Save special fields (those added via hooks). |
|
| 390 | - $save_special = $this->update_additional_fields_for_object( $object, $request ); |
|
| 391 | - if ( is_wp_error( $save_special ) ) { |
|
| 392 | - return $save_special; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Fires after a single item is created or updated via the REST API. |
|
| 397 | - * |
|
| 398 | - * @param GetPaid_Data $object GetPaid_Data object. |
|
| 399 | - * @param WP_REST_Request $request Request object. |
|
| 400 | - * @param boolean $creating True when creating item, false when updating. |
|
| 401 | - */ |
|
| 402 | - do_action( "getpaid_rest_insert_{$this->post_type}", $object, $request, false ); |
|
| 403 | - |
|
| 404 | - $request->set_param( 'context', 'edit' ); |
|
| 405 | - $response = $this->prepare_item_for_response( $object, $request ); |
|
| 406 | - return rest_ensure_response( $response ); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * Get a collection of objects. |
|
| 411 | - * |
|
| 412 | - * @param WP_REST_Request $request Full details about the request. |
|
| 413 | - * @return WP_Error|WP_REST_Response |
|
| 414 | - */ |
|
| 415 | - public function get_items( $request ) { |
|
| 416 | - $args = array(); |
|
| 417 | - $args['offset'] = $request['offset']; |
|
| 418 | - $args['order'] = $request['order']; |
|
| 419 | - $args['orderby'] = $request['orderby']; |
|
| 420 | - $args['paged'] = $request['page']; |
|
| 421 | - $args['post__in'] = $request['include']; |
|
| 422 | - $args['post__not_in'] = $request['exclude']; |
|
| 423 | - $args['posts_per_page'] = $request['per_page']; |
|
| 424 | - $args['name'] = $request['slug']; |
|
| 425 | - $args['post_parent__in'] = $request['parent']; |
|
| 426 | - $args['post_parent__not_in'] = $request['parent_exclude']; |
|
| 427 | - $args['s'] = $request['search']; |
|
| 428 | - $args['post_status'] = $request['status'] == 'any' ? 'any' : wpinv_parse_list( $request['status'] ); |
|
| 429 | - |
|
| 430 | - $args['date_query'] = array(); |
|
| 431 | - // Set before into date query. Date query must be specified as an array of an array. |
|
| 432 | - if ( isset( $request['before'] ) ) { |
|
| 433 | - $args['date_query'][0]['before'] = $request['before']; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - // Set after into date query. Date query must be specified as an array of an array. |
|
| 437 | - if ( isset( $request['after'] ) ) { |
|
| 438 | - $args['date_query'][0]['after'] = $request['after']; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - // Force the post_type argument, since it's not a user input variable. |
|
| 442 | - $args['post_type'] = $this->post_type; |
|
| 443 | - |
|
| 444 | - // Filter the query arguments for a request. |
|
| 445 | - $args = apply_filters( "getpaid_rest_{$this->post_type}_query", $args, $request ); |
|
| 446 | - $query_args = $this->prepare_items_query( $args, $request ); |
|
| 447 | - |
|
| 448 | - $posts_query = new WP_Query(); |
|
| 449 | - $query_result = $posts_query->query( $query_args ); |
|
| 450 | - |
|
| 451 | - $posts = array(); |
|
| 452 | - foreach ( $query_result as $post ) { |
|
| 453 | - if ( ! $this->check_post_permissions( 'read', $post->ID ) ) { |
|
| 454 | - continue; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - $data = $this->prepare_item_for_response( $this->get_object( $post->ID ), $request ); |
|
| 458 | - $posts[] = $this->prepare_response_for_collection( $data ); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - $page = (int) $query_args['paged']; |
|
| 462 | - $total_posts = $posts_query->found_posts; |
|
| 463 | - |
|
| 464 | - if ( $total_posts < 1 ) { |
|
| 465 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 466 | - unset( $query_args['paged'] ); |
|
| 467 | - $count_query = new WP_Query(); |
|
| 468 | - $count_query->query( $query_args ); |
|
| 469 | - $total_posts = $count_query->found_posts; |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - $max_pages = ceil( $total_posts / (int) $query_args['posts_per_page'] ); |
|
| 473 | - |
|
| 474 | - $response = rest_ensure_response( $posts ); |
|
| 475 | - $response->header( 'X-WP-Total', (int) $total_posts ); |
|
| 476 | - $response->header( 'X-WP-TotalPages', (int) $max_pages ); |
|
| 477 | - |
|
| 478 | - $request_params = $request->get_query_params(); |
|
| 479 | - $base = add_query_arg( $request_params, rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); |
|
| 480 | - |
|
| 481 | - if ( $page > 1 ) { |
|
| 482 | - $prev_page = $page - 1; |
|
| 483 | - if ( $prev_page > $max_pages ) { |
|
| 484 | - $prev_page = $max_pages; |
|
| 485 | - } |
|
| 486 | - $prev_link = add_query_arg( 'page', $prev_page, $base ); |
|
| 487 | - $response->link_header( 'prev', $prev_link ); |
|
| 488 | - } |
|
| 489 | - if ( $max_pages > $page ) { |
|
| 490 | - $next_page = $page + 1; |
|
| 491 | - $next_link = add_query_arg( 'page', $next_page, $base ); |
|
| 492 | - $response->link_header( 'next', $next_link ); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - return $response; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - /** |
|
| 499 | - * Delete a single item. |
|
| 500 | - * |
|
| 501 | - * @param WP_REST_Request $request Full details about the request. |
|
| 502 | - * @return WP_REST_Response|WP_Error |
|
| 503 | - */ |
|
| 504 | - public function delete_item( $request ) { |
|
| 505 | - |
|
| 506 | - // Fetch the item. |
|
| 507 | - $item = $this->get_object( $request['id'] ); |
|
| 508 | - if ( is_wp_error( $item ) ) { |
|
| 509 | - return $item; |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - $supports_trash = EMPTY_TRASH_DAYS > 0; |
|
| 513 | - $force = $supports_trash && (bool) $request['force']; |
|
| 514 | - |
|
| 515 | - if ( ! $this->check_post_permissions( 'delete', $item->ID ) ) { |
|
| 516 | - return new WP_Error( "cannot_delete", __( 'Sorry, you are not allowed to delete this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - $request->set_param( 'context', 'edit' ); |
|
| 520 | - $response = $this->prepare_item_for_response( $item, $request ); |
|
| 521 | - |
|
| 522 | - if ( ! wp_delete_post( $item->ID, $force ) ) { |
|
| 523 | - return new WP_Error( 'rest_cannot_delete', sprintf( __( 'The resource cannot be deleted.', 'invoicing' ), $this->post_type ), array( 'status' => 500 ) ); |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - return $response; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Prepare links for the request. |
|
| 531 | - * |
|
| 532 | - * @param GetPaid_Data $object GetPaid_Data object. |
|
| 533 | - * @return array Links for the given object. |
|
| 534 | - */ |
|
| 535 | - protected function prepare_links( $object ) { |
|
| 536 | - |
|
| 537 | - $links = array( |
|
| 538 | - 'self' => array( |
|
| 539 | - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), |
|
| 540 | - ), |
|
| 541 | - 'collection' => array( |
|
| 542 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
|
| 543 | - ), |
|
| 544 | - ); |
|
| 545 | - |
|
| 546 | - if ( is_callable( array( $object, 'get_user_id' ) ) ) { |
|
| 547 | - $links['user'] = array( |
|
| 548 | - 'href' => rest_url( 'wp/v2/users/' . call_user_func( array( $object, 'get_user_id' ) ) ), |
|
| 549 | - 'embeddable' => true, |
|
| 550 | - ); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - return $links; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * Determine the allowed query_vars for a get_items() response and |
|
| 558 | - * prepare for WP_Query. |
|
| 559 | - * |
|
| 560 | - * @param array $prepared_args Prepared arguments. |
|
| 561 | - * @param WP_REST_Request $request Request object. |
|
| 562 | - * @return array $query_args |
|
| 563 | - */ |
|
| 564 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 565 | - |
|
| 566 | - $valid_vars = array_flip( $this->get_allowed_query_vars() ); |
|
| 567 | - $query_args = array(); |
|
| 568 | - foreach ( $valid_vars as $var => $index ) { |
|
| 569 | - if ( isset( $prepared_args[ $var ] ) ) { |
|
| 570 | - $query_args[ $var ] = apply_filters( "getpaid_rest_query_var-{$var}", $prepared_args[ $var ] ); |
|
| 571 | - } |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - $query_args['ignore_sticky_posts'] = true; |
|
| 575 | - |
|
| 576 | - if ( 'include' === $query_args['orderby'] ) { |
|
| 577 | - $query_args['orderby'] = 'post__in'; |
|
| 578 | - } elseif ( 'id' === $query_args['orderby'] ) { |
|
| 579 | - $query_args['orderby'] = 'ID'; // ID must be capitalized. |
|
| 580 | - } elseif ( 'slug' === $query_args['orderby'] ) { |
|
| 581 | - $query_args['orderby'] = 'name'; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - return apply_filters( 'getpaid_rest_prepare_items_query', $query_args, $request, $this ); |
|
| 585 | - |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Get all the WP Query vars that are allowed for the API request. |
|
| 590 | - * |
|
| 591 | - * @return array |
|
| 592 | - */ |
|
| 593 | - protected function get_allowed_query_vars() { |
|
| 594 | - global $wp; |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * Filter the publicly allowed query vars. |
|
| 598 | - * |
|
| 599 | - * Allows adjusting of the default query vars that are made public. |
|
| 600 | - * |
|
| 601 | - * @param array Array of allowed WP_Query query vars. |
|
| 602 | - */ |
|
| 603 | - $valid_vars = apply_filters( 'query_vars', $wp->public_query_vars ); |
|
| 604 | - |
|
| 605 | - $post_type_obj = get_post_type_object( $this->post_type ); |
|
| 606 | - if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
|
| 607 | - $private = apply_filters( 'getpaid_rest_private_query_vars', $wp->private_query_vars ); |
|
| 608 | - $valid_vars = array_merge( $valid_vars, $private ); |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - // Define our own in addition to WP's normal vars. |
|
| 612 | - $rest_valid = array( |
|
| 613 | - 'post_status', |
|
| 614 | - 'date_query', |
|
| 615 | - 'ignore_sticky_posts', |
|
| 616 | - 'offset', |
|
| 617 | - 'post__in', |
|
| 618 | - 'post__not_in', |
|
| 619 | - 'post_parent', |
|
| 620 | - 'post_parent__in', |
|
| 621 | - 'post_parent__not_in', |
|
| 622 | - 'posts_per_page', |
|
| 623 | - 'meta_query', |
|
| 624 | - 'tax_query', |
|
| 625 | - 'meta_key', |
|
| 626 | - 'meta_value', |
|
| 627 | - 'meta_compare', |
|
| 628 | - 'meta_value_num', |
|
| 629 | - ); |
|
| 630 | - $valid_vars = array_merge( $valid_vars, $rest_valid ); |
|
| 631 | - |
|
| 632 | - // Filter allowed query vars for the REST API. |
|
| 633 | - $valid_vars = apply_filters( 'getpaid_rest_query_vars', $valid_vars, $this ); |
|
| 634 | - |
|
| 635 | - return $valid_vars; |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * Get the query params for collections of attachments. |
|
| 640 | - * |
|
| 641 | - * @return array |
|
| 642 | - */ |
|
| 643 | - public function get_collection_params() { |
|
| 644 | - $params = parent::get_collection_params(); |
|
| 645 | - |
|
| 646 | - $params['context']['default'] = 'view'; |
|
| 647 | - |
|
| 648 | - $params['status'] = array( |
|
| 649 | - 'default' => 'any', |
|
| 650 | - 'description' => __( 'Limit result set to resources assigned one or more statuses.', 'invoicing' ), |
|
| 651 | - 'type' => array( 'array', 'string' ), |
|
| 652 | - 'items' => array( |
|
| 653 | - 'enum' => array_merge( array( 'any' ), $this->get_post_statuses() ), |
|
| 654 | - 'type' => 'string', |
|
| 655 | - ), |
|
| 656 | - 'sanitize_callback' => 'rest_validate_request_arg', |
|
| 657 | - ); |
|
| 658 | - |
|
| 659 | - $params['after'] = array( |
|
| 660 | - 'description' => __( 'Limit response to resources created after a given ISO8601 compliant date.', 'invoicing' ), |
|
| 661 | - 'type' => 'string', |
|
| 662 | - 'format' => 'string', |
|
| 663 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 664 | - ); |
|
| 665 | - $params['before'] = array( |
|
| 666 | - 'description' => __( 'Limit response to resources created before a given ISO8601 compliant date.', 'invoicing' ), |
|
| 667 | - 'type' => 'string', |
|
| 668 | - 'format' => 'string', |
|
| 669 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 670 | - ); |
|
| 671 | - $params['exclude'] = array( |
|
| 672 | - 'description' => __( 'Ensure result set excludes specific IDs.', 'invoicing' ), |
|
| 673 | - 'type' => 'array', |
|
| 674 | - 'items' => array( |
|
| 675 | - 'type' => 'integer', |
|
| 676 | - ), |
|
| 677 | - 'default' => array(), |
|
| 678 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 679 | - ); |
|
| 680 | - $params['include'] = array( |
|
| 681 | - 'description' => __( 'Limit result set to specific ids.', 'invoicing' ), |
|
| 682 | - 'type' => 'array', |
|
| 683 | - 'items' => array( |
|
| 684 | - 'type' => 'integer', |
|
| 685 | - ), |
|
| 686 | - 'default' => array(), |
|
| 687 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 688 | - ); |
|
| 689 | - $params['offset'] = array( |
|
| 690 | - 'description' => __( 'Offset the result set by a specific number of items.', 'invoicing' ), |
|
| 691 | - 'type' => 'integer', |
|
| 692 | - 'sanitize_callback' => 'absint', |
|
| 693 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 694 | - ); |
|
| 695 | - $params['order'] = array( |
|
| 696 | - 'description' => __( 'Order sort attribute ascending or descending.', 'invoicing' ), |
|
| 697 | - 'type' => 'string', |
|
| 698 | - 'default' => 'desc', |
|
| 699 | - 'enum' => array( 'asc', 'desc' ), |
|
| 700 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 701 | - ); |
|
| 702 | - $params['orderby'] = array( |
|
| 703 | - 'description' => __( 'Sort collection by object attribute.', 'invoicing' ), |
|
| 704 | - 'type' => 'string', |
|
| 705 | - 'default' => 'date', |
|
| 706 | - 'enum' => array( |
|
| 707 | - 'date', |
|
| 708 | - 'id', |
|
| 709 | - 'include', |
|
| 710 | - 'title', |
|
| 711 | - 'slug', |
|
| 712 | - 'modified', |
|
| 713 | - ), |
|
| 714 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 715 | - ); |
|
| 716 | - |
|
| 717 | - $post_type_obj = get_post_type_object( $this->post_type ); |
|
| 718 | - |
|
| 719 | - if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) { |
|
| 720 | - $params['parent'] = array( |
|
| 721 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 722 | - 'type' => 'array', |
|
| 723 | - 'items' => array( |
|
| 724 | - 'type' => 'integer', |
|
| 725 | - ), |
|
| 726 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 727 | - 'default' => array(), |
|
| 728 | - ); |
|
| 729 | - $params['parent_exclude'] = array( |
|
| 730 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 731 | - 'type' => 'array', |
|
| 732 | - 'items' => array( |
|
| 733 | - 'type' => 'integer', |
|
| 734 | - ), |
|
| 735 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
| 736 | - 'default' => array(), |
|
| 737 | - ); |
|
| 738 | - } |
|
| 739 | - |
|
| 740 | - return $params; |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - /** |
|
| 744 | - * Retrieves the items's schema, conforming to JSON Schema. |
|
| 745 | - * |
|
| 746 | - * @since 1.0.19 |
|
| 747 | - * |
|
| 748 | - * @return array Item schema data. |
|
| 749 | - */ |
|
| 750 | - public function get_item_schema() { |
|
| 751 | - |
|
| 752 | - // Maybe retrieve the schema from cache. |
|
| 753 | - if ( $this->schema ) { |
|
| 754 | - return $this->add_additional_fields_schema( $this->schema ); |
|
| 755 | - } |
|
| 756 | - |
|
| 757 | - $type = str_replace( 'wpi_', '', $this->post_type ); |
|
| 758 | - $schema = array( |
|
| 759 | - '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
| 760 | - 'title' => $this->post_type, |
|
| 761 | - 'type' => 'object', |
|
| 762 | - 'properties' => wpinv_get_data( "$type-schema" ), |
|
| 763 | - ); |
|
| 764 | - |
|
| 765 | - // Filters the invoice schema for the REST API. |
|
| 409 | + /** |
|
| 410 | + * Get a collection of objects. |
|
| 411 | + * |
|
| 412 | + * @param WP_REST_Request $request Full details about the request. |
|
| 413 | + * @return WP_Error|WP_REST_Response |
|
| 414 | + */ |
|
| 415 | + public function get_items( $request ) { |
|
| 416 | + $args = array(); |
|
| 417 | + $args['offset'] = $request['offset']; |
|
| 418 | + $args['order'] = $request['order']; |
|
| 419 | + $args['orderby'] = $request['orderby']; |
|
| 420 | + $args['paged'] = $request['page']; |
|
| 421 | + $args['post__in'] = $request['include']; |
|
| 422 | + $args['post__not_in'] = $request['exclude']; |
|
| 423 | + $args['posts_per_page'] = $request['per_page']; |
|
| 424 | + $args['name'] = $request['slug']; |
|
| 425 | + $args['post_parent__in'] = $request['parent']; |
|
| 426 | + $args['post_parent__not_in'] = $request['parent_exclude']; |
|
| 427 | + $args['s'] = $request['search']; |
|
| 428 | + $args['post_status'] = $request['status'] == 'any' ? 'any' : wpinv_parse_list( $request['status'] ); |
|
| 429 | + |
|
| 430 | + $args['date_query'] = array(); |
|
| 431 | + // Set before into date query. Date query must be specified as an array of an array. |
|
| 432 | + if ( isset( $request['before'] ) ) { |
|
| 433 | + $args['date_query'][0]['before'] = $request['before']; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + // Set after into date query. Date query must be specified as an array of an array. |
|
| 437 | + if ( isset( $request['after'] ) ) { |
|
| 438 | + $args['date_query'][0]['after'] = $request['after']; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + // Force the post_type argument, since it's not a user input variable. |
|
| 442 | + $args['post_type'] = $this->post_type; |
|
| 443 | + |
|
| 444 | + // Filter the query arguments for a request. |
|
| 445 | + $args = apply_filters( "getpaid_rest_{$this->post_type}_query", $args, $request ); |
|
| 446 | + $query_args = $this->prepare_items_query( $args, $request ); |
|
| 447 | + |
|
| 448 | + $posts_query = new WP_Query(); |
|
| 449 | + $query_result = $posts_query->query( $query_args ); |
|
| 450 | + |
|
| 451 | + $posts = array(); |
|
| 452 | + foreach ( $query_result as $post ) { |
|
| 453 | + if ( ! $this->check_post_permissions( 'read', $post->ID ) ) { |
|
| 454 | + continue; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + $data = $this->prepare_item_for_response( $this->get_object( $post->ID ), $request ); |
|
| 458 | + $posts[] = $this->prepare_response_for_collection( $data ); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + $page = (int) $query_args['paged']; |
|
| 462 | + $total_posts = $posts_query->found_posts; |
|
| 463 | + |
|
| 464 | + if ( $total_posts < 1 ) { |
|
| 465 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 466 | + unset( $query_args['paged'] ); |
|
| 467 | + $count_query = new WP_Query(); |
|
| 468 | + $count_query->query( $query_args ); |
|
| 469 | + $total_posts = $count_query->found_posts; |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + $max_pages = ceil( $total_posts / (int) $query_args['posts_per_page'] ); |
|
| 473 | + |
|
| 474 | + $response = rest_ensure_response( $posts ); |
|
| 475 | + $response->header( 'X-WP-Total', (int) $total_posts ); |
|
| 476 | + $response->header( 'X-WP-TotalPages', (int) $max_pages ); |
|
| 477 | + |
|
| 478 | + $request_params = $request->get_query_params(); |
|
| 479 | + $base = add_query_arg( $request_params, rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); |
|
| 480 | + |
|
| 481 | + if ( $page > 1 ) { |
|
| 482 | + $prev_page = $page - 1; |
|
| 483 | + if ( $prev_page > $max_pages ) { |
|
| 484 | + $prev_page = $max_pages; |
|
| 485 | + } |
|
| 486 | + $prev_link = add_query_arg( 'page', $prev_page, $base ); |
|
| 487 | + $response->link_header( 'prev', $prev_link ); |
|
| 488 | + } |
|
| 489 | + if ( $max_pages > $page ) { |
|
| 490 | + $next_page = $page + 1; |
|
| 491 | + $next_link = add_query_arg( 'page', $next_page, $base ); |
|
| 492 | + $response->link_header( 'next', $next_link ); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + return $response; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + /** |
|
| 499 | + * Delete a single item. |
|
| 500 | + * |
|
| 501 | + * @param WP_REST_Request $request Full details about the request. |
|
| 502 | + * @return WP_REST_Response|WP_Error |
|
| 503 | + */ |
|
| 504 | + public function delete_item( $request ) { |
|
| 505 | + |
|
| 506 | + // Fetch the item. |
|
| 507 | + $item = $this->get_object( $request['id'] ); |
|
| 508 | + if ( is_wp_error( $item ) ) { |
|
| 509 | + return $item; |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + $supports_trash = EMPTY_TRASH_DAYS > 0; |
|
| 513 | + $force = $supports_trash && (bool) $request['force']; |
|
| 514 | + |
|
| 515 | + if ( ! $this->check_post_permissions( 'delete', $item->ID ) ) { |
|
| 516 | + return new WP_Error( "cannot_delete", __( 'Sorry, you are not allowed to delete this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + $request->set_param( 'context', 'edit' ); |
|
| 520 | + $response = $this->prepare_item_for_response( $item, $request ); |
|
| 521 | + |
|
| 522 | + if ( ! wp_delete_post( $item->ID, $force ) ) { |
|
| 523 | + return new WP_Error( 'rest_cannot_delete', sprintf( __( 'The resource cannot be deleted.', 'invoicing' ), $this->post_type ), array( 'status' => 500 ) ); |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + return $response; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * Prepare links for the request. |
|
| 531 | + * |
|
| 532 | + * @param GetPaid_Data $object GetPaid_Data object. |
|
| 533 | + * @return array Links for the given object. |
|
| 534 | + */ |
|
| 535 | + protected function prepare_links( $object ) { |
|
| 536 | + |
|
| 537 | + $links = array( |
|
| 538 | + 'self' => array( |
|
| 539 | + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), |
|
| 540 | + ), |
|
| 541 | + 'collection' => array( |
|
| 542 | + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
|
| 543 | + ), |
|
| 544 | + ); |
|
| 545 | + |
|
| 546 | + if ( is_callable( array( $object, 'get_user_id' ) ) ) { |
|
| 547 | + $links['user'] = array( |
|
| 548 | + 'href' => rest_url( 'wp/v2/users/' . call_user_func( array( $object, 'get_user_id' ) ) ), |
|
| 549 | + 'embeddable' => true, |
|
| 550 | + ); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + return $links; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * Determine the allowed query_vars for a get_items() response and |
|
| 558 | + * prepare for WP_Query. |
|
| 559 | + * |
|
| 560 | + * @param array $prepared_args Prepared arguments. |
|
| 561 | + * @param WP_REST_Request $request Request object. |
|
| 562 | + * @return array $query_args |
|
| 563 | + */ |
|
| 564 | + protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 565 | + |
|
| 566 | + $valid_vars = array_flip( $this->get_allowed_query_vars() ); |
|
| 567 | + $query_args = array(); |
|
| 568 | + foreach ( $valid_vars as $var => $index ) { |
|
| 569 | + if ( isset( $prepared_args[ $var ] ) ) { |
|
| 570 | + $query_args[ $var ] = apply_filters( "getpaid_rest_query_var-{$var}", $prepared_args[ $var ] ); |
|
| 571 | + } |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + $query_args['ignore_sticky_posts'] = true; |
|
| 575 | + |
|
| 576 | + if ( 'include' === $query_args['orderby'] ) { |
|
| 577 | + $query_args['orderby'] = 'post__in'; |
|
| 578 | + } elseif ( 'id' === $query_args['orderby'] ) { |
|
| 579 | + $query_args['orderby'] = 'ID'; // ID must be capitalized. |
|
| 580 | + } elseif ( 'slug' === $query_args['orderby'] ) { |
|
| 581 | + $query_args['orderby'] = 'name'; |
|
| 582 | + } |
|
| 583 | + |
|
| 584 | + return apply_filters( 'getpaid_rest_prepare_items_query', $query_args, $request, $this ); |
|
| 585 | + |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Get all the WP Query vars that are allowed for the API request. |
|
| 590 | + * |
|
| 591 | + * @return array |
|
| 592 | + */ |
|
| 593 | + protected function get_allowed_query_vars() { |
|
| 594 | + global $wp; |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * Filter the publicly allowed query vars. |
|
| 598 | + * |
|
| 599 | + * Allows adjusting of the default query vars that are made public. |
|
| 600 | + * |
|
| 601 | + * @param array Array of allowed WP_Query query vars. |
|
| 602 | + */ |
|
| 603 | + $valid_vars = apply_filters( 'query_vars', $wp->public_query_vars ); |
|
| 604 | + |
|
| 605 | + $post_type_obj = get_post_type_object( $this->post_type ); |
|
| 606 | + if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
|
| 607 | + $private = apply_filters( 'getpaid_rest_private_query_vars', $wp->private_query_vars ); |
|
| 608 | + $valid_vars = array_merge( $valid_vars, $private ); |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + // Define our own in addition to WP's normal vars. |
|
| 612 | + $rest_valid = array( |
|
| 613 | + 'post_status', |
|
| 614 | + 'date_query', |
|
| 615 | + 'ignore_sticky_posts', |
|
| 616 | + 'offset', |
|
| 617 | + 'post__in', |
|
| 618 | + 'post__not_in', |
|
| 619 | + 'post_parent', |
|
| 620 | + 'post_parent__in', |
|
| 621 | + 'post_parent__not_in', |
|
| 622 | + 'posts_per_page', |
|
| 623 | + 'meta_query', |
|
| 624 | + 'tax_query', |
|
| 625 | + 'meta_key', |
|
| 626 | + 'meta_value', |
|
| 627 | + 'meta_compare', |
|
| 628 | + 'meta_value_num', |
|
| 629 | + ); |
|
| 630 | + $valid_vars = array_merge( $valid_vars, $rest_valid ); |
|
| 631 | + |
|
| 632 | + // Filter allowed query vars for the REST API. |
|
| 633 | + $valid_vars = apply_filters( 'getpaid_rest_query_vars', $valid_vars, $this ); |
|
| 634 | + |
|
| 635 | + return $valid_vars; |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * Get the query params for collections of attachments. |
|
| 640 | + * |
|
| 641 | + * @return array |
|
| 642 | + */ |
|
| 643 | + public function get_collection_params() { |
|
| 644 | + $params = parent::get_collection_params(); |
|
| 645 | + |
|
| 646 | + $params['context']['default'] = 'view'; |
|
| 647 | + |
|
| 648 | + $params['status'] = array( |
|
| 649 | + 'default' => 'any', |
|
| 650 | + 'description' => __( 'Limit result set to resources assigned one or more statuses.', 'invoicing' ), |
|
| 651 | + 'type' => array( 'array', 'string' ), |
|
| 652 | + 'items' => array( |
|
| 653 | + 'enum' => array_merge( array( 'any' ), $this->get_post_statuses() ), |
|
| 654 | + 'type' => 'string', |
|
| 655 | + ), |
|
| 656 | + 'sanitize_callback' => 'rest_validate_request_arg', |
|
| 657 | + ); |
|
| 658 | + |
|
| 659 | + $params['after'] = array( |
|
| 660 | + 'description' => __( 'Limit response to resources created after a given ISO8601 compliant date.', 'invoicing' ), |
|
| 661 | + 'type' => 'string', |
|
| 662 | + 'format' => 'string', |
|
| 663 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 664 | + ); |
|
| 665 | + $params['before'] = array( |
|
| 666 | + 'description' => __( 'Limit response to resources created before a given ISO8601 compliant date.', 'invoicing' ), |
|
| 667 | + 'type' => 'string', |
|
| 668 | + 'format' => 'string', |
|
| 669 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 670 | + ); |
|
| 671 | + $params['exclude'] = array( |
|
| 672 | + 'description' => __( 'Ensure result set excludes specific IDs.', 'invoicing' ), |
|
| 673 | + 'type' => 'array', |
|
| 674 | + 'items' => array( |
|
| 675 | + 'type' => 'integer', |
|
| 676 | + ), |
|
| 677 | + 'default' => array(), |
|
| 678 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 679 | + ); |
|
| 680 | + $params['include'] = array( |
|
| 681 | + 'description' => __( 'Limit result set to specific ids.', 'invoicing' ), |
|
| 682 | + 'type' => 'array', |
|
| 683 | + 'items' => array( |
|
| 684 | + 'type' => 'integer', |
|
| 685 | + ), |
|
| 686 | + 'default' => array(), |
|
| 687 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 688 | + ); |
|
| 689 | + $params['offset'] = array( |
|
| 690 | + 'description' => __( 'Offset the result set by a specific number of items.', 'invoicing' ), |
|
| 691 | + 'type' => 'integer', |
|
| 692 | + 'sanitize_callback' => 'absint', |
|
| 693 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 694 | + ); |
|
| 695 | + $params['order'] = array( |
|
| 696 | + 'description' => __( 'Order sort attribute ascending or descending.', 'invoicing' ), |
|
| 697 | + 'type' => 'string', |
|
| 698 | + 'default' => 'desc', |
|
| 699 | + 'enum' => array( 'asc', 'desc' ), |
|
| 700 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 701 | + ); |
|
| 702 | + $params['orderby'] = array( |
|
| 703 | + 'description' => __( 'Sort collection by object attribute.', 'invoicing' ), |
|
| 704 | + 'type' => 'string', |
|
| 705 | + 'default' => 'date', |
|
| 706 | + 'enum' => array( |
|
| 707 | + 'date', |
|
| 708 | + 'id', |
|
| 709 | + 'include', |
|
| 710 | + 'title', |
|
| 711 | + 'slug', |
|
| 712 | + 'modified', |
|
| 713 | + ), |
|
| 714 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 715 | + ); |
|
| 716 | + |
|
| 717 | + $post_type_obj = get_post_type_object( $this->post_type ); |
|
| 718 | + |
|
| 719 | + if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) { |
|
| 720 | + $params['parent'] = array( |
|
| 721 | + 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 722 | + 'type' => 'array', |
|
| 723 | + 'items' => array( |
|
| 724 | + 'type' => 'integer', |
|
| 725 | + ), |
|
| 726 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 727 | + 'default' => array(), |
|
| 728 | + ); |
|
| 729 | + $params['parent_exclude'] = array( |
|
| 730 | + 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 731 | + 'type' => 'array', |
|
| 732 | + 'items' => array( |
|
| 733 | + 'type' => 'integer', |
|
| 734 | + ), |
|
| 735 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
| 736 | + 'default' => array(), |
|
| 737 | + ); |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + return $params; |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + /** |
|
| 744 | + * Retrieves the items's schema, conforming to JSON Schema. |
|
| 745 | + * |
|
| 746 | + * @since 1.0.19 |
|
| 747 | + * |
|
| 748 | + * @return array Item schema data. |
|
| 749 | + */ |
|
| 750 | + public function get_item_schema() { |
|
| 751 | + |
|
| 752 | + // Maybe retrieve the schema from cache. |
|
| 753 | + if ( $this->schema ) { |
|
| 754 | + return $this->add_additional_fields_schema( $this->schema ); |
|
| 755 | + } |
|
| 756 | + |
|
| 757 | + $type = str_replace( 'wpi_', '', $this->post_type ); |
|
| 758 | + $schema = array( |
|
| 759 | + '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
| 760 | + 'title' => $this->post_type, |
|
| 761 | + 'type' => 'object', |
|
| 762 | + 'properties' => wpinv_get_data( "$type-schema" ), |
|
| 763 | + ); |
|
| 764 | + |
|
| 765 | + // Filters the invoice schema for the REST API. |
|
| 766 | 766 | $schema = apply_filters( "wpinv_rest_{$type}_schema", $schema ); |
| 767 | 767 | |
| 768 | - // Cache the invoice schema. |
|
| 769 | - $this->schema = $schema; |
|
| 770 | - |
|
| 771 | - return $this->add_additional_fields_schema( $this->schema ); |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - /** |
|
| 775 | - * Only return writable props from schema. |
|
| 776 | - * |
|
| 777 | - * @param array $schema Schema. |
|
| 778 | - * @return bool |
|
| 779 | - */ |
|
| 780 | - public function filter_writable_props( $schema ) { |
|
| 781 | - return empty( $schema['readonly'] ); |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - /** |
|
| 785 | - * Sanitizes and validates the list of post statuses. |
|
| 786 | - * |
|
| 787 | - * @since 1.0.13 |
|
| 788 | - * |
|
| 789 | - * @param string|array $statuses One or more post statuses. |
|
| 790 | - * @param WP_REST_Request $request Full details about the request. |
|
| 791 | - * @param string $parameter Additional parameter to pass to validation. |
|
| 792 | - * @return array|WP_Error A list of valid statuses, otherwise WP_Error object. |
|
| 793 | - */ |
|
| 794 | - public function sanitize_post_statuses( $statuses, $request, $parameter ) { |
|
| 795 | - return array_intersect( wp_parse_slug_list( $statuses ), $this->get_post_statuses() ); |
|
| 796 | - } |
|
| 797 | - |
|
| 798 | - /** |
|
| 799 | - * Retrieves a valid list of post statuses. |
|
| 800 | - * |
|
| 801 | - * @since 1.0.19 |
|
| 802 | - * |
|
| 803 | - * @return array A list of registered item statuses. |
|
| 804 | - */ |
|
| 805 | - public function get_post_statuses() { |
|
| 806 | - return get_post_stati(); |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - /** |
|
| 810 | - * Prepare a single object for create or update. |
|
| 811 | - * |
|
| 812 | - * @since 1.0.19 |
|
| 813 | - * @param WP_REST_Request $request Request object. |
|
| 814 | - * @return GetPaid_Data|WP_Error Data object or WP_Error. |
|
| 815 | - */ |
|
| 816 | - protected function prepare_item_for_database( $request ) { |
|
| 817 | - |
|
| 818 | - // Do we have an object? |
|
| 819 | - if ( empty( $this->crud_class ) || ! class_exists( $this->crud_class ) ) { |
|
| 820 | - return new WP_Error( 'no_crud_class', __( 'You need to specify a CRUD class for this controller', 'invoicing' ) ); |
|
| 821 | - } |
|
| 822 | - |
|
| 823 | - // Prepare the object. |
|
| 824 | - $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; |
|
| 825 | - $object = new $this->crud_class( $id ); |
|
| 826 | - |
|
| 827 | - // Abort if an error exists. |
|
| 828 | - if ( ! empty( $object->last_error ) ) { |
|
| 829 | - return new WP_Error( 'invalid_item', $object->last_error ); |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - $schema = $this->get_item_schema(); |
|
| 833 | - $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); |
|
| 834 | - |
|
| 835 | - // Handle all writable props. |
|
| 836 | - foreach ( $data_keys as $key ) { |
|
| 837 | - $value = $request[ $key ]; |
|
| 838 | - |
|
| 839 | - if ( ! is_null( $value ) ) { |
|
| 840 | - switch ( $key ) { |
|
| 841 | - |
|
| 842 | - case 'meta_data': |
|
| 843 | - if ( is_array( $value ) ) { |
|
| 844 | - foreach ( $value as $meta ) { |
|
| 845 | - $object->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
| 846 | - } |
|
| 847 | - } |
|
| 848 | - break; |
|
| 849 | - |
|
| 850 | - default: |
|
| 851 | - if ( is_callable( array( $object, "set_{$key}" ) ) ) { |
|
| 852 | - $object->{"set_{$key}"}( $value ); |
|
| 853 | - } |
|
| 854 | - break; |
|
| 855 | - } |
|
| 856 | - } |
|
| 857 | - |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - // Filters an object before it is inserted via the REST API.. |
|
| 861 | - return apply_filters( "getpaid_rest_pre_insert_{$this->post_type}_object", $object, $request ); |
|
| 862 | - } |
|
| 863 | - |
|
| 864 | - /** |
|
| 865 | - * Retrieves data from a GetPaid class. |
|
| 866 | - * |
|
| 867 | - * @since 1.0.19 |
|
| 868 | - * @param GetPaid_Meta_Data[] $meta_data meta data objects. |
|
| 869 | - * @return array |
|
| 870 | - */ |
|
| 871 | - protected function prepare_object_meta_data( $meta_data ) { |
|
| 872 | - $meta = array(); |
|
| 873 | - |
|
| 874 | - foreach( $meta_data as $object ) { |
|
| 875 | - $meta[] = $object->get_data(); |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - return $meta; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * Retrieves invoice items. |
|
| 883 | - * |
|
| 884 | - * @since 1.0.19 |
|
| 885 | - * @param WPInv_Invoice $invoice Invoice items. |
|
| 886 | - * @return array |
|
| 887 | - */ |
|
| 888 | - protected function prepare_invoice_items( $invoice ) { |
|
| 889 | - $items = array(); |
|
| 890 | - |
|
| 891 | - foreach( $invoice->get_items() as $item ) { |
|
| 892 | - $item_data = $item->prepare_data_for_saving(); |
|
| 893 | - |
|
| 894 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 895 | - $item_data['quantity'] = 1; |
|
| 896 | - } |
|
| 897 | - |
|
| 898 | - $items[] = $item_data; |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - return $items; |
|
| 902 | - } |
|
| 903 | - |
|
| 904 | - /** |
|
| 905 | - * Retrieves data from a GetPaid class. |
|
| 906 | - * |
|
| 907 | - * @since 1.0.19 |
|
| 908 | - * @param GetPaid_Data $object Data object. |
|
| 909 | - * @param array $fields Fields to include. |
|
| 910 | - * @param string $context either view or edit. |
|
| 911 | - * @return array |
|
| 912 | - */ |
|
| 913 | - protected function prepare_object_data( $object, $fields, $context = 'view' ) { |
|
| 914 | - |
|
| 915 | - $data = array(); |
|
| 916 | - $schema = $this->get_item_schema(); |
|
| 917 | - $data_keys = array_keys( $schema['properties'] ); |
|
| 918 | - |
|
| 919 | - // Handle all writable props. |
|
| 920 | - foreach ( $data_keys as $key ) { |
|
| 921 | - |
|
| 922 | - // Abort if it is not included. |
|
| 923 | - if ( ! empty( $fields ) && ! $this->is_field_included( $key, $fields ) ) { |
|
| 924 | - continue; |
|
| 925 | - } |
|
| 926 | - |
|
| 927 | - // Handle meta data. |
|
| 928 | - if ( $key == 'meta_data' ) { |
|
| 929 | - $data['meta_data'] = $this->prepare_object_meta_data( $object->get_meta_data() ); |
|
| 930 | - continue; |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - // Handle items. |
|
| 934 | - if ( $key == 'items' && is_a( $object, 'WPInv_Invoice' ) ) { |
|
| 935 | - $data['items'] = $this->prepare_invoice_items( $object ); |
|
| 936 | - continue; |
|
| 937 | - } |
|
| 938 | - |
|
| 939 | - // Booleans. |
|
| 940 | - if ( is_callable( array( $object, $key ) ) ) { |
|
| 941 | - $data[ $key ] = $object->$key( $context ); |
|
| 942 | - continue; |
|
| 943 | - } |
|
| 944 | - |
|
| 945 | - // Get object value. |
|
| 946 | - if ( is_callable( array( $object, "get_{$key}" ) ) ) { |
|
| 947 | - $value = $object->{"get_{$key}"}( $context ); |
|
| 948 | - |
|
| 949 | - // If the value is an instance of GetPaid_Data... |
|
| 950 | - if ( is_a( $value, 'GetPaid_Data' ) ) { |
|
| 951 | - $value = $value->get_data( $context ); |
|
| 952 | - } |
|
| 953 | - |
|
| 954 | - // For objects, retrieves it's properties. |
|
| 955 | - $data[ $key ] = is_object( $value ) ? get_object_vars( $value ) : $value ; |
|
| 956 | - continue; |
|
| 957 | - } |
|
| 958 | - |
|
| 959 | - // The value does not exist on an object. |
|
| 960 | - $data[ $key ] = apply_filters( "getpaid_{$this->post_type}_{$key}_object_data", null, $object ); |
|
| 961 | - |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - return $data; |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * Prepare a single object output for response. |
|
| 969 | - * |
|
| 970 | - * @since 1.0.19 |
|
| 971 | - * @param GetPaid_Data $object Data object. |
|
| 972 | - * @param WP_REST_Request $request Request object. |
|
| 973 | - * @return WP_REST_Response |
|
| 974 | - */ |
|
| 975 | - public function prepare_item_for_response( $object, $request ) { |
|
| 976 | - |
|
| 977 | - // Fetch the fields to include in this response. |
|
| 978 | - $fields = $this->get_fields_for_response( $request ); |
|
| 979 | - |
|
| 980 | - // Prepare object data. |
|
| 981 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 982 | - $data = $this->prepare_object_data( $object, $fields, $context ); |
|
| 983 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
| 984 | - $data = $this->filter_response_by_context( $data, $context ); |
|
| 985 | - |
|
| 986 | - // Prepare the response. |
|
| 987 | - $response = rest_ensure_response( $data ); |
|
| 988 | - $response->add_links( $this->prepare_links( $object, $request ) ); |
|
| 989 | - |
|
| 990 | - // Filter item response. |
|
| 991 | - return apply_filters( "getpaid_rest_prepare_{$this->post_type}_object", $response, $object, $request ); |
|
| 992 | - } |
|
| 768 | + // Cache the invoice schema. |
|
| 769 | + $this->schema = $schema; |
|
| 770 | + |
|
| 771 | + return $this->add_additional_fields_schema( $this->schema ); |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + /** |
|
| 775 | + * Only return writable props from schema. |
|
| 776 | + * |
|
| 777 | + * @param array $schema Schema. |
|
| 778 | + * @return bool |
|
| 779 | + */ |
|
| 780 | + public function filter_writable_props( $schema ) { |
|
| 781 | + return empty( $schema['readonly'] ); |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + /** |
|
| 785 | + * Sanitizes and validates the list of post statuses. |
|
| 786 | + * |
|
| 787 | + * @since 1.0.13 |
|
| 788 | + * |
|
| 789 | + * @param string|array $statuses One or more post statuses. |
|
| 790 | + * @param WP_REST_Request $request Full details about the request. |
|
| 791 | + * @param string $parameter Additional parameter to pass to validation. |
|
| 792 | + * @return array|WP_Error A list of valid statuses, otherwise WP_Error object. |
|
| 793 | + */ |
|
| 794 | + public function sanitize_post_statuses( $statuses, $request, $parameter ) { |
|
| 795 | + return array_intersect( wp_parse_slug_list( $statuses ), $this->get_post_statuses() ); |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + /** |
|
| 799 | + * Retrieves a valid list of post statuses. |
|
| 800 | + * |
|
| 801 | + * @since 1.0.19 |
|
| 802 | + * |
|
| 803 | + * @return array A list of registered item statuses. |
|
| 804 | + */ |
|
| 805 | + public function get_post_statuses() { |
|
| 806 | + return get_post_stati(); |
|
| 807 | + } |
|
| 808 | + |
|
| 809 | + /** |
|
| 810 | + * Prepare a single object for create or update. |
|
| 811 | + * |
|
| 812 | + * @since 1.0.19 |
|
| 813 | + * @param WP_REST_Request $request Request object. |
|
| 814 | + * @return GetPaid_Data|WP_Error Data object or WP_Error. |
|
| 815 | + */ |
|
| 816 | + protected function prepare_item_for_database( $request ) { |
|
| 817 | + |
|
| 818 | + // Do we have an object? |
|
| 819 | + if ( empty( $this->crud_class ) || ! class_exists( $this->crud_class ) ) { |
|
| 820 | + return new WP_Error( 'no_crud_class', __( 'You need to specify a CRUD class for this controller', 'invoicing' ) ); |
|
| 821 | + } |
|
| 822 | + |
|
| 823 | + // Prepare the object. |
|
| 824 | + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; |
|
| 825 | + $object = new $this->crud_class( $id ); |
|
| 826 | + |
|
| 827 | + // Abort if an error exists. |
|
| 828 | + if ( ! empty( $object->last_error ) ) { |
|
| 829 | + return new WP_Error( 'invalid_item', $object->last_error ); |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + $schema = $this->get_item_schema(); |
|
| 833 | + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); |
|
| 834 | + |
|
| 835 | + // Handle all writable props. |
|
| 836 | + foreach ( $data_keys as $key ) { |
|
| 837 | + $value = $request[ $key ]; |
|
| 838 | + |
|
| 839 | + if ( ! is_null( $value ) ) { |
|
| 840 | + switch ( $key ) { |
|
| 841 | + |
|
| 842 | + case 'meta_data': |
|
| 843 | + if ( is_array( $value ) ) { |
|
| 844 | + foreach ( $value as $meta ) { |
|
| 845 | + $object->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
| 846 | + } |
|
| 847 | + } |
|
| 848 | + break; |
|
| 849 | + |
|
| 850 | + default: |
|
| 851 | + if ( is_callable( array( $object, "set_{$key}" ) ) ) { |
|
| 852 | + $object->{"set_{$key}"}( $value ); |
|
| 853 | + } |
|
| 854 | + break; |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | + |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + // Filters an object before it is inserted via the REST API.. |
|
| 861 | + return apply_filters( "getpaid_rest_pre_insert_{$this->post_type}_object", $object, $request ); |
|
| 862 | + } |
|
| 863 | + |
|
| 864 | + /** |
|
| 865 | + * Retrieves data from a GetPaid class. |
|
| 866 | + * |
|
| 867 | + * @since 1.0.19 |
|
| 868 | + * @param GetPaid_Meta_Data[] $meta_data meta data objects. |
|
| 869 | + * @return array |
|
| 870 | + */ |
|
| 871 | + protected function prepare_object_meta_data( $meta_data ) { |
|
| 872 | + $meta = array(); |
|
| 873 | + |
|
| 874 | + foreach( $meta_data as $object ) { |
|
| 875 | + $meta[] = $object->get_data(); |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + return $meta; |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + /** |
|
| 882 | + * Retrieves invoice items. |
|
| 883 | + * |
|
| 884 | + * @since 1.0.19 |
|
| 885 | + * @param WPInv_Invoice $invoice Invoice items. |
|
| 886 | + * @return array |
|
| 887 | + */ |
|
| 888 | + protected function prepare_invoice_items( $invoice ) { |
|
| 889 | + $items = array(); |
|
| 890 | + |
|
| 891 | + foreach( $invoice->get_items() as $item ) { |
|
| 892 | + $item_data = $item->prepare_data_for_saving(); |
|
| 893 | + |
|
| 894 | + if ( 'amount' == $invoice->get_template() ) { |
|
| 895 | + $item_data['quantity'] = 1; |
|
| 896 | + } |
|
| 897 | + |
|
| 898 | + $items[] = $item_data; |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + return $items; |
|
| 902 | + } |
|
| 903 | + |
|
| 904 | + /** |
|
| 905 | + * Retrieves data from a GetPaid class. |
|
| 906 | + * |
|
| 907 | + * @since 1.0.19 |
|
| 908 | + * @param GetPaid_Data $object Data object. |
|
| 909 | + * @param array $fields Fields to include. |
|
| 910 | + * @param string $context either view or edit. |
|
| 911 | + * @return array |
|
| 912 | + */ |
|
| 913 | + protected function prepare_object_data( $object, $fields, $context = 'view' ) { |
|
| 914 | + |
|
| 915 | + $data = array(); |
|
| 916 | + $schema = $this->get_item_schema(); |
|
| 917 | + $data_keys = array_keys( $schema['properties'] ); |
|
| 918 | + |
|
| 919 | + // Handle all writable props. |
|
| 920 | + foreach ( $data_keys as $key ) { |
|
| 921 | + |
|
| 922 | + // Abort if it is not included. |
|
| 923 | + if ( ! empty( $fields ) && ! $this->is_field_included( $key, $fields ) ) { |
|
| 924 | + continue; |
|
| 925 | + } |
|
| 926 | + |
|
| 927 | + // Handle meta data. |
|
| 928 | + if ( $key == 'meta_data' ) { |
|
| 929 | + $data['meta_data'] = $this->prepare_object_meta_data( $object->get_meta_data() ); |
|
| 930 | + continue; |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + // Handle items. |
|
| 934 | + if ( $key == 'items' && is_a( $object, 'WPInv_Invoice' ) ) { |
|
| 935 | + $data['items'] = $this->prepare_invoice_items( $object ); |
|
| 936 | + continue; |
|
| 937 | + } |
|
| 938 | + |
|
| 939 | + // Booleans. |
|
| 940 | + if ( is_callable( array( $object, $key ) ) ) { |
|
| 941 | + $data[ $key ] = $object->$key( $context ); |
|
| 942 | + continue; |
|
| 943 | + } |
|
| 944 | + |
|
| 945 | + // Get object value. |
|
| 946 | + if ( is_callable( array( $object, "get_{$key}" ) ) ) { |
|
| 947 | + $value = $object->{"get_{$key}"}( $context ); |
|
| 948 | + |
|
| 949 | + // If the value is an instance of GetPaid_Data... |
|
| 950 | + if ( is_a( $value, 'GetPaid_Data' ) ) { |
|
| 951 | + $value = $value->get_data( $context ); |
|
| 952 | + } |
|
| 953 | + |
|
| 954 | + // For objects, retrieves it's properties. |
|
| 955 | + $data[ $key ] = is_object( $value ) ? get_object_vars( $value ) : $value ; |
|
| 956 | + continue; |
|
| 957 | + } |
|
| 958 | + |
|
| 959 | + // The value does not exist on an object. |
|
| 960 | + $data[ $key ] = apply_filters( "getpaid_{$this->post_type}_{$key}_object_data", null, $object ); |
|
| 961 | + |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + return $data; |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * Prepare a single object output for response. |
|
| 969 | + * |
|
| 970 | + * @since 1.0.19 |
|
| 971 | + * @param GetPaid_Data $object Data object. |
|
| 972 | + * @param WP_REST_Request $request Request object. |
|
| 973 | + * @return WP_REST_Response |
|
| 974 | + */ |
|
| 975 | + public function prepare_item_for_response( $object, $request ) { |
|
| 976 | + |
|
| 977 | + // Fetch the fields to include in this response. |
|
| 978 | + $fields = $this->get_fields_for_response( $request ); |
|
| 979 | + |
|
| 980 | + // Prepare object data. |
|
| 981 | + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 982 | + $data = $this->prepare_object_data( $object, $fields, $context ); |
|
| 983 | + $data = $this->add_additional_fields_to_object( $data, $request ); |
|
| 984 | + $data = $this->filter_response_by_context( $data, $context ); |
|
| 985 | + |
|
| 986 | + // Prepare the response. |
|
| 987 | + $response = rest_ensure_response( $data ); |
|
| 988 | + $response->add_links( $this->prepare_links( $object, $request ) ); |
|
| 989 | + |
|
| 990 | + // Filter item response. |
|
| 991 | + return apply_filters( "getpaid_rest_prepare_{$this->post_type}_object", $response, $object, $request ); |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | 994 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * GetPaid REST Posts controller class. |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @see register_rest_route() |
| 47 | 47 | */ |
| 48 | - public function register_namespace_routes( $namespace ) { |
|
| 48 | + public function register_namespace_routes($namespace) { |
|
| 49 | 49 | |
| 50 | 50 | register_rest_route( |
| 51 | 51 | $namespace, |
@@ -53,22 +53,22 @@ discard block |
||
| 53 | 53 | array( |
| 54 | 54 | array( |
| 55 | 55 | 'methods' => WP_REST_Server::READABLE, |
| 56 | - 'callback' => array( $this, 'get_items' ), |
|
| 57 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 56 | + 'callback' => array($this, 'get_items'), |
|
| 57 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
| 58 | 58 | 'args' => $this->get_collection_params(), |
| 59 | 59 | ), |
| 60 | 60 | array( |
| 61 | 61 | 'methods' => WP_REST_Server::CREATABLE, |
| 62 | - 'callback' => array( $this, 'create_item' ), |
|
| 63 | - 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 64 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 62 | + 'callback' => array($this, 'create_item'), |
|
| 63 | + 'permission_callback' => array($this, 'create_item_permissions_check'), |
|
| 64 | + 'args' => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE), |
|
| 65 | 65 | ), |
| 66 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 66 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 67 | 67 | ) |
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | $get_item_args = array( |
| 71 | - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 71 | + 'context' => $this->get_context_param(array('default' => 'view')), |
|
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | register_rest_route( |
@@ -77,35 +77,35 @@ discard block |
||
| 77 | 77 | array( |
| 78 | 78 | 'args' => array( |
| 79 | 79 | 'id' => array( |
| 80 | - 'description' => __( 'Unique identifier for the object.', 'invoicing' ), |
|
| 80 | + 'description' => __('Unique identifier for the object.', 'invoicing'), |
|
| 81 | 81 | 'type' => 'integer', |
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | array( |
| 85 | 85 | 'methods' => WP_REST_Server::READABLE, |
| 86 | - 'callback' => array( $this, 'get_item' ), |
|
| 87 | - 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 86 | + 'callback' => array($this, 'get_item'), |
|
| 87 | + 'permission_callback' => array($this, 'get_item_permissions_check'), |
|
| 88 | 88 | 'args' => $get_item_args, |
| 89 | 89 | ), |
| 90 | 90 | array( |
| 91 | 91 | 'methods' => WP_REST_Server::EDITABLE, |
| 92 | - 'callback' => array( $this, 'update_item' ), |
|
| 93 | - 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 94 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 92 | + 'callback' => array($this, 'update_item'), |
|
| 93 | + 'permission_callback' => array($this, 'update_item_permissions_check'), |
|
| 94 | + 'args' => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE), |
|
| 95 | 95 | ), |
| 96 | 96 | array( |
| 97 | 97 | 'methods' => WP_REST_Server::DELETABLE, |
| 98 | - 'callback' => array( $this, 'delete_item' ), |
|
| 99 | - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 98 | + 'callback' => array($this, 'delete_item'), |
|
| 99 | + 'permission_callback' => array($this, 'delete_item_permissions_check'), |
|
| 100 | 100 | 'args' => array( |
| 101 | 101 | 'force' => array( |
| 102 | 102 | 'type' => 'boolean', |
| 103 | 103 | 'default' => false, |
| 104 | - 'description' => __( 'Whether to bypass Trash and force deletion.', 'invoicing' ), |
|
| 104 | + 'description' => __('Whether to bypass Trash and force deletion.', 'invoicing'), |
|
| 105 | 105 | ), |
| 106 | 106 | ), |
| 107 | 107 | ), |
| 108 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 108 | + 'schema' => array($this, 'get_public_item_schema'), |
|
| 109 | 109 | ) |
| 110 | 110 | ); |
| 111 | 111 | |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | array( |
| 116 | 116 | array( |
| 117 | 117 | 'methods' => WP_REST_Server::EDITABLE, |
| 118 | - 'callback' => array( $this, 'batch_items' ), |
|
| 119 | - 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 120 | - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 118 | + 'callback' => array($this, 'batch_items'), |
|
| 119 | + 'permission_callback' => array($this, 'batch_items_permissions_check'), |
|
| 120 | + 'args' => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE), |
|
| 121 | 121 | ), |
| 122 | - 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 122 | + 'schema' => array($this, 'get_public_batch_schema'), |
|
| 123 | 123 | ) |
| 124 | 124 | ); |
| 125 | 125 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param int $object_id Post ID. |
| 134 | 134 | * @return bool |
| 135 | 135 | */ |
| 136 | - public function check_post_permissions( $context = 'read', $object_id = 0 ) { |
|
| 136 | + public function check_post_permissions($context = 'read', $object_id = 0) { |
|
| 137 | 137 | return true; |
| 138 | 138 | $contexts = array( |
| 139 | 139 | 'read' => 'read_private_posts', |
@@ -143,15 +143,15 @@ discard block |
||
| 143 | 143 | 'batch' => 'edit_others_posts', |
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - if ( 'revision' === $this->post_type ) { |
|
| 146 | + if ('revision' === $this->post_type) { |
|
| 147 | 147 | $permission = false; |
| 148 | 148 | } else { |
| 149 | - $cap = $contexts[ $context ]; |
|
| 150 | - $post_type_object = get_post_type_object( $this->post_type ); |
|
| 151 | - $permission = current_user_can( $post_type_object->cap->$cap, $object_id ); |
|
| 149 | + $cap = $contexts[$context]; |
|
| 150 | + $post_type_object = get_post_type_object($this->post_type); |
|
| 151 | + $permission = current_user_can($post_type_object->cap->$cap, $object_id); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - return apply_filters( 'getpaid_rest_check_permissions', $permission, $context, $object_id, $this->post_type ); |
|
| 154 | + return apply_filters('getpaid_rest_check_permissions', $permission, $context, $object_id, $this->post_type); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * @param WP_REST_Request $request Full details about the request. |
| 161 | 161 | * @return WP_Error|boolean |
| 162 | 162 | */ |
| 163 | - public function get_items_permissions_check( $request ) { |
|
| 164 | - return $this->check_post_permissions() ? true : new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot list resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 163 | + public function get_items_permissions_check($request) { |
|
| 164 | + return $this->check_post_permissions() ? true : new WP_Error('rest_cannot_view', __('Sorry, you cannot list resources.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @param WP_REST_Request $request Full details about the request. |
| 171 | 171 | * @return WP_Error|boolean |
| 172 | 172 | */ |
| 173 | - public function create_item_permissions_check( $request ) { |
|
| 174 | - return $this->check_post_permissions( 'create' ) ? true : new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 173 | + public function create_item_permissions_check($request) { |
|
| 174 | + return $this->check_post_permissions('create') ? true : new WP_Error('rest_cannot_create', __('Sorry, you are not allowed to create resources.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | * @param WP_REST_Request $request Full details about the request. |
| 181 | 181 | * @return WP_Error|boolean |
| 182 | 182 | */ |
| 183 | - public function get_item_permissions_check( $request ) { |
|
| 184 | - $post = get_post( (int) $request['id'] ); |
|
| 183 | + public function get_item_permissions_check($request) { |
|
| 184 | + $post = get_post((int) $request['id']); |
|
| 185 | 185 | |
| 186 | - if ( $post && ! $this->check_post_permissions( 'read', $post->ID ) ) { |
|
| 187 | - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 186 | + if ($post && !$this->check_post_permissions('read', $post->ID)) { |
|
| 187 | + return new WP_Error('rest_cannot_view', __('Sorry, you cannot view this resource.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | return true; |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | * @param WP_REST_Request $request Full details about the request. |
| 197 | 197 | * @return WP_Error|boolean |
| 198 | 198 | */ |
| 199 | - public function update_item_permissions_check( $request ) { |
|
| 200 | - $post = get_post( (int) $request['id'] ); |
|
| 199 | + public function update_item_permissions_check($request) { |
|
| 200 | + $post = get_post((int) $request['id']); |
|
| 201 | 201 | |
| 202 | - if ( $post && ! $this->check_post_permissions( 'edit', $post->ID ) ) { |
|
| 203 | - return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 202 | + if ($post && !$this->check_post_permissions('edit', $post->ID)) { |
|
| 203 | + return new WP_Error('rest_cannot_edit', __('Sorry, you are not allowed to edit this resource.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | return true; |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * @param WP_REST_Request $request Full details about the request. |
| 213 | 213 | * @return bool|WP_Error |
| 214 | 214 | */ |
| 215 | - public function delete_item_permissions_check( $request ) { |
|
| 216 | - $post = get_post( (int) $request['id'] ); |
|
| 215 | + public function delete_item_permissions_check($request) { |
|
| 216 | + $post = get_post((int) $request['id']); |
|
| 217 | 217 | |
| 218 | - if ( $post && ! $this->check_post_permissions( 'delete', $post->ID ) ) { |
|
| 219 | - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 218 | + if ($post && !$this->check_post_permissions('delete', $post->ID)) { |
|
| 219 | + return new WP_Error('rest_cannot_delete', __('Sorry, you are not allowed to delete this resource.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return true; |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return boolean|WP_Error |
| 231 | 231 | */ |
| 232 | - public function batch_items_permissions_check( $request ) { |
|
| 233 | - return $this->check_post_permissions( 'batch' ) ? true : new WP_Error( 'rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 232 | + public function batch_items_permissions_check($request) { |
|
| 233 | + return $this->check_post_permissions('batch') ? true : new WP_Error('rest_cannot_batch', __('Sorry, you are not allowed to batch manipulate this resource.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | * @param GetPaid_Data $object Object to save. |
| 240 | 240 | * @return WP_Error|GetPaid_Data |
| 241 | 241 | */ |
| 242 | - protected function save_object( $object ) { |
|
| 242 | + protected function save_object($object) { |
|
| 243 | 243 | $object->save(); |
| 244 | 244 | |
| 245 | - if ( ! empty( $object->last_error ) ) { |
|
| 246 | - return new WP_Error( 'rest_cannot_save', $object->last_error, array( 'status' => 400 ) ); |
|
| 245 | + if (!empty($object->last_error)) { |
|
| 246 | + return new WP_Error('rest_cannot_save', $object->last_error, array('status' => 400)); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return new $this->crud_class( $object->get_id() ); |
|
| 249 | + return new $this->crud_class($object->get_id()); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -258,28 +258,28 @@ discard block |
||
| 258 | 258 | * @param int|WP_Post $object_id Supplied ID. |
| 259 | 259 | * @return GetPaid_Data|WP_Error GetPaid_Data object if ID is valid, WP_Error otherwise. |
| 260 | 260 | */ |
| 261 | - protected function get_object( $object_id ) { |
|
| 261 | + protected function get_object($object_id) { |
|
| 262 | 262 | |
| 263 | 263 | // Do we have an object? |
| 264 | - if ( empty( $this->crud_class ) || ! class_exists( $this->crud_class ) ) { |
|
| 265 | - return new WP_Error( 'no_crud_class', __( 'You need to specify a CRUD class for this controller', 'invoicing' ) ); |
|
| 264 | + if (empty($this->crud_class) || !class_exists($this->crud_class)) { |
|
| 265 | + return new WP_Error('no_crud_class', __('You need to specify a CRUD class for this controller', 'invoicing')); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Fetch the object. |
| 269 | - $object = new $this->crud_class( $object_id ); |
|
| 270 | - if ( ! empty( $object->last_error ) ) { |
|
| 271 | - return new WP_Error( 'rest_object_invalid_id', $object->last_error, array( 'status' => 404 ) ); |
|
| 269 | + $object = new $this->crud_class($object_id); |
|
| 270 | + if (!empty($object->last_error)) { |
|
| 271 | + return new WP_Error('rest_object_invalid_id', $object->last_error, array('status' => 404)); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - return $object->get_id() ? $object : new WP_Error( 'rest_object_invalid_id', __( 'Invalid ID.', 'invoicing' ), array( 'status' => 404 ) ); |
|
| 274 | + return $object->get_id() ? $object : new WP_Error('rest_object_invalid_id', __('Invalid ID.', 'invoicing'), array('status' => 404)); |
|
| 275 | 275 | |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | 279 | * @deprecated |
| 280 | 280 | */ |
| 281 | - public function get_post( $object_id ) { |
|
| 282 | - return $this->get_object( $object_id ); |
|
| 281 | + public function get_post($object_id) { |
|
| 282 | + return $this->get_object($object_id); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -288,22 +288,22 @@ discard block |
||
| 288 | 288 | * @param WP_REST_Request $request Full details about the request. |
| 289 | 289 | * @return WP_Error|WP_REST_Response |
| 290 | 290 | */ |
| 291 | - public function get_item( $request ) { |
|
| 291 | + public function get_item($request) { |
|
| 292 | 292 | |
| 293 | 293 | // Fetch the item. |
| 294 | - $object = $this->get_object( $request['id'] ); |
|
| 294 | + $object = $this->get_object($request['id']); |
|
| 295 | 295 | |
| 296 | - if ( is_wp_error( $object ) ) { |
|
| 296 | + if (is_wp_error($object)) { |
|
| 297 | 297 | return $object; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // Generate a response. |
| 301 | - $data = $this->prepare_item_for_response( $object, $request ); |
|
| 302 | - $response = rest_ensure_response( $data ); |
|
| 301 | + $data = $this->prepare_item_for_response($object, $request); |
|
| 302 | + $response = rest_ensure_response($data); |
|
| 303 | 303 | |
| 304 | 304 | // (Maybe) add a link to the html pagee. |
| 305 | - if ( $this->public && ! is_wp_error( $response ) ) { |
|
| 306 | - $response->link_header( 'alternate', get_permalink( $object->get_id() ), array( 'type' => 'text/html' ) ); |
|
| 305 | + if ($this->public && !is_wp_error($response)) { |
|
| 306 | + $response->link_header('alternate', get_permalink($object->get_id()), array('type' => 'text/html')); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | return $response; |
@@ -315,30 +315,30 @@ discard block |
||
| 315 | 315 | * @param WP_REST_Request $request Full details about the request. |
| 316 | 316 | * @return WP_Error|WP_REST_Response |
| 317 | 317 | */ |
| 318 | - public function create_item( $request ) { |
|
| 318 | + public function create_item($request) { |
|
| 319 | 319 | |
| 320 | 320 | // Can not create an existing item. |
| 321 | - if ( ! empty( $request['id'] ) ) { |
|
| 321 | + if (!empty($request['id'])) { |
|
| 322 | 322 | /* translators: %s: post type */ |
| 323 | - return new WP_Error( "getpaid_rest_{$this->post_type}_exists", __( 'Cannot create existing resource.', 'invoicing' ), array( 'status' => 400 ) ); |
|
| 323 | + return new WP_Error("getpaid_rest_{$this->post_type}_exists", __('Cannot create existing resource.', 'invoicing'), array('status' => 400)); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // Generate a GetPaid_Data object from the request. |
| 327 | - $object = $this->prepare_item_for_database( $request ); |
|
| 328 | - if ( is_wp_error( $object ) ) { |
|
| 327 | + $object = $this->prepare_item_for_database($request); |
|
| 328 | + if (is_wp_error($object)) { |
|
| 329 | 329 | return $object; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Save the object. |
| 333 | - $object = $this->save_object( $object ); |
|
| 334 | - if ( is_wp_error( $object ) ) { |
|
| 333 | + $object = $this->save_object($object); |
|
| 334 | + if (is_wp_error($object)) { |
|
| 335 | 335 | return $object; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Save special fields. |
| 339 | - $save_special = $this->update_additional_fields_for_object( $object, $request ); |
|
| 340 | - if ( is_wp_error( $save_special ) ) { |
|
| 341 | - $object->delete( true ); |
|
| 339 | + $save_special = $this->update_additional_fields_for_object($object, $request); |
|
| 340 | + if (is_wp_error($save_special)) { |
|
| 341 | + $object->delete(true); |
|
| 342 | 342 | return $save_special; |
| 343 | 343 | } |
| 344 | 344 | |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | * @param WP_REST_Request $request Request object. |
| 350 | 350 | * @param boolean $creating True when creating item, false when updating. |
| 351 | 351 | */ |
| 352 | - do_action( "getpaid_rest_insert_{$this->post_type}", $object, $request, true ); |
|
| 352 | + do_action("getpaid_rest_insert_{$this->post_type}", $object, $request, true); |
|
| 353 | 353 | |
| 354 | - $request->set_param( 'context', 'edit' ); |
|
| 355 | - $response = $this->prepare_item_for_response( $object, $request ); |
|
| 356 | - $response = rest_ensure_response( $response ); |
|
| 357 | - $response->set_status( 201 ); |
|
| 358 | - $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ) ); |
|
| 354 | + $request->set_param('context', 'edit'); |
|
| 355 | + $response = $this->prepare_item_for_response($object, $request); |
|
| 356 | + $response = rest_ensure_response($response); |
|
| 357 | + $response->set_status(201); |
|
| 358 | + $response->header('Location', rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id()))); |
|
| 359 | 359 | |
| 360 | 360 | return $response; |
| 361 | 361 | } |
@@ -366,29 +366,29 @@ discard block |
||
| 366 | 366 | * @param WP_REST_Request $request Full details about the request. |
| 367 | 367 | * @return WP_Error|WP_REST_Response |
| 368 | 368 | */ |
| 369 | - public function update_item( $request ) { |
|
| 369 | + public function update_item($request) { |
|
| 370 | 370 | |
| 371 | 371 | // Fetch the item. |
| 372 | - $object = $this->get_object( $request['id'] ); |
|
| 373 | - if ( is_wp_error( $object ) ) { |
|
| 372 | + $object = $this->get_object($request['id']); |
|
| 373 | + if (is_wp_error($object)) { |
|
| 374 | 374 | return $object; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Prepare the item for saving. |
| 378 | - $object = $this->prepare_item_for_database( $request ); |
|
| 379 | - if ( is_wp_error( $object ) ) { |
|
| 378 | + $object = $this->prepare_item_for_database($request); |
|
| 379 | + if (is_wp_error($object)) { |
|
| 380 | 380 | return $object; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // Save the item. |
| 384 | - $object = $this->save_object( $object ); |
|
| 385 | - if ( is_wp_error( $object ) ) { |
|
| 384 | + $object = $this->save_object($object); |
|
| 385 | + if (is_wp_error($object)) { |
|
| 386 | 386 | return $object; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Save special fields (those added via hooks). |
| 390 | - $save_special = $this->update_additional_fields_for_object( $object, $request ); |
|
| 391 | - if ( is_wp_error( $save_special ) ) { |
|
| 390 | + $save_special = $this->update_additional_fields_for_object($object, $request); |
|
| 391 | + if (is_wp_error($save_special)) { |
|
| 392 | 392 | return $save_special; |
| 393 | 393 | } |
| 394 | 394 | |
@@ -399,11 +399,11 @@ discard block |
||
| 399 | 399 | * @param WP_REST_Request $request Request object. |
| 400 | 400 | * @param boolean $creating True when creating item, false when updating. |
| 401 | 401 | */ |
| 402 | - do_action( "getpaid_rest_insert_{$this->post_type}", $object, $request, false ); |
|
| 402 | + do_action("getpaid_rest_insert_{$this->post_type}", $object, $request, false); |
|
| 403 | 403 | |
| 404 | - $request->set_param( 'context', 'edit' ); |
|
| 405 | - $response = $this->prepare_item_for_response( $object, $request ); |
|
| 406 | - return rest_ensure_response( $response ); |
|
| 404 | + $request->set_param('context', 'edit'); |
|
| 405 | + $response = $this->prepare_item_for_response($object, $request); |
|
| 406 | + return rest_ensure_response($response); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | * @param WP_REST_Request $request Full details about the request. |
| 413 | 413 | * @return WP_Error|WP_REST_Response |
| 414 | 414 | */ |
| 415 | - public function get_items( $request ) { |
|
| 415 | + public function get_items($request) { |
|
| 416 | 416 | $args = array(); |
| 417 | 417 | $args['offset'] = $request['offset']; |
| 418 | 418 | $args['order'] = $request['order']; |
@@ -425,16 +425,16 @@ discard block |
||
| 425 | 425 | $args['post_parent__in'] = $request['parent']; |
| 426 | 426 | $args['post_parent__not_in'] = $request['parent_exclude']; |
| 427 | 427 | $args['s'] = $request['search']; |
| 428 | - $args['post_status'] = $request['status'] == 'any' ? 'any' : wpinv_parse_list( $request['status'] ); |
|
| 428 | + $args['post_status'] = $request['status'] == 'any' ? 'any' : wpinv_parse_list($request['status']); |
|
| 429 | 429 | |
| 430 | 430 | $args['date_query'] = array(); |
| 431 | 431 | // Set before into date query. Date query must be specified as an array of an array. |
| 432 | - if ( isset( $request['before'] ) ) { |
|
| 432 | + if (isset($request['before'])) { |
|
| 433 | 433 | $args['date_query'][0]['before'] = $request['before']; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | // Set after into date query. Date query must be specified as an array of an array. |
| 437 | - if ( isset( $request['after'] ) ) { |
|
| 437 | + if (isset($request['after'])) { |
|
| 438 | 438 | $args['date_query'][0]['after'] = $request['after']; |
| 439 | 439 | } |
| 440 | 440 | |
@@ -442,54 +442,54 @@ discard block |
||
| 442 | 442 | $args['post_type'] = $this->post_type; |
| 443 | 443 | |
| 444 | 444 | // Filter the query arguments for a request. |
| 445 | - $args = apply_filters( "getpaid_rest_{$this->post_type}_query", $args, $request ); |
|
| 446 | - $query_args = $this->prepare_items_query( $args, $request ); |
|
| 445 | + $args = apply_filters("getpaid_rest_{$this->post_type}_query", $args, $request); |
|
| 446 | + $query_args = $this->prepare_items_query($args, $request); |
|
| 447 | 447 | |
| 448 | 448 | $posts_query = new WP_Query(); |
| 449 | - $query_result = $posts_query->query( $query_args ); |
|
| 449 | + $query_result = $posts_query->query($query_args); |
|
| 450 | 450 | |
| 451 | 451 | $posts = array(); |
| 452 | - foreach ( $query_result as $post ) { |
|
| 453 | - if ( ! $this->check_post_permissions( 'read', $post->ID ) ) { |
|
| 452 | + foreach ($query_result as $post) { |
|
| 453 | + if (!$this->check_post_permissions('read', $post->ID)) { |
|
| 454 | 454 | continue; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $data = $this->prepare_item_for_response( $this->get_object( $post->ID ), $request ); |
|
| 458 | - $posts[] = $this->prepare_response_for_collection( $data ); |
|
| 457 | + $data = $this->prepare_item_for_response($this->get_object($post->ID), $request); |
|
| 458 | + $posts[] = $this->prepare_response_for_collection($data); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | $page = (int) $query_args['paged']; |
| 462 | 462 | $total_posts = $posts_query->found_posts; |
| 463 | 463 | |
| 464 | - if ( $total_posts < 1 ) { |
|
| 464 | + if ($total_posts < 1) { |
|
| 465 | 465 | // Out-of-bounds, run the query again without LIMIT for total count. |
| 466 | - unset( $query_args['paged'] ); |
|
| 466 | + unset($query_args['paged']); |
|
| 467 | 467 | $count_query = new WP_Query(); |
| 468 | - $count_query->query( $query_args ); |
|
| 468 | + $count_query->query($query_args); |
|
| 469 | 469 | $total_posts = $count_query->found_posts; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - $max_pages = ceil( $total_posts / (int) $query_args['posts_per_page'] ); |
|
| 472 | + $max_pages = ceil($total_posts / (int) $query_args['posts_per_page']); |
|
| 473 | 473 | |
| 474 | - $response = rest_ensure_response( $posts ); |
|
| 475 | - $response->header( 'X-WP-Total', (int) $total_posts ); |
|
| 476 | - $response->header( 'X-WP-TotalPages', (int) $max_pages ); |
|
| 474 | + $response = rest_ensure_response($posts); |
|
| 475 | + $response->header('X-WP-Total', (int) $total_posts); |
|
| 476 | + $response->header('X-WP-TotalPages', (int) $max_pages); |
|
| 477 | 477 | |
| 478 | 478 | $request_params = $request->get_query_params(); |
| 479 | - $base = add_query_arg( $request_params, rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); |
|
| 479 | + $base = add_query_arg($request_params, rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base))); |
|
| 480 | 480 | |
| 481 | - if ( $page > 1 ) { |
|
| 481 | + if ($page > 1) { |
|
| 482 | 482 | $prev_page = $page - 1; |
| 483 | - if ( $prev_page > $max_pages ) { |
|
| 483 | + if ($prev_page > $max_pages) { |
|
| 484 | 484 | $prev_page = $max_pages; |
| 485 | 485 | } |
| 486 | - $prev_link = add_query_arg( 'page', $prev_page, $base ); |
|
| 487 | - $response->link_header( 'prev', $prev_link ); |
|
| 486 | + $prev_link = add_query_arg('page', $prev_page, $base); |
|
| 487 | + $response->link_header('prev', $prev_link); |
|
| 488 | 488 | } |
| 489 | - if ( $max_pages > $page ) { |
|
| 489 | + if ($max_pages > $page) { |
|
| 490 | 490 | $next_page = $page + 1; |
| 491 | - $next_link = add_query_arg( 'page', $next_page, $base ); |
|
| 492 | - $response->link_header( 'next', $next_link ); |
|
| 491 | + $next_link = add_query_arg('page', $next_page, $base); |
|
| 492 | + $response->link_header('next', $next_link); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | return $response; |
@@ -501,26 +501,26 @@ discard block |
||
| 501 | 501 | * @param WP_REST_Request $request Full details about the request. |
| 502 | 502 | * @return WP_REST_Response|WP_Error |
| 503 | 503 | */ |
| 504 | - public function delete_item( $request ) { |
|
| 504 | + public function delete_item($request) { |
|
| 505 | 505 | |
| 506 | 506 | // Fetch the item. |
| 507 | - $item = $this->get_object( $request['id'] ); |
|
| 508 | - if ( is_wp_error( $item ) ) { |
|
| 507 | + $item = $this->get_object($request['id']); |
|
| 508 | + if (is_wp_error($item)) { |
|
| 509 | 509 | return $item; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | $supports_trash = EMPTY_TRASH_DAYS > 0; |
| 513 | 513 | $force = $supports_trash && (bool) $request['force']; |
| 514 | 514 | |
| 515 | - if ( ! $this->check_post_permissions( 'delete', $item->ID ) ) { |
|
| 516 | - return new WP_Error( "cannot_delete", __( 'Sorry, you are not allowed to delete this resource.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 515 | + if (!$this->check_post_permissions('delete', $item->ID)) { |
|
| 516 | + return new WP_Error("cannot_delete", __('Sorry, you are not allowed to delete this resource.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - $request->set_param( 'context', 'edit' ); |
|
| 520 | - $response = $this->prepare_item_for_response( $item, $request ); |
|
| 519 | + $request->set_param('context', 'edit'); |
|
| 520 | + $response = $this->prepare_item_for_response($item, $request); |
|
| 521 | 521 | |
| 522 | - if ( ! wp_delete_post( $item->ID, $force ) ) { |
|
| 523 | - return new WP_Error( 'rest_cannot_delete', sprintf( __( 'The resource cannot be deleted.', 'invoicing' ), $this->post_type ), array( 'status' => 500 ) ); |
|
| 522 | + if (!wp_delete_post($item->ID, $force)) { |
|
| 523 | + return new WP_Error('rest_cannot_delete', sprintf(__('The resource cannot be deleted.', 'invoicing'), $this->post_type), array('status' => 500)); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | return $response; |
@@ -532,20 +532,20 @@ discard block |
||
| 532 | 532 | * @param GetPaid_Data $object GetPaid_Data object. |
| 533 | 533 | * @return array Links for the given object. |
| 534 | 534 | */ |
| 535 | - protected function prepare_links( $object ) { |
|
| 535 | + protected function prepare_links($object) { |
|
| 536 | 536 | |
| 537 | 537 | $links = array( |
| 538 | 538 | 'self' => array( |
| 539 | - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), |
|
| 539 | + 'href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id())), |
|
| 540 | 540 | ), |
| 541 | 541 | 'collection' => array( |
| 542 | - 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
|
| 542 | + 'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)), |
|
| 543 | 543 | ), |
| 544 | 544 | ); |
| 545 | 545 | |
| 546 | - if ( is_callable( array( $object, 'get_user_id' ) ) ) { |
|
| 546 | + if (is_callable(array($object, 'get_user_id'))) { |
|
| 547 | 547 | $links['user'] = array( |
| 548 | - 'href' => rest_url( 'wp/v2/users/' . call_user_func( array( $object, 'get_user_id' ) ) ), |
|
| 548 | + 'href' => rest_url('wp/v2/users/' . call_user_func(array($object, 'get_user_id'))), |
|
| 549 | 549 | 'embeddable' => true, |
| 550 | 550 | ); |
| 551 | 551 | } |
@@ -561,27 +561,27 @@ discard block |
||
| 561 | 561 | * @param WP_REST_Request $request Request object. |
| 562 | 562 | * @return array $query_args |
| 563 | 563 | */ |
| 564 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 564 | + protected function prepare_items_query($prepared_args = array(), $request = null) { |
|
| 565 | 565 | |
| 566 | - $valid_vars = array_flip( $this->get_allowed_query_vars() ); |
|
| 566 | + $valid_vars = array_flip($this->get_allowed_query_vars()); |
|
| 567 | 567 | $query_args = array(); |
| 568 | - foreach ( $valid_vars as $var => $index ) { |
|
| 569 | - if ( isset( $prepared_args[ $var ] ) ) { |
|
| 570 | - $query_args[ $var ] = apply_filters( "getpaid_rest_query_var-{$var}", $prepared_args[ $var ] ); |
|
| 568 | + foreach ($valid_vars as $var => $index) { |
|
| 569 | + if (isset($prepared_args[$var])) { |
|
| 570 | + $query_args[$var] = apply_filters("getpaid_rest_query_var-{$var}", $prepared_args[$var]); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | $query_args['ignore_sticky_posts'] = true; |
| 575 | 575 | |
| 576 | - if ( 'include' === $query_args['orderby'] ) { |
|
| 576 | + if ('include' === $query_args['orderby']) { |
|
| 577 | 577 | $query_args['orderby'] = 'post__in'; |
| 578 | - } elseif ( 'id' === $query_args['orderby'] ) { |
|
| 578 | + } elseif ('id' === $query_args['orderby']) { |
|
| 579 | 579 | $query_args['orderby'] = 'ID'; // ID must be capitalized. |
| 580 | - } elseif ( 'slug' === $query_args['orderby'] ) { |
|
| 580 | + } elseif ('slug' === $query_args['orderby']) { |
|
| 581 | 581 | $query_args['orderby'] = 'name'; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - return apply_filters( 'getpaid_rest_prepare_items_query', $query_args, $request, $this ); |
|
| 584 | + return apply_filters('getpaid_rest_prepare_items_query', $query_args, $request, $this); |
|
| 585 | 585 | |
| 586 | 586 | } |
| 587 | 587 | |
@@ -600,12 +600,12 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @param array Array of allowed WP_Query query vars. |
| 602 | 602 | */ |
| 603 | - $valid_vars = apply_filters( 'query_vars', $wp->public_query_vars ); |
|
| 603 | + $valid_vars = apply_filters('query_vars', $wp->public_query_vars); |
|
| 604 | 604 | |
| 605 | - $post_type_obj = get_post_type_object( $this->post_type ); |
|
| 606 | - if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
|
| 607 | - $private = apply_filters( 'getpaid_rest_private_query_vars', $wp->private_query_vars ); |
|
| 608 | - $valid_vars = array_merge( $valid_vars, $private ); |
|
| 605 | + $post_type_obj = get_post_type_object($this->post_type); |
|
| 606 | + if (current_user_can($post_type_obj->cap->edit_posts)) { |
|
| 607 | + $private = apply_filters('getpaid_rest_private_query_vars', $wp->private_query_vars); |
|
| 608 | + $valid_vars = array_merge($valid_vars, $private); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | // Define our own in addition to WP's normal vars. |
@@ -627,10 +627,10 @@ discard block |
||
| 627 | 627 | 'meta_compare', |
| 628 | 628 | 'meta_value_num', |
| 629 | 629 | ); |
| 630 | - $valid_vars = array_merge( $valid_vars, $rest_valid ); |
|
| 630 | + $valid_vars = array_merge($valid_vars, $rest_valid); |
|
| 631 | 631 | |
| 632 | 632 | // Filter allowed query vars for the REST API. |
| 633 | - $valid_vars = apply_filters( 'getpaid_rest_query_vars', $valid_vars, $this ); |
|
| 633 | + $valid_vars = apply_filters('getpaid_rest_query_vars', $valid_vars, $this); |
|
| 634 | 634 | |
| 635 | 635 | return $valid_vars; |
| 636 | 636 | } |
@@ -647,29 +647,29 @@ discard block |
||
| 647 | 647 | |
| 648 | 648 | $params['status'] = array( |
| 649 | 649 | 'default' => 'any', |
| 650 | - 'description' => __( 'Limit result set to resources assigned one or more statuses.', 'invoicing' ), |
|
| 651 | - 'type' => array( 'array', 'string' ), |
|
| 650 | + 'description' => __('Limit result set to resources assigned one or more statuses.', 'invoicing'), |
|
| 651 | + 'type' => array('array', 'string'), |
|
| 652 | 652 | 'items' => array( |
| 653 | - 'enum' => array_merge( array( 'any' ), $this->get_post_statuses() ), |
|
| 653 | + 'enum' => array_merge(array('any'), $this->get_post_statuses()), |
|
| 654 | 654 | 'type' => 'string', |
| 655 | 655 | ), |
| 656 | 656 | 'sanitize_callback' => 'rest_validate_request_arg', |
| 657 | 657 | ); |
| 658 | 658 | |
| 659 | 659 | $params['after'] = array( |
| 660 | - 'description' => __( 'Limit response to resources created after a given ISO8601 compliant date.', 'invoicing' ), |
|
| 660 | + 'description' => __('Limit response to resources created after a given ISO8601 compliant date.', 'invoicing'), |
|
| 661 | 661 | 'type' => 'string', |
| 662 | 662 | 'format' => 'string', |
| 663 | 663 | 'validate_callback' => 'rest_validate_request_arg', |
| 664 | 664 | ); |
| 665 | 665 | $params['before'] = array( |
| 666 | - 'description' => __( 'Limit response to resources created before a given ISO8601 compliant date.', 'invoicing' ), |
|
| 666 | + 'description' => __('Limit response to resources created before a given ISO8601 compliant date.', 'invoicing'), |
|
| 667 | 667 | 'type' => 'string', |
| 668 | 668 | 'format' => 'string', |
| 669 | 669 | 'validate_callback' => 'rest_validate_request_arg', |
| 670 | 670 | ); |
| 671 | 671 | $params['exclude'] = array( |
| 672 | - 'description' => __( 'Ensure result set excludes specific IDs.', 'invoicing' ), |
|
| 672 | + 'description' => __('Ensure result set excludes specific IDs.', 'invoicing'), |
|
| 673 | 673 | 'type' => 'array', |
| 674 | 674 | 'items' => array( |
| 675 | 675 | 'type' => 'integer', |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | 'sanitize_callback' => 'wp_parse_id_list', |
| 679 | 679 | ); |
| 680 | 680 | $params['include'] = array( |
| 681 | - 'description' => __( 'Limit result set to specific ids.', 'invoicing' ), |
|
| 681 | + 'description' => __('Limit result set to specific ids.', 'invoicing'), |
|
| 682 | 682 | 'type' => 'array', |
| 683 | 683 | 'items' => array( |
| 684 | 684 | 'type' => 'integer', |
@@ -687,20 +687,20 @@ discard block |
||
| 687 | 687 | 'sanitize_callback' => 'wp_parse_id_list', |
| 688 | 688 | ); |
| 689 | 689 | $params['offset'] = array( |
| 690 | - 'description' => __( 'Offset the result set by a specific number of items.', 'invoicing' ), |
|
| 690 | + 'description' => __('Offset the result set by a specific number of items.', 'invoicing'), |
|
| 691 | 691 | 'type' => 'integer', |
| 692 | 692 | 'sanitize_callback' => 'absint', |
| 693 | 693 | 'validate_callback' => 'rest_validate_request_arg', |
| 694 | 694 | ); |
| 695 | 695 | $params['order'] = array( |
| 696 | - 'description' => __( 'Order sort attribute ascending or descending.', 'invoicing' ), |
|
| 696 | + 'description' => __('Order sort attribute ascending or descending.', 'invoicing'), |
|
| 697 | 697 | 'type' => 'string', |
| 698 | 698 | 'default' => 'desc', |
| 699 | - 'enum' => array( 'asc', 'desc' ), |
|
| 699 | + 'enum' => array('asc', 'desc'), |
|
| 700 | 700 | 'validate_callback' => 'rest_validate_request_arg', |
| 701 | 701 | ); |
| 702 | 702 | $params['orderby'] = array( |
| 703 | - 'description' => __( 'Sort collection by object attribute.', 'invoicing' ), |
|
| 703 | + 'description' => __('Sort collection by object attribute.', 'invoicing'), |
|
| 704 | 704 | 'type' => 'string', |
| 705 | 705 | 'default' => 'date', |
| 706 | 706 | 'enum' => array( |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | 'validate_callback' => 'rest_validate_request_arg', |
| 715 | 715 | ); |
| 716 | 716 | |
| 717 | - $post_type_obj = get_post_type_object( $this->post_type ); |
|
| 717 | + $post_type_obj = get_post_type_object($this->post_type); |
|
| 718 | 718 | |
| 719 | - if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) { |
|
| 719 | + if (isset($post_type_obj->hierarchical) && $post_type_obj->hierarchical) { |
|
| 720 | 720 | $params['parent'] = array( |
| 721 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 721 | + 'description' => __('Limit result set to those of particular parent IDs.', 'invoicing'), |
|
| 722 | 722 | 'type' => 'array', |
| 723 | 723 | 'items' => array( |
| 724 | 724 | 'type' => 'integer', |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | 'default' => array(), |
| 728 | 728 | ); |
| 729 | 729 | $params['parent_exclude'] = array( |
| 730 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 730 | + 'description' => __('Limit result set to all items except those of a particular parent ID.', 'invoicing'), |
|
| 731 | 731 | 'type' => 'array', |
| 732 | 732 | 'items' => array( |
| 733 | 733 | 'type' => 'integer', |
@@ -750,25 +750,25 @@ discard block |
||
| 750 | 750 | public function get_item_schema() { |
| 751 | 751 | |
| 752 | 752 | // Maybe retrieve the schema from cache. |
| 753 | - if ( $this->schema ) { |
|
| 754 | - return $this->add_additional_fields_schema( $this->schema ); |
|
| 753 | + if ($this->schema) { |
|
| 754 | + return $this->add_additional_fields_schema($this->schema); |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - $type = str_replace( 'wpi_', '', $this->post_type ); |
|
| 757 | + $type = str_replace('wpi_', '', $this->post_type); |
|
| 758 | 758 | $schema = array( |
| 759 | 759 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
| 760 | 760 | 'title' => $this->post_type, |
| 761 | 761 | 'type' => 'object', |
| 762 | - 'properties' => wpinv_get_data( "$type-schema" ), |
|
| 762 | + 'properties' => wpinv_get_data("$type-schema"), |
|
| 763 | 763 | ); |
| 764 | 764 | |
| 765 | 765 | // Filters the invoice schema for the REST API. |
| 766 | - $schema = apply_filters( "wpinv_rest_{$type}_schema", $schema ); |
|
| 766 | + $schema = apply_filters("wpinv_rest_{$type}_schema", $schema); |
|
| 767 | 767 | |
| 768 | 768 | // Cache the invoice schema. |
| 769 | 769 | $this->schema = $schema; |
| 770 | 770 | |
| 771 | - return $this->add_additional_fields_schema( $this->schema ); |
|
| 771 | + return $this->add_additional_fields_schema($this->schema); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | /** |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | * @param array $schema Schema. |
| 778 | 778 | * @return bool |
| 779 | 779 | */ |
| 780 | - public function filter_writable_props( $schema ) { |
|
| 781 | - return empty( $schema['readonly'] ); |
|
| 780 | + public function filter_writable_props($schema) { |
|
| 781 | + return empty($schema['readonly']); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
@@ -791,8 +791,8 @@ discard block |
||
| 791 | 791 | * @param string $parameter Additional parameter to pass to validation. |
| 792 | 792 | * @return array|WP_Error A list of valid statuses, otherwise WP_Error object. |
| 793 | 793 | */ |
| 794 | - public function sanitize_post_statuses( $statuses, $request, $parameter ) { |
|
| 795 | - return array_intersect( wp_parse_slug_list( $statuses ), $this->get_post_statuses() ); |
|
| 794 | + public function sanitize_post_statuses($statuses, $request, $parameter) { |
|
| 795 | + return array_intersect(wp_parse_slug_list($statuses), $this->get_post_statuses()); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
@@ -813,43 +813,43 @@ discard block |
||
| 813 | 813 | * @param WP_REST_Request $request Request object. |
| 814 | 814 | * @return GetPaid_Data|WP_Error Data object or WP_Error. |
| 815 | 815 | */ |
| 816 | - protected function prepare_item_for_database( $request ) { |
|
| 816 | + protected function prepare_item_for_database($request) { |
|
| 817 | 817 | |
| 818 | 818 | // Do we have an object? |
| 819 | - if ( empty( $this->crud_class ) || ! class_exists( $this->crud_class ) ) { |
|
| 820 | - return new WP_Error( 'no_crud_class', __( 'You need to specify a CRUD class for this controller', 'invoicing' ) ); |
|
| 819 | + if (empty($this->crud_class) || !class_exists($this->crud_class)) { |
|
| 820 | + return new WP_Error('no_crud_class', __('You need to specify a CRUD class for this controller', 'invoicing')); |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | // Prepare the object. |
| 824 | - $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; |
|
| 825 | - $object = new $this->crud_class( $id ); |
|
| 824 | + $id = isset($request['id']) ? absint($request['id']) : 0; |
|
| 825 | + $object = new $this->crud_class($id); |
|
| 826 | 826 | |
| 827 | 827 | // Abort if an error exists. |
| 828 | - if ( ! empty( $object->last_error ) ) { |
|
| 829 | - return new WP_Error( 'invalid_item', $object->last_error ); |
|
| 828 | + if (!empty($object->last_error)) { |
|
| 829 | + return new WP_Error('invalid_item', $object->last_error); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $schema = $this->get_item_schema(); |
| 833 | - $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); |
|
| 833 | + $data_keys = array_keys(array_filter($schema['properties'], array($this, 'filter_writable_props'))); |
|
| 834 | 834 | |
| 835 | 835 | // Handle all writable props. |
| 836 | - foreach ( $data_keys as $key ) { |
|
| 837 | - $value = $request[ $key ]; |
|
| 836 | + foreach ($data_keys as $key) { |
|
| 837 | + $value = $request[$key]; |
|
| 838 | 838 | |
| 839 | - if ( ! is_null( $value ) ) { |
|
| 840 | - switch ( $key ) { |
|
| 839 | + if (!is_null($value)) { |
|
| 840 | + switch ($key) { |
|
| 841 | 841 | |
| 842 | 842 | case 'meta_data': |
| 843 | - if ( is_array( $value ) ) { |
|
| 844 | - foreach ( $value as $meta ) { |
|
| 845 | - $object->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); |
|
| 843 | + if (is_array($value)) { |
|
| 844 | + foreach ($value as $meta) { |
|
| 845 | + $object->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : ''); |
|
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | 848 | break; |
| 849 | 849 | |
| 850 | 850 | default: |
| 851 | - if ( is_callable( array( $object, "set_{$key}" ) ) ) { |
|
| 852 | - $object->{"set_{$key}"}( $value ); |
|
| 851 | + if (is_callable(array($object, "set_{$key}"))) { |
|
| 852 | + $object->{"set_{$key}"}($value); |
|
| 853 | 853 | } |
| 854 | 854 | break; |
| 855 | 855 | } |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | // Filters an object before it is inserted via the REST API.. |
| 861 | - return apply_filters( "getpaid_rest_pre_insert_{$this->post_type}_object", $object, $request ); |
|
| 861 | + return apply_filters("getpaid_rest_pre_insert_{$this->post_type}_object", $object, $request); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | /** |
@@ -868,10 +868,10 @@ discard block |
||
| 868 | 868 | * @param GetPaid_Meta_Data[] $meta_data meta data objects. |
| 869 | 869 | * @return array |
| 870 | 870 | */ |
| 871 | - protected function prepare_object_meta_data( $meta_data ) { |
|
| 871 | + protected function prepare_object_meta_data($meta_data) { |
|
| 872 | 872 | $meta = array(); |
| 873 | 873 | |
| 874 | - foreach( $meta_data as $object ) { |
|
| 874 | + foreach ($meta_data as $object) { |
|
| 875 | 875 | $meta[] = $object->get_data(); |
| 876 | 876 | } |
| 877 | 877 | |
@@ -885,13 +885,13 @@ discard block |
||
| 885 | 885 | * @param WPInv_Invoice $invoice Invoice items. |
| 886 | 886 | * @return array |
| 887 | 887 | */ |
| 888 | - protected function prepare_invoice_items( $invoice ) { |
|
| 888 | + protected function prepare_invoice_items($invoice) { |
|
| 889 | 889 | $items = array(); |
| 890 | 890 | |
| 891 | - foreach( $invoice->get_items() as $item ) { |
|
| 891 | + foreach ($invoice->get_items() as $item) { |
|
| 892 | 892 | $item_data = $item->prepare_data_for_saving(); |
| 893 | 893 | |
| 894 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 894 | + if ('amount' == $invoice->get_template()) { |
|
| 895 | 895 | $item_data['quantity'] = 1; |
| 896 | 896 | } |
| 897 | 897 | |
@@ -910,54 +910,54 @@ discard block |
||
| 910 | 910 | * @param string $context either view or edit. |
| 911 | 911 | * @return array |
| 912 | 912 | */ |
| 913 | - protected function prepare_object_data( $object, $fields, $context = 'view' ) { |
|
| 913 | + protected function prepare_object_data($object, $fields, $context = 'view') { |
|
| 914 | 914 | |
| 915 | 915 | $data = array(); |
| 916 | 916 | $schema = $this->get_item_schema(); |
| 917 | - $data_keys = array_keys( $schema['properties'] ); |
|
| 917 | + $data_keys = array_keys($schema['properties']); |
|
| 918 | 918 | |
| 919 | 919 | // Handle all writable props. |
| 920 | - foreach ( $data_keys as $key ) { |
|
| 920 | + foreach ($data_keys as $key) { |
|
| 921 | 921 | |
| 922 | 922 | // Abort if it is not included. |
| 923 | - if ( ! empty( $fields ) && ! $this->is_field_included( $key, $fields ) ) { |
|
| 923 | + if (!empty($fields) && !$this->is_field_included($key, $fields)) { |
|
| 924 | 924 | continue; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | // Handle meta data. |
| 928 | - if ( $key == 'meta_data' ) { |
|
| 929 | - $data['meta_data'] = $this->prepare_object_meta_data( $object->get_meta_data() ); |
|
| 928 | + if ($key == 'meta_data') { |
|
| 929 | + $data['meta_data'] = $this->prepare_object_meta_data($object->get_meta_data()); |
|
| 930 | 930 | continue; |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | // Handle items. |
| 934 | - if ( $key == 'items' && is_a( $object, 'WPInv_Invoice' ) ) { |
|
| 935 | - $data['items'] = $this->prepare_invoice_items( $object ); |
|
| 934 | + if ($key == 'items' && is_a($object, 'WPInv_Invoice')) { |
|
| 935 | + $data['items'] = $this->prepare_invoice_items($object); |
|
| 936 | 936 | continue; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | // Booleans. |
| 940 | - if ( is_callable( array( $object, $key ) ) ) { |
|
| 941 | - $data[ $key ] = $object->$key( $context ); |
|
| 940 | + if (is_callable(array($object, $key))) { |
|
| 941 | + $data[$key] = $object->$key($context); |
|
| 942 | 942 | continue; |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | // Get object value. |
| 946 | - if ( is_callable( array( $object, "get_{$key}" ) ) ) { |
|
| 947 | - $value = $object->{"get_{$key}"}( $context ); |
|
| 946 | + if (is_callable(array($object, "get_{$key}"))) { |
|
| 947 | + $value = $object->{"get_{$key}"}($context); |
|
| 948 | 948 | |
| 949 | 949 | // If the value is an instance of GetPaid_Data... |
| 950 | - if ( is_a( $value, 'GetPaid_Data' ) ) { |
|
| 951 | - $value = $value->get_data( $context ); |
|
| 950 | + if (is_a($value, 'GetPaid_Data')) { |
|
| 951 | + $value = $value->get_data($context); |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | // For objects, retrieves it's properties. |
| 955 | - $data[ $key ] = is_object( $value ) ? get_object_vars( $value ) : $value ; |
|
| 955 | + $data[$key] = is_object($value) ? get_object_vars($value) : $value; |
|
| 956 | 956 | continue; |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | // The value does not exist on an object. |
| 960 | - $data[ $key ] = apply_filters( "getpaid_{$this->post_type}_{$key}_object_data", null, $object ); |
|
| 960 | + $data[$key] = apply_filters("getpaid_{$this->post_type}_{$key}_object_data", null, $object); |
|
| 961 | 961 | |
| 962 | 962 | } |
| 963 | 963 | |
@@ -972,23 +972,23 @@ discard block |
||
| 972 | 972 | * @param WP_REST_Request $request Request object. |
| 973 | 973 | * @return WP_REST_Response |
| 974 | 974 | */ |
| 975 | - public function prepare_item_for_response( $object, $request ) { |
|
| 975 | + public function prepare_item_for_response($object, $request) { |
|
| 976 | 976 | |
| 977 | 977 | // Fetch the fields to include in this response. |
| 978 | - $fields = $this->get_fields_for_response( $request ); |
|
| 978 | + $fields = $this->get_fields_for_response($request); |
|
| 979 | 979 | |
| 980 | 980 | // Prepare object data. |
| 981 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 982 | - $data = $this->prepare_object_data( $object, $fields, $context ); |
|
| 983 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
| 984 | - $data = $this->filter_response_by_context( $data, $context ); |
|
| 981 | + $context = !empty($request['context']) ? $request['context'] : 'view'; |
|
| 982 | + $data = $this->prepare_object_data($object, $fields, $context); |
|
| 983 | + $data = $this->add_additional_fields_to_object($data, $request); |
|
| 984 | + $data = $this->filter_response_by_context($data, $context); |
|
| 985 | 985 | |
| 986 | 986 | // Prepare the response. |
| 987 | - $response = rest_ensure_response( $data ); |
|
| 988 | - $response->add_links( $this->prepare_links( $object, $request ) ); |
|
| 987 | + $response = rest_ensure_response($data); |
|
| 988 | + $response->add_links($this->prepare_links($object, $request)); |
|
| 989 | 989 | |
| 990 | 990 | // Filter item response. |
| 991 | - return apply_filters( "getpaid_rest_prepare_{$this->post_type}_object", $response, $object, $request ); |
|
| 991 | + return apply_filters("getpaid_rest_prepare_{$this->post_type}_object", $response, $object, $request); |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | } |
@@ -13,629 +13,629 @@ |
||
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | - 'id' => array( |
|
| 17 | - 'description' => __( 'Unique identifier for the invoice.', 'invoicing' ), |
|
| 18 | - 'type' => 'integer', |
|
| 19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 20 | - 'readonly' => true, |
|
| 21 | - ), |
|
| 22 | - |
|
| 23 | - 'parent_id' => array( |
|
| 24 | - 'description' => __( 'Parent invoice ID.', 'invoicing' ), |
|
| 25 | - 'type' => 'integer', |
|
| 26 | - 'minimum' => 0, |
|
| 27 | - 'default' => 0, |
|
| 28 | - 'context' => array( 'view', 'edit' ), |
|
| 29 | - ), |
|
| 30 | - |
|
| 31 | - 'key' => array( |
|
| 32 | - 'description' => __( 'A unique key for the invoice.', 'invoicing' ), |
|
| 33 | - 'type' => 'string', |
|
| 34 | - 'context' => array( 'view', 'edit' ), |
|
| 35 | - 'readonly' => true, |
|
| 36 | - ), |
|
| 37 | - |
|
| 38 | - 'number' => array( |
|
| 39 | - 'description' => __( 'A unique number for the invoice.', 'invoicing' ), |
|
| 40 | - 'type' => 'string', |
|
| 41 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 42 | - ), |
|
| 43 | - |
|
| 44 | - 'type' => array( |
|
| 45 | - 'description' => __( 'Get the invoice type (e.g invoice, quote etc).', 'invoicing' ), |
|
| 46 | - 'type' => 'string', |
|
| 47 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 48 | - 'readonly' => true, |
|
| 49 | - ), |
|
| 50 | - |
|
| 51 | - 'post_type' => array( |
|
| 52 | - 'description' => __( 'Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing' ), |
|
| 53 | - 'type' => 'string', |
|
| 54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 55 | - 'readonly' => true, |
|
| 56 | - ), |
|
| 57 | - |
|
| 58 | - 'version' => array( |
|
| 59 | - 'description' => __( 'Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing' ), |
|
| 60 | - 'type' => 'integer', |
|
| 61 | - 'context' => array( 'view', 'edit' ), |
|
| 62 | - 'readonly' => true, |
|
| 63 | - ), |
|
| 64 | - |
|
| 65 | - 'template' => array( |
|
| 66 | - 'description' => __( 'The invoice template.', 'invoicing' ), |
|
| 67 | - 'type' => 'string', |
|
| 68 | - 'default' => 'quantity', |
|
| 69 | - 'enum' => array( 'quantity', 'hours', 'amount' ), |
|
| 70 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 71 | - ), |
|
| 72 | - |
|
| 73 | - 'status' => array( |
|
| 74 | - 'description' => __( 'Invoice status.', 'invoicing' ), |
|
| 75 | - 'type' => 'string', |
|
| 76 | - 'default' => 'wpi-pending', |
|
| 77 | - 'enum' => array_keys( wpinv_get_invoice_statuses( true ) ), |
|
| 78 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 79 | - ), |
|
| 80 | - |
|
| 81 | - 'status_nicename' => array( |
|
| 82 | - 'description' => __( 'A human readable name for the invoice status.', 'invoicing' ), |
|
| 83 | - 'type' => 'string', |
|
| 84 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 85 | - 'readonly' => true, |
|
| 86 | - ), |
|
| 87 | - |
|
| 88 | - 'currency' => array( |
|
| 89 | - 'description' => __( 'The invoice currency in ISO format.', 'invoicing' ), |
|
| 90 | - 'type' => 'string', |
|
| 91 | - 'default' => wpinv_get_currency(), |
|
| 92 | - 'enum' => array_keys( wpinv_get_currencies() ), |
|
| 93 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 94 | - ), |
|
| 95 | - |
|
| 96 | - 'date_created' => array( |
|
| 97 | - 'description' => __( "The date the invoice was created, in the site's timezone.", 'invoicing' ), |
|
| 98 | - 'type' => 'string', |
|
| 99 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 100 | - ), |
|
| 101 | - |
|
| 102 | - 'date_created_gmt' => array( |
|
| 103 | - 'description' => __( 'The GMT date the invoice was created.', 'invoicing' ), |
|
| 104 | - 'type' => 'string', |
|
| 105 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 106 | - 'readonly' => true, |
|
| 107 | - ), |
|
| 108 | - |
|
| 109 | - 'date_modified' => array( |
|
| 110 | - 'description' => __( "The date the invoice was last modified, in the site's timezone.", 'invoicing' ), |
|
| 111 | - 'type' => 'string', |
|
| 112 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 113 | - 'readonly' => true, |
|
| 114 | - ), |
|
| 115 | - |
|
| 116 | - 'date_modified_gmt' => array( |
|
| 117 | - 'description' => __( 'The GMT date the invoice was last modified.', 'invoicing' ), |
|
| 118 | - 'type' => 'string', |
|
| 119 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 120 | - 'readonly' => true, |
|
| 121 | - ), |
|
| 122 | - |
|
| 123 | - 'due_date' => array( |
|
| 124 | - 'description' => __( "The invoice's due date, in the site's timezone.", 'invoicing' ), |
|
| 125 | - 'type' => 'string', |
|
| 126 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 127 | - ), |
|
| 128 | - |
|
| 129 | - 'due_date_gmt' => array( |
|
| 130 | - 'description' => __( 'The GMT date the invoice is/was due.', 'invoicing' ), |
|
| 131 | - 'type' => 'string', |
|
| 132 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 133 | - 'readonly' => true, |
|
| 134 | - ), |
|
| 135 | - |
|
| 136 | - 'completed_date' => array( |
|
| 137 | - 'description' => __( "The date the invoice was paid, in the site's timezone.", 'invoicing' ), |
|
| 138 | - 'type' => 'string', |
|
| 139 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 140 | - 'readonly' => true, |
|
| 141 | - ), |
|
| 142 | - |
|
| 143 | - 'completed_date_gmt' => array( |
|
| 144 | - 'description' => __( 'The GMT date the invoice was paid.', 'invoicing' ), |
|
| 145 | - 'type' => 'string', |
|
| 146 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 147 | - 'readonly' => true, |
|
| 148 | - ), |
|
| 149 | - |
|
| 150 | - 'total_discount' => array( |
|
| 151 | - 'description' => __( 'Total discount amount for the invoice.', 'invoicing' ), |
|
| 152 | - 'type' => 'number', |
|
| 153 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 154 | - 'readonly' => true, |
|
| 155 | - ), |
|
| 156 | - |
|
| 157 | - 'total_tax' => array( |
|
| 158 | - 'description' => __( 'Total tax amount for the invoice.', 'invoicing' ), |
|
| 159 | - 'type' => 'number', |
|
| 160 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 161 | - 'readonly' => true, |
|
| 162 | - ), |
|
| 163 | - |
|
| 164 | - 'total_fees' => array( |
|
| 165 | - 'description' => __( 'Total fees amount for the invoice.', 'invoicing' ), |
|
| 166 | - 'type' => 'number', |
|
| 167 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 168 | - 'readonly' => true, |
|
| 169 | - ), |
|
| 170 | - |
|
| 171 | - 'subtotal' => array( |
|
| 172 | - 'description' => __( 'Invoice subtotal.', 'invoicing' ), |
|
| 173 | - 'type' => 'number', |
|
| 174 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 175 | - 'readonly' => true, |
|
| 176 | - ), |
|
| 177 | - |
|
| 178 | - 'total' => array( |
|
| 179 | - 'description' => __( 'Grand total.', 'invoicing' ), |
|
| 180 | - 'type' => 'number', |
|
| 181 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 182 | - 'readonly' => true, |
|
| 183 | - ), |
|
| 184 | - |
|
| 185 | - 'initial_total' => array( |
|
| 186 | - 'description' => __( 'Initial total (for recurring invoices).', 'invoicing' ), |
|
| 187 | - 'type' => 'number', |
|
| 188 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 189 | - 'readonly' => true, |
|
| 190 | - ), |
|
| 191 | - |
|
| 192 | - 'recurring_total' => array( |
|
| 193 | - 'description' => __( 'Recurring total (for recurring invoices).', 'invoicing' ), |
|
| 194 | - 'type' => 'number', |
|
| 195 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 196 | - 'readonly' => true, |
|
| 197 | - ), |
|
| 198 | - |
|
| 199 | - 'totals' => array( |
|
| 200 | - 'description' => __( 'Invoice totals.', 'invoicing' ), |
|
| 201 | - 'type' => 'object', |
|
| 202 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 203 | - 'readonly' => true, |
|
| 204 | - ), |
|
| 205 | - |
|
| 206 | - 'fees' => array( |
|
| 207 | - 'description' => __( 'Invoice fees (Name => properties).', 'invoicing' ), |
|
| 208 | - 'type' => 'object', |
|
| 209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 210 | - 'items' => array( |
|
| 211 | - 'type' => 'object', |
|
| 212 | - 'required' => array( 'amount' ), |
|
| 213 | - 'properties' => array( |
|
| 214 | - 'amount' => array( |
|
| 215 | - 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 216 | - 'type' => 'string', |
|
| 217 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 218 | - ), |
|
| 219 | - 'recurring' => array( |
|
| 220 | - 'description' => __( 'Whether this is a recurring or one-time fee.', 'invoicing' ), |
|
| 221 | - 'type' => array( 'boolean', 'integer' ), |
|
| 222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | - ), |
|
| 224 | - ), |
|
| 225 | - ), |
|
| 226 | - ), |
|
| 227 | - |
|
| 228 | - 'discounts' => array( |
|
| 229 | - 'description' => __( 'Invoice discounts (Name => properties).', 'invoicing' ), |
|
| 230 | - 'type' => 'object', |
|
| 231 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 232 | - 'items' => array( |
|
| 233 | - 'type' => 'object', |
|
| 234 | - 'required' => array( 'amount' ), |
|
| 235 | - 'properties' => array( |
|
| 236 | - 'amount' => array( |
|
| 237 | - 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 238 | - 'type' => 'string', |
|
| 239 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 240 | - ), |
|
| 241 | - 'recurring' => array( |
|
| 242 | - 'description' => __( 'Whether this is a recurring or one-time discount.', 'invoicing' ), |
|
| 243 | - 'type' => array( 'boolean', 'integer' ), |
|
| 244 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 245 | - ), |
|
| 246 | - ), |
|
| 247 | - ), |
|
| 248 | - ), |
|
| 249 | - |
|
| 250 | - 'taxes' => array( |
|
| 251 | - 'description' => __( 'Invoice taxes (Name => properties).', 'invoicing' ), |
|
| 252 | - 'type' => 'object', |
|
| 253 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 254 | - 'items' => array( |
|
| 255 | - 'type' => 'object', |
|
| 256 | - 'required' => array( 'amount' ), |
|
| 257 | - 'properties' => array( |
|
| 258 | - 'amount' => array( |
|
| 259 | - 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 260 | - 'type' => 'string', |
|
| 261 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 262 | - ), |
|
| 263 | - 'recurring' => array( |
|
| 264 | - 'description' => __( 'Whether this is a recurring or one-time tax.', 'invoicing' ), |
|
| 265 | - 'type' => array( 'boolean', 'integer' ), |
|
| 266 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 267 | - ), |
|
| 268 | - ), |
|
| 269 | - ), |
|
| 270 | - ), |
|
| 271 | - |
|
| 272 | - 'items' => array( |
|
| 273 | - 'description' => __( 'Invoice items.', 'invoicing' ), |
|
| 274 | - 'type' => 'array', |
|
| 275 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 276 | - 'items' => array( |
|
| 277 | - 'type' => 'object', |
|
| 278 | - 'required' => array( 'item_id' ), |
|
| 279 | - 'properties' => array( |
|
| 280 | - 'item_id' => array( |
|
| 281 | - 'description' => __( 'Item ID.', 'invoicing' ), |
|
| 282 | - 'type' => 'integer', |
|
| 283 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 284 | - ), |
|
| 285 | - 'item_name' => array( |
|
| 286 | - 'description' => __( 'Item Name.', 'invoicing' ), |
|
| 287 | - 'type' => 'string', |
|
| 288 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 289 | - ), |
|
| 290 | - 'item_description' => array( |
|
| 291 | - 'description' => __( 'Item Description.', 'invoicing' ), |
|
| 292 | - 'type' => 'string', |
|
| 293 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 294 | - ), |
|
| 295 | - 'item_price' => array( |
|
| 296 | - 'description' => __( 'Item Price.', 'invoicing' ), |
|
| 297 | - 'type' => 'number', |
|
| 298 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 299 | - ), |
|
| 300 | - 'quantity' => array( |
|
| 301 | - 'description' => __( 'Item Quantity.', 'invoicing' ), |
|
| 302 | - 'type' => 'integer', |
|
| 303 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 304 | - ), |
|
| 305 | - 'subtotal' => array( |
|
| 306 | - 'description' => __( 'Item Subtotal.', 'invoicing' ), |
|
| 307 | - 'type' => 'number', |
|
| 308 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 309 | - 'readonly' => true, |
|
| 310 | - ), |
|
| 311 | - 'meta' => array( |
|
| 312 | - 'description' => __( 'Item Meta.', 'invoicing' ), |
|
| 313 | - 'type' => 'object', |
|
| 314 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 315 | - ), |
|
| 316 | - ), |
|
| 317 | - ), |
|
| 318 | - ), |
|
| 319 | - |
|
| 320 | - 'mode' => array( |
|
| 321 | - 'description' => __( 'The invoice transaction mode.', 'invoicing' ), |
|
| 322 | - 'type' => 'string', |
|
| 323 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 324 | - 'enum' => array( 'live', 'test' ), |
|
| 325 | - 'readonly' => true, |
|
| 326 | - ), |
|
| 16 | + 'id' => array( |
|
| 17 | + 'description' => __( 'Unique identifier for the invoice.', 'invoicing' ), |
|
| 18 | + 'type' => 'integer', |
|
| 19 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 20 | + 'readonly' => true, |
|
| 21 | + ), |
|
| 22 | + |
|
| 23 | + 'parent_id' => array( |
|
| 24 | + 'description' => __( 'Parent invoice ID.', 'invoicing' ), |
|
| 25 | + 'type' => 'integer', |
|
| 26 | + 'minimum' => 0, |
|
| 27 | + 'default' => 0, |
|
| 28 | + 'context' => array( 'view', 'edit' ), |
|
| 29 | + ), |
|
| 30 | + |
|
| 31 | + 'key' => array( |
|
| 32 | + 'description' => __( 'A unique key for the invoice.', 'invoicing' ), |
|
| 33 | + 'type' => 'string', |
|
| 34 | + 'context' => array( 'view', 'edit' ), |
|
| 35 | + 'readonly' => true, |
|
| 36 | + ), |
|
| 37 | + |
|
| 38 | + 'number' => array( |
|
| 39 | + 'description' => __( 'A unique number for the invoice.', 'invoicing' ), |
|
| 40 | + 'type' => 'string', |
|
| 41 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 42 | + ), |
|
| 43 | + |
|
| 44 | + 'type' => array( |
|
| 45 | + 'description' => __( 'Get the invoice type (e.g invoice, quote etc).', 'invoicing' ), |
|
| 46 | + 'type' => 'string', |
|
| 47 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 48 | + 'readonly' => true, |
|
| 49 | + ), |
|
| 50 | + |
|
| 51 | + 'post_type' => array( |
|
| 52 | + 'description' => __( 'Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing' ), |
|
| 53 | + 'type' => 'string', |
|
| 54 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 55 | + 'readonly' => true, |
|
| 56 | + ), |
|
| 57 | + |
|
| 58 | + 'version' => array( |
|
| 59 | + 'description' => __( 'Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing' ), |
|
| 60 | + 'type' => 'integer', |
|
| 61 | + 'context' => array( 'view', 'edit' ), |
|
| 62 | + 'readonly' => true, |
|
| 63 | + ), |
|
| 64 | + |
|
| 65 | + 'template' => array( |
|
| 66 | + 'description' => __( 'The invoice template.', 'invoicing' ), |
|
| 67 | + 'type' => 'string', |
|
| 68 | + 'default' => 'quantity', |
|
| 69 | + 'enum' => array( 'quantity', 'hours', 'amount' ), |
|
| 70 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 71 | + ), |
|
| 72 | + |
|
| 73 | + 'status' => array( |
|
| 74 | + 'description' => __( 'Invoice status.', 'invoicing' ), |
|
| 75 | + 'type' => 'string', |
|
| 76 | + 'default' => 'wpi-pending', |
|
| 77 | + 'enum' => array_keys( wpinv_get_invoice_statuses( true ) ), |
|
| 78 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 79 | + ), |
|
| 80 | + |
|
| 81 | + 'status_nicename' => array( |
|
| 82 | + 'description' => __( 'A human readable name for the invoice status.', 'invoicing' ), |
|
| 83 | + 'type' => 'string', |
|
| 84 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 85 | + 'readonly' => true, |
|
| 86 | + ), |
|
| 87 | + |
|
| 88 | + 'currency' => array( |
|
| 89 | + 'description' => __( 'The invoice currency in ISO format.', 'invoicing' ), |
|
| 90 | + 'type' => 'string', |
|
| 91 | + 'default' => wpinv_get_currency(), |
|
| 92 | + 'enum' => array_keys( wpinv_get_currencies() ), |
|
| 93 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 94 | + ), |
|
| 95 | + |
|
| 96 | + 'date_created' => array( |
|
| 97 | + 'description' => __( "The date the invoice was created, in the site's timezone.", 'invoicing' ), |
|
| 98 | + 'type' => 'string', |
|
| 99 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 100 | + ), |
|
| 101 | + |
|
| 102 | + 'date_created_gmt' => array( |
|
| 103 | + 'description' => __( 'The GMT date the invoice was created.', 'invoicing' ), |
|
| 104 | + 'type' => 'string', |
|
| 105 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 106 | + 'readonly' => true, |
|
| 107 | + ), |
|
| 108 | + |
|
| 109 | + 'date_modified' => array( |
|
| 110 | + 'description' => __( "The date the invoice was last modified, in the site's timezone.", 'invoicing' ), |
|
| 111 | + 'type' => 'string', |
|
| 112 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 113 | + 'readonly' => true, |
|
| 114 | + ), |
|
| 115 | + |
|
| 116 | + 'date_modified_gmt' => array( |
|
| 117 | + 'description' => __( 'The GMT date the invoice was last modified.', 'invoicing' ), |
|
| 118 | + 'type' => 'string', |
|
| 119 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 120 | + 'readonly' => true, |
|
| 121 | + ), |
|
| 122 | + |
|
| 123 | + 'due_date' => array( |
|
| 124 | + 'description' => __( "The invoice's due date, in the site's timezone.", 'invoicing' ), |
|
| 125 | + 'type' => 'string', |
|
| 126 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 127 | + ), |
|
| 128 | + |
|
| 129 | + 'due_date_gmt' => array( |
|
| 130 | + 'description' => __( 'The GMT date the invoice is/was due.', 'invoicing' ), |
|
| 131 | + 'type' => 'string', |
|
| 132 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 133 | + 'readonly' => true, |
|
| 134 | + ), |
|
| 135 | + |
|
| 136 | + 'completed_date' => array( |
|
| 137 | + 'description' => __( "The date the invoice was paid, in the site's timezone.", 'invoicing' ), |
|
| 138 | + 'type' => 'string', |
|
| 139 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 140 | + 'readonly' => true, |
|
| 141 | + ), |
|
| 142 | + |
|
| 143 | + 'completed_date_gmt' => array( |
|
| 144 | + 'description' => __( 'The GMT date the invoice was paid.', 'invoicing' ), |
|
| 145 | + 'type' => 'string', |
|
| 146 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 147 | + 'readonly' => true, |
|
| 148 | + ), |
|
| 149 | + |
|
| 150 | + 'total_discount' => array( |
|
| 151 | + 'description' => __( 'Total discount amount for the invoice.', 'invoicing' ), |
|
| 152 | + 'type' => 'number', |
|
| 153 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 154 | + 'readonly' => true, |
|
| 155 | + ), |
|
| 156 | + |
|
| 157 | + 'total_tax' => array( |
|
| 158 | + 'description' => __( 'Total tax amount for the invoice.', 'invoicing' ), |
|
| 159 | + 'type' => 'number', |
|
| 160 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 161 | + 'readonly' => true, |
|
| 162 | + ), |
|
| 163 | + |
|
| 164 | + 'total_fees' => array( |
|
| 165 | + 'description' => __( 'Total fees amount for the invoice.', 'invoicing' ), |
|
| 166 | + 'type' => 'number', |
|
| 167 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 168 | + 'readonly' => true, |
|
| 169 | + ), |
|
| 170 | + |
|
| 171 | + 'subtotal' => array( |
|
| 172 | + 'description' => __( 'Invoice subtotal.', 'invoicing' ), |
|
| 173 | + 'type' => 'number', |
|
| 174 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 175 | + 'readonly' => true, |
|
| 176 | + ), |
|
| 177 | + |
|
| 178 | + 'total' => array( |
|
| 179 | + 'description' => __( 'Grand total.', 'invoicing' ), |
|
| 180 | + 'type' => 'number', |
|
| 181 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 182 | + 'readonly' => true, |
|
| 183 | + ), |
|
| 184 | + |
|
| 185 | + 'initial_total' => array( |
|
| 186 | + 'description' => __( 'Initial total (for recurring invoices).', 'invoicing' ), |
|
| 187 | + 'type' => 'number', |
|
| 188 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 189 | + 'readonly' => true, |
|
| 190 | + ), |
|
| 191 | + |
|
| 192 | + 'recurring_total' => array( |
|
| 193 | + 'description' => __( 'Recurring total (for recurring invoices).', 'invoicing' ), |
|
| 194 | + 'type' => 'number', |
|
| 195 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 196 | + 'readonly' => true, |
|
| 197 | + ), |
|
| 198 | + |
|
| 199 | + 'totals' => array( |
|
| 200 | + 'description' => __( 'Invoice totals.', 'invoicing' ), |
|
| 201 | + 'type' => 'object', |
|
| 202 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 203 | + 'readonly' => true, |
|
| 204 | + ), |
|
| 205 | + |
|
| 206 | + 'fees' => array( |
|
| 207 | + 'description' => __( 'Invoice fees (Name => properties).', 'invoicing' ), |
|
| 208 | + 'type' => 'object', |
|
| 209 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 210 | + 'items' => array( |
|
| 211 | + 'type' => 'object', |
|
| 212 | + 'required' => array( 'amount' ), |
|
| 213 | + 'properties' => array( |
|
| 214 | + 'amount' => array( |
|
| 215 | + 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 216 | + 'type' => 'string', |
|
| 217 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 218 | + ), |
|
| 219 | + 'recurring' => array( |
|
| 220 | + 'description' => __( 'Whether this is a recurring or one-time fee.', 'invoicing' ), |
|
| 221 | + 'type' => array( 'boolean', 'integer' ), |
|
| 222 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | + ), |
|
| 224 | + ), |
|
| 225 | + ), |
|
| 226 | + ), |
|
| 227 | + |
|
| 228 | + 'discounts' => array( |
|
| 229 | + 'description' => __( 'Invoice discounts (Name => properties).', 'invoicing' ), |
|
| 230 | + 'type' => 'object', |
|
| 231 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 232 | + 'items' => array( |
|
| 233 | + 'type' => 'object', |
|
| 234 | + 'required' => array( 'amount' ), |
|
| 235 | + 'properties' => array( |
|
| 236 | + 'amount' => array( |
|
| 237 | + 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 238 | + 'type' => 'string', |
|
| 239 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 240 | + ), |
|
| 241 | + 'recurring' => array( |
|
| 242 | + 'description' => __( 'Whether this is a recurring or one-time discount.', 'invoicing' ), |
|
| 243 | + 'type' => array( 'boolean', 'integer' ), |
|
| 244 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 245 | + ), |
|
| 246 | + ), |
|
| 247 | + ), |
|
| 248 | + ), |
|
| 249 | + |
|
| 250 | + 'taxes' => array( |
|
| 251 | + 'description' => __( 'Invoice taxes (Name => properties).', 'invoicing' ), |
|
| 252 | + 'type' => 'object', |
|
| 253 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 254 | + 'items' => array( |
|
| 255 | + 'type' => 'object', |
|
| 256 | + 'required' => array( 'amount' ), |
|
| 257 | + 'properties' => array( |
|
| 258 | + 'amount' => array( |
|
| 259 | + 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 260 | + 'type' => 'string', |
|
| 261 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 262 | + ), |
|
| 263 | + 'recurring' => array( |
|
| 264 | + 'description' => __( 'Whether this is a recurring or one-time tax.', 'invoicing' ), |
|
| 265 | + 'type' => array( 'boolean', 'integer' ), |
|
| 266 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 267 | + ), |
|
| 268 | + ), |
|
| 269 | + ), |
|
| 270 | + ), |
|
| 271 | + |
|
| 272 | + 'items' => array( |
|
| 273 | + 'description' => __( 'Invoice items.', 'invoicing' ), |
|
| 274 | + 'type' => 'array', |
|
| 275 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 276 | + 'items' => array( |
|
| 277 | + 'type' => 'object', |
|
| 278 | + 'required' => array( 'item_id' ), |
|
| 279 | + 'properties' => array( |
|
| 280 | + 'item_id' => array( |
|
| 281 | + 'description' => __( 'Item ID.', 'invoicing' ), |
|
| 282 | + 'type' => 'integer', |
|
| 283 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 284 | + ), |
|
| 285 | + 'item_name' => array( |
|
| 286 | + 'description' => __( 'Item Name.', 'invoicing' ), |
|
| 287 | + 'type' => 'string', |
|
| 288 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 289 | + ), |
|
| 290 | + 'item_description' => array( |
|
| 291 | + 'description' => __( 'Item Description.', 'invoicing' ), |
|
| 292 | + 'type' => 'string', |
|
| 293 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 294 | + ), |
|
| 295 | + 'item_price' => array( |
|
| 296 | + 'description' => __( 'Item Price.', 'invoicing' ), |
|
| 297 | + 'type' => 'number', |
|
| 298 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 299 | + ), |
|
| 300 | + 'quantity' => array( |
|
| 301 | + 'description' => __( 'Item Quantity.', 'invoicing' ), |
|
| 302 | + 'type' => 'integer', |
|
| 303 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 304 | + ), |
|
| 305 | + 'subtotal' => array( |
|
| 306 | + 'description' => __( 'Item Subtotal.', 'invoicing' ), |
|
| 307 | + 'type' => 'number', |
|
| 308 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 309 | + 'readonly' => true, |
|
| 310 | + ), |
|
| 311 | + 'meta' => array( |
|
| 312 | + 'description' => __( 'Item Meta.', 'invoicing' ), |
|
| 313 | + 'type' => 'object', |
|
| 314 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 315 | + ), |
|
| 316 | + ), |
|
| 317 | + ), |
|
| 318 | + ), |
|
| 319 | + |
|
| 320 | + 'mode' => array( |
|
| 321 | + 'description' => __( 'The invoice transaction mode.', 'invoicing' ), |
|
| 322 | + 'type' => 'string', |
|
| 323 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 324 | + 'enum' => array( 'live', 'test' ), |
|
| 325 | + 'readonly' => true, |
|
| 326 | + ), |
|
| 327 | 327 | |
| 328 | - 'discount_code' => array( |
|
| 329 | - 'description' => __( 'The discount code used on this invoice.', 'invoicing' ), |
|
| 330 | - 'type' => 'string', |
|
| 331 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 332 | - ), |
|
| 333 | - |
|
| 334 | - 'gateway' => array( |
|
| 335 | - 'description' => __( 'The gateway used to pay this invoice.', 'invoicing' ), |
|
| 336 | - 'type' => 'string', |
|
| 337 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 338 | - ), |
|
| 339 | - |
|
| 340 | - 'gateway_title' => array( |
|
| 341 | - 'description' => __( 'The title of the gateway used to pay this invoice.', 'invoicing' ), |
|
| 342 | - 'type' => 'string', |
|
| 343 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 344 | - 'readonly' => true, |
|
| 345 | - ), |
|
| 346 | - |
|
| 347 | - 'transaction_id' => array( |
|
| 348 | - 'description' => __( 'The transaction id for this invoice.', 'invoicing' ), |
|
| 349 | - 'type' => 'string', |
|
| 350 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 351 | - ), |
|
| 328 | + 'discount_code' => array( |
|
| 329 | + 'description' => __( 'The discount code used on this invoice.', 'invoicing' ), |
|
| 330 | + 'type' => 'string', |
|
| 331 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 332 | + ), |
|
| 333 | + |
|
| 334 | + 'gateway' => array( |
|
| 335 | + 'description' => __( 'The gateway used to pay this invoice.', 'invoicing' ), |
|
| 336 | + 'type' => 'string', |
|
| 337 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 338 | + ), |
|
| 339 | + |
|
| 340 | + 'gateway_title' => array( |
|
| 341 | + 'description' => __( 'The title of the gateway used to pay this invoice.', 'invoicing' ), |
|
| 342 | + 'type' => 'string', |
|
| 343 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 344 | + 'readonly' => true, |
|
| 345 | + ), |
|
| 346 | + |
|
| 347 | + 'transaction_id' => array( |
|
| 348 | + 'description' => __( 'The transaction id for this invoice.', 'invoicing' ), |
|
| 349 | + 'type' => 'string', |
|
| 350 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 351 | + ), |
|
| 352 | 352 | |
| 353 | - 'disable_taxes' => array( |
|
| 354 | - 'description' => __( 'Whether or not taxes should be disabled for this invoice.', 'invoicing' ), |
|
| 355 | - 'type' => 'boolean ', |
|
| 356 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 357 | - ), |
|
| 358 | - |
|
| 359 | - 'is_viewed' => array( |
|
| 360 | - 'description' => __( 'Whether or not this invoice has been viewed by the user.', 'invoicing' ), |
|
| 361 | - 'type' => 'boolean ', |
|
| 362 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 363 | - 'readonly' => true, |
|
| 364 | - ), |
|
| 365 | - |
|
| 366 | - 'email_cc' => array( |
|
| 367 | - 'description' => __( 'A comma separated list of other emails that should receive communications for this invoice.', 'invoicing' ), |
|
| 368 | - 'type' => 'string ', |
|
| 369 | - 'context' => array( 'view', 'edit' ), |
|
| 370 | - ), |
|
| 371 | - |
|
| 372 | - 'subscription_id' => array( |
|
| 373 | - 'description' => __( 'The ID of the subscription associated with this invoice.', 'invoicing' ), |
|
| 374 | - 'type' => 'string ', |
|
| 375 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 376 | - 'readonly' => true, |
|
| 377 | - ), |
|
| 378 | - |
|
| 379 | - 'subscription_name' => array( |
|
| 380 | - 'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ), |
|
| 381 | - 'type' => 'string ', |
|
| 382 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 383 | - 'readonly' => true, |
|
| 384 | - ), |
|
| 385 | - |
|
| 386 | - 'subscription_name' => array( |
|
| 387 | - 'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ), |
|
| 388 | - 'type' => 'string ', |
|
| 389 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 390 | - 'readonly' => true, |
|
| 391 | - ), |
|
| 392 | - |
|
| 393 | - 'is_parent' => array( |
|
| 394 | - 'description' => __( 'Whether or not this is a parent invoice.', 'invoicing' ), |
|
| 395 | - 'type' => 'boolean', |
|
| 396 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 397 | - 'readonly' => true, |
|
| 398 | - ), |
|
| 399 | - |
|
| 400 | - 'is_renewal' => array( |
|
| 401 | - 'description' => __( 'Whether or not this is a renewal invoice.', 'invoicing' ), |
|
| 402 | - 'type' => 'boolean', |
|
| 403 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 404 | - 'readonly' => true, |
|
| 405 | - ), |
|
| 406 | - |
|
| 407 | - 'is_recurring' => array( |
|
| 408 | - 'description' => __( 'Whether or not this is a recurring invoice.', 'invoicing' ), |
|
| 409 | - 'type' => 'boolean', |
|
| 410 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 411 | - 'readonly' => true, |
|
| 412 | - ), |
|
| 413 | - |
|
| 414 | - 'is_free' => array( |
|
| 415 | - 'description' => __( 'Whether or not this invoice is free.', 'invoicing' ), |
|
| 416 | - 'type' => 'boolean', |
|
| 417 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 418 | - 'readonly' => true, |
|
| 419 | - ), |
|
| 420 | - |
|
| 421 | - 'is_paid' => array( |
|
| 422 | - 'description' => __( 'Whether or not this invoice has been paid.', 'invoicing' ), |
|
| 423 | - 'type' => 'boolean', |
|
| 424 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 425 | - 'readonly' => true, |
|
| 426 | - ), |
|
| 427 | - |
|
| 428 | - 'needs_payment' => array( |
|
| 429 | - 'description' => __( 'Whether or not this invoice needs payment.', 'invoicing' ), |
|
| 430 | - 'type' => 'boolean', |
|
| 431 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 432 | - 'readonly' => true, |
|
| 433 | - ), |
|
| 434 | - |
|
| 435 | - 'is_refunded' => array( |
|
| 436 | - 'description' => __( 'Whether or not this invoice was refunded.', 'invoicing' ), |
|
| 437 | - 'type' => 'boolean', |
|
| 438 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 439 | - 'readonly' => true, |
|
| 440 | - ), |
|
| 441 | - |
|
| 442 | - 'is_due' => array( |
|
| 443 | - 'description' => __( 'Whether or not this invoice is due.', 'invoicing' ), |
|
| 444 | - 'type' => 'boolean', |
|
| 445 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 446 | - 'readonly' => true, |
|
| 447 | - ), |
|
| 448 | - |
|
| 449 | - 'is_held' => array( |
|
| 450 | - 'description' => __( 'Whether or not this invoice has been held for payment confirmation.', 'invoicing' ), |
|
| 451 | - 'type' => 'boolean', |
|
| 452 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 453 | - 'readonly' => true, |
|
| 454 | - ), |
|
| 455 | - |
|
| 456 | - 'is_draft' => array( |
|
| 457 | - 'description' => __( 'Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing' ), |
|
| 458 | - 'type' => 'boolean', |
|
| 459 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 460 | - 'readonly' => true, |
|
| 461 | - ), |
|
| 462 | - |
|
| 463 | - 'path' => array( |
|
| 464 | - 'description' => __( 'The invoice path/slug/name.', 'invoicing' ), |
|
| 465 | - 'type' => 'string', |
|
| 466 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 467 | - 'readonly' => true, |
|
| 468 | - ), |
|
| 469 | - |
|
| 470 | - 'description' => array( |
|
| 471 | - 'description' => __( 'The invoice description.', 'invoicing' ), |
|
| 472 | - 'type' => 'string', |
|
| 473 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 474 | - ), |
|
| 475 | - |
|
| 476 | - 'payment_form' => array( |
|
| 477 | - 'description' => __( 'The id of the payment form used to pay for this invoice.', 'invoicing' ), |
|
| 478 | - 'type' => 'integer', |
|
| 479 | - 'context' => array( 'view', 'edit' ), |
|
| 480 | - 'readonly' => true, |
|
| 481 | - ), |
|
| 482 | - |
|
| 483 | - 'submission_id' => array( |
|
| 484 | - 'description' => __( 'A uniques ID of the submission details used to pay for this invoice.', 'invoicing' ), |
|
| 485 | - 'type' => 'string', |
|
| 486 | - 'context' => array( 'view', 'edit' ), |
|
| 487 | - 'readonly' => true, |
|
| 488 | - ), |
|
| 489 | - |
|
| 490 | - 'customer_id' => array( |
|
| 491 | - 'description' => __( 'The customer id.', 'invoicing' ), |
|
| 492 | - 'type' => 'integer', |
|
| 493 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 494 | - ), |
|
| 495 | - |
|
| 496 | - 'customer_ip' => array( |
|
| 497 | - 'description' => __( "The customer's ip address.", 'invoicing' ), |
|
| 498 | - 'type' => 'string', |
|
| 499 | - 'format' => 'ip', |
|
| 500 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 501 | - ), |
|
| 502 | - |
|
| 503 | - 'first_name' => array( |
|
| 504 | - 'description' => __( "The customer's first name.", 'invoicing' ), |
|
| 505 | - 'type' => 'string', |
|
| 506 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 507 | - ), |
|
| 508 | - |
|
| 509 | - 'last_name' => array( |
|
| 510 | - 'description' => __( "The customer's last name.", 'invoicing' ), |
|
| 511 | - 'type' => 'string', |
|
| 512 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 513 | - ), |
|
| 353 | + 'disable_taxes' => array( |
|
| 354 | + 'description' => __( 'Whether or not taxes should be disabled for this invoice.', 'invoicing' ), |
|
| 355 | + 'type' => 'boolean ', |
|
| 356 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 357 | + ), |
|
| 358 | + |
|
| 359 | + 'is_viewed' => array( |
|
| 360 | + 'description' => __( 'Whether or not this invoice has been viewed by the user.', 'invoicing' ), |
|
| 361 | + 'type' => 'boolean ', |
|
| 362 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 363 | + 'readonly' => true, |
|
| 364 | + ), |
|
| 365 | + |
|
| 366 | + 'email_cc' => array( |
|
| 367 | + 'description' => __( 'A comma separated list of other emails that should receive communications for this invoice.', 'invoicing' ), |
|
| 368 | + 'type' => 'string ', |
|
| 369 | + 'context' => array( 'view', 'edit' ), |
|
| 370 | + ), |
|
| 371 | + |
|
| 372 | + 'subscription_id' => array( |
|
| 373 | + 'description' => __( 'The ID of the subscription associated with this invoice.', 'invoicing' ), |
|
| 374 | + 'type' => 'string ', |
|
| 375 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 376 | + 'readonly' => true, |
|
| 377 | + ), |
|
| 378 | + |
|
| 379 | + 'subscription_name' => array( |
|
| 380 | + 'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ), |
|
| 381 | + 'type' => 'string ', |
|
| 382 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 383 | + 'readonly' => true, |
|
| 384 | + ), |
|
| 385 | + |
|
| 386 | + 'subscription_name' => array( |
|
| 387 | + 'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ), |
|
| 388 | + 'type' => 'string ', |
|
| 389 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 390 | + 'readonly' => true, |
|
| 391 | + ), |
|
| 392 | + |
|
| 393 | + 'is_parent' => array( |
|
| 394 | + 'description' => __( 'Whether or not this is a parent invoice.', 'invoicing' ), |
|
| 395 | + 'type' => 'boolean', |
|
| 396 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 397 | + 'readonly' => true, |
|
| 398 | + ), |
|
| 399 | + |
|
| 400 | + 'is_renewal' => array( |
|
| 401 | + 'description' => __( 'Whether or not this is a renewal invoice.', 'invoicing' ), |
|
| 402 | + 'type' => 'boolean', |
|
| 403 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 404 | + 'readonly' => true, |
|
| 405 | + ), |
|
| 406 | + |
|
| 407 | + 'is_recurring' => array( |
|
| 408 | + 'description' => __( 'Whether or not this is a recurring invoice.', 'invoicing' ), |
|
| 409 | + 'type' => 'boolean', |
|
| 410 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 411 | + 'readonly' => true, |
|
| 412 | + ), |
|
| 413 | + |
|
| 414 | + 'is_free' => array( |
|
| 415 | + 'description' => __( 'Whether or not this invoice is free.', 'invoicing' ), |
|
| 416 | + 'type' => 'boolean', |
|
| 417 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 418 | + 'readonly' => true, |
|
| 419 | + ), |
|
| 420 | + |
|
| 421 | + 'is_paid' => array( |
|
| 422 | + 'description' => __( 'Whether or not this invoice has been paid.', 'invoicing' ), |
|
| 423 | + 'type' => 'boolean', |
|
| 424 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 425 | + 'readonly' => true, |
|
| 426 | + ), |
|
| 427 | + |
|
| 428 | + 'needs_payment' => array( |
|
| 429 | + 'description' => __( 'Whether or not this invoice needs payment.', 'invoicing' ), |
|
| 430 | + 'type' => 'boolean', |
|
| 431 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 432 | + 'readonly' => true, |
|
| 433 | + ), |
|
| 434 | + |
|
| 435 | + 'is_refunded' => array( |
|
| 436 | + 'description' => __( 'Whether or not this invoice was refunded.', 'invoicing' ), |
|
| 437 | + 'type' => 'boolean', |
|
| 438 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 439 | + 'readonly' => true, |
|
| 440 | + ), |
|
| 441 | + |
|
| 442 | + 'is_due' => array( |
|
| 443 | + 'description' => __( 'Whether or not this invoice is due.', 'invoicing' ), |
|
| 444 | + 'type' => 'boolean', |
|
| 445 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 446 | + 'readonly' => true, |
|
| 447 | + ), |
|
| 448 | + |
|
| 449 | + 'is_held' => array( |
|
| 450 | + 'description' => __( 'Whether or not this invoice has been held for payment confirmation.', 'invoicing' ), |
|
| 451 | + 'type' => 'boolean', |
|
| 452 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 453 | + 'readonly' => true, |
|
| 454 | + ), |
|
| 455 | + |
|
| 456 | + 'is_draft' => array( |
|
| 457 | + 'description' => __( 'Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing' ), |
|
| 458 | + 'type' => 'boolean', |
|
| 459 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 460 | + 'readonly' => true, |
|
| 461 | + ), |
|
| 462 | + |
|
| 463 | + 'path' => array( |
|
| 464 | + 'description' => __( 'The invoice path/slug/name.', 'invoicing' ), |
|
| 465 | + 'type' => 'string', |
|
| 466 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 467 | + 'readonly' => true, |
|
| 468 | + ), |
|
| 469 | + |
|
| 470 | + 'description' => array( |
|
| 471 | + 'description' => __( 'The invoice description.', 'invoicing' ), |
|
| 472 | + 'type' => 'string', |
|
| 473 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 474 | + ), |
|
| 475 | + |
|
| 476 | + 'payment_form' => array( |
|
| 477 | + 'description' => __( 'The id of the payment form used to pay for this invoice.', 'invoicing' ), |
|
| 478 | + 'type' => 'integer', |
|
| 479 | + 'context' => array( 'view', 'edit' ), |
|
| 480 | + 'readonly' => true, |
|
| 481 | + ), |
|
| 482 | + |
|
| 483 | + 'submission_id' => array( |
|
| 484 | + 'description' => __( 'A uniques ID of the submission details used to pay for this invoice.', 'invoicing' ), |
|
| 485 | + 'type' => 'string', |
|
| 486 | + 'context' => array( 'view', 'edit' ), |
|
| 487 | + 'readonly' => true, |
|
| 488 | + ), |
|
| 489 | + |
|
| 490 | + 'customer_id' => array( |
|
| 491 | + 'description' => __( 'The customer id.', 'invoicing' ), |
|
| 492 | + 'type' => 'integer', |
|
| 493 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 494 | + ), |
|
| 495 | + |
|
| 496 | + 'customer_ip' => array( |
|
| 497 | + 'description' => __( "The customer's ip address.", 'invoicing' ), |
|
| 498 | + 'type' => 'string', |
|
| 499 | + 'format' => 'ip', |
|
| 500 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 501 | + ), |
|
| 502 | + |
|
| 503 | + 'first_name' => array( |
|
| 504 | + 'description' => __( "The customer's first name.", 'invoicing' ), |
|
| 505 | + 'type' => 'string', |
|
| 506 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 507 | + ), |
|
| 508 | + |
|
| 509 | + 'last_name' => array( |
|
| 510 | + 'description' => __( "The customer's last name.", 'invoicing' ), |
|
| 511 | + 'type' => 'string', |
|
| 512 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 513 | + ), |
|
| 514 | 514 | |
| 515 | - 'full_name' => array( |
|
| 516 | - 'description' => __( "The customer's full name.", 'invoicing' ), |
|
| 517 | - 'type' => 'string', |
|
| 518 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 519 | - 'readonly' => true, |
|
| 520 | - ), |
|
| 521 | - |
|
| 522 | - 'phone_number' => array( |
|
| 523 | - 'description' => __( "The customer's phone number.", 'invoicing' ), |
|
| 524 | - 'type' => 'string', |
|
| 525 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 526 | - ), |
|
| 527 | - |
|
| 528 | - 'email_address' => array( |
|
| 529 | - 'description' => __( "The customer's email address.", 'invoicing' ), |
|
| 530 | - 'type' => 'string', |
|
| 531 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 532 | - 'readonly' => true, |
|
| 533 | - ), |
|
| 534 | - |
|
| 535 | - 'customer_country' => array( |
|
| 536 | - 'description' => __( "The customer's country.", 'invoicing' ), |
|
| 537 | - 'type' => 'string', |
|
| 538 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 539 | - 'default' => wpinv_get_default_country(), |
|
| 540 | - ), |
|
| 541 | - |
|
| 542 | - 'customer_state' => array( |
|
| 543 | - 'description' => __( "The customer's state.", 'invoicing' ), |
|
| 544 | - 'type' => 'string', |
|
| 545 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 546 | - ), |
|
| 547 | - |
|
| 548 | - 'customer_city' => array( |
|
| 549 | - 'description' => __( "The customer's city.", 'invoicing' ), |
|
| 550 | - 'type' => 'string', |
|
| 551 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 552 | - ), |
|
| 553 | - |
|
| 554 | - 'customer_zip' => array( |
|
| 555 | - 'description' => __( "The customer's zip/postal code.", 'invoicing' ), |
|
| 556 | - 'type' => 'string', |
|
| 557 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 558 | - ), |
|
| 559 | - |
|
| 560 | - 'customer_company' => array( |
|
| 561 | - 'description' => __( "The customer's company name.", 'invoicing' ), |
|
| 562 | - 'type' => 'string', |
|
| 563 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 564 | - ), |
|
| 565 | - |
|
| 566 | - 'vat_number' => array( |
|
| 567 | - 'description' => __( "The customer's VAT number.", 'invoicing' ), |
|
| 568 | - 'type' => 'string', |
|
| 569 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 570 | - ), |
|
| 571 | - |
|
| 572 | - 'vat_rate' => array( |
|
| 573 | - 'description' => __( "The customer's VAT rate.", 'invoicing' ), |
|
| 574 | - 'type' => 'number', |
|
| 575 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 576 | - 'readonly' => true, |
|
| 577 | - ), |
|
| 578 | - |
|
| 579 | - 'customer_address' => array( |
|
| 580 | - 'description' => __( "The customer's address.", 'invoicing' ), |
|
| 581 | - 'type' => 'string', |
|
| 582 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 583 | - ), |
|
| 584 | - |
|
| 585 | - 'address_confirmed' => array( |
|
| 586 | - 'description' => __( "Whether or not the customer's address is confirmed.", 'invoicing' ), |
|
| 587 | - 'type' => 'boolean', |
|
| 588 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 589 | - ), |
|
| 590 | - |
|
| 591 | - 'meta_data' => array( |
|
| 592 | - 'description' => __( 'Invoice meta data.', 'invoicing' ), |
|
| 593 | - 'type' => 'array', |
|
| 594 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 595 | - 'items' => array( |
|
| 596 | - 'type' => 'object', |
|
| 597 | - 'properties' => array( |
|
| 598 | - 'id' => array( |
|
| 599 | - 'description' => __( 'Meta ID.', 'invoicing' ), |
|
| 600 | - 'type' => 'string', |
|
| 601 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 602 | - ), |
|
| 603 | - 'key' => array( |
|
| 604 | - 'description' => __( 'Meta key.', 'invoicing' ), |
|
| 605 | - 'type' => 'string', |
|
| 606 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 607 | - ), |
|
| 608 | - 'value' => array( |
|
| 609 | - 'description' => __( 'Meta Value.', 'invoicing' ), |
|
| 610 | - 'type' => array( 'string', 'array', 'object', 'integer', 'null' ), |
|
| 611 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 612 | - ), |
|
| 613 | - ), |
|
| 614 | - ), |
|
| 615 | - ), |
|
| 616 | - |
|
| 617 | - 'view_url' => array( |
|
| 618 | - 'description' => __( 'URL to the invoice.', 'invoicing' ), |
|
| 619 | - 'type' => 'string', |
|
| 620 | - 'format' => 'uri', |
|
| 621 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 622 | - 'readonly' => true, |
|
| 623 | - ), |
|
| 624 | - |
|
| 625 | - 'checkout_payment_url' => array( |
|
| 626 | - 'description' => __( 'URL to the invoice checkout page.', 'invoicing' ), |
|
| 627 | - 'type' => 'string', |
|
| 628 | - 'format' => 'uri', |
|
| 629 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 630 | - 'readonly' => true, |
|
| 631 | - ), |
|
| 632 | - |
|
| 633 | - 'receipt_url' => array( |
|
| 634 | - 'description' => __( 'URL to the invoice receipt page.', 'invoicing' ), |
|
| 635 | - 'type' => 'string', |
|
| 636 | - 'format' => 'uri', |
|
| 637 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 638 | - 'readonly' => true, |
|
| 639 | - ), |
|
| 515 | + 'full_name' => array( |
|
| 516 | + 'description' => __( "The customer's full name.", 'invoicing' ), |
|
| 517 | + 'type' => 'string', |
|
| 518 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 519 | + 'readonly' => true, |
|
| 520 | + ), |
|
| 521 | + |
|
| 522 | + 'phone_number' => array( |
|
| 523 | + 'description' => __( "The customer's phone number.", 'invoicing' ), |
|
| 524 | + 'type' => 'string', |
|
| 525 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 526 | + ), |
|
| 527 | + |
|
| 528 | + 'email_address' => array( |
|
| 529 | + 'description' => __( "The customer's email address.", 'invoicing' ), |
|
| 530 | + 'type' => 'string', |
|
| 531 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 532 | + 'readonly' => true, |
|
| 533 | + ), |
|
| 534 | + |
|
| 535 | + 'customer_country' => array( |
|
| 536 | + 'description' => __( "The customer's country.", 'invoicing' ), |
|
| 537 | + 'type' => 'string', |
|
| 538 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 539 | + 'default' => wpinv_get_default_country(), |
|
| 540 | + ), |
|
| 541 | + |
|
| 542 | + 'customer_state' => array( |
|
| 543 | + 'description' => __( "The customer's state.", 'invoicing' ), |
|
| 544 | + 'type' => 'string', |
|
| 545 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 546 | + ), |
|
| 547 | + |
|
| 548 | + 'customer_city' => array( |
|
| 549 | + 'description' => __( "The customer's city.", 'invoicing' ), |
|
| 550 | + 'type' => 'string', |
|
| 551 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 552 | + ), |
|
| 553 | + |
|
| 554 | + 'customer_zip' => array( |
|
| 555 | + 'description' => __( "The customer's zip/postal code.", 'invoicing' ), |
|
| 556 | + 'type' => 'string', |
|
| 557 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 558 | + ), |
|
| 559 | + |
|
| 560 | + 'customer_company' => array( |
|
| 561 | + 'description' => __( "The customer's company name.", 'invoicing' ), |
|
| 562 | + 'type' => 'string', |
|
| 563 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 564 | + ), |
|
| 565 | + |
|
| 566 | + 'vat_number' => array( |
|
| 567 | + 'description' => __( "The customer's VAT number.", 'invoicing' ), |
|
| 568 | + 'type' => 'string', |
|
| 569 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 570 | + ), |
|
| 571 | + |
|
| 572 | + 'vat_rate' => array( |
|
| 573 | + 'description' => __( "The customer's VAT rate.", 'invoicing' ), |
|
| 574 | + 'type' => 'number', |
|
| 575 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 576 | + 'readonly' => true, |
|
| 577 | + ), |
|
| 578 | + |
|
| 579 | + 'customer_address' => array( |
|
| 580 | + 'description' => __( "The customer's address.", 'invoicing' ), |
|
| 581 | + 'type' => 'string', |
|
| 582 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 583 | + ), |
|
| 584 | + |
|
| 585 | + 'address_confirmed' => array( |
|
| 586 | + 'description' => __( "Whether or not the customer's address is confirmed.", 'invoicing' ), |
|
| 587 | + 'type' => 'boolean', |
|
| 588 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 589 | + ), |
|
| 590 | + |
|
| 591 | + 'meta_data' => array( |
|
| 592 | + 'description' => __( 'Invoice meta data.', 'invoicing' ), |
|
| 593 | + 'type' => 'array', |
|
| 594 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 595 | + 'items' => array( |
|
| 596 | + 'type' => 'object', |
|
| 597 | + 'properties' => array( |
|
| 598 | + 'id' => array( |
|
| 599 | + 'description' => __( 'Meta ID.', 'invoicing' ), |
|
| 600 | + 'type' => 'string', |
|
| 601 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 602 | + ), |
|
| 603 | + 'key' => array( |
|
| 604 | + 'description' => __( 'Meta key.', 'invoicing' ), |
|
| 605 | + 'type' => 'string', |
|
| 606 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 607 | + ), |
|
| 608 | + 'value' => array( |
|
| 609 | + 'description' => __( 'Meta Value.', 'invoicing' ), |
|
| 610 | + 'type' => array( 'string', 'array', 'object', 'integer', 'null' ), |
|
| 611 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 612 | + ), |
|
| 613 | + ), |
|
| 614 | + ), |
|
| 615 | + ), |
|
| 616 | + |
|
| 617 | + 'view_url' => array( |
|
| 618 | + 'description' => __( 'URL to the invoice.', 'invoicing' ), |
|
| 619 | + 'type' => 'string', |
|
| 620 | + 'format' => 'uri', |
|
| 621 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 622 | + 'readonly' => true, |
|
| 623 | + ), |
|
| 624 | + |
|
| 625 | + 'checkout_payment_url' => array( |
|
| 626 | + 'description' => __( 'URL to the invoice checkout page.', 'invoicing' ), |
|
| 627 | + 'type' => 'string', |
|
| 628 | + 'format' => 'uri', |
|
| 629 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 630 | + 'readonly' => true, |
|
| 631 | + ), |
|
| 632 | + |
|
| 633 | + 'receipt_url' => array( |
|
| 634 | + 'description' => __( 'URL to the invoice receipt page.', 'invoicing' ), |
|
| 635 | + 'type' => 'string', |
|
| 636 | + 'format' => 'uri', |
|
| 637 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 638 | + 'readonly' => true, |
|
| 639 | + ), |
|
| 640 | 640 | |
| 641 | 641 | ); |
@@ -9,632 +9,632 @@ |
||
| 9 | 9 | * @version 1.0.19 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | 16 | 'id' => array( |
| 17 | - 'description' => __( 'Unique identifier for the invoice.', 'invoicing' ), |
|
| 17 | + 'description' => __('Unique identifier for the invoice.', 'invoicing'), |
|
| 18 | 18 | 'type' => 'integer', |
| 19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 19 | + 'context' => array('view', 'edit', 'embed'), |
|
| 20 | 20 | 'readonly' => true, |
| 21 | 21 | ), |
| 22 | 22 | |
| 23 | 23 | 'parent_id' => array( |
| 24 | - 'description' => __( 'Parent invoice ID.', 'invoicing' ), |
|
| 24 | + 'description' => __('Parent invoice ID.', 'invoicing'), |
|
| 25 | 25 | 'type' => 'integer', |
| 26 | 26 | 'minimum' => 0, |
| 27 | 27 | 'default' => 0, |
| 28 | - 'context' => array( 'view', 'edit' ), |
|
| 28 | + 'context' => array('view', 'edit'), |
|
| 29 | 29 | ), |
| 30 | 30 | |
| 31 | 31 | 'key' => array( |
| 32 | - 'description' => __( 'A unique key for the invoice.', 'invoicing' ), |
|
| 32 | + 'description' => __('A unique key for the invoice.', 'invoicing'), |
|
| 33 | 33 | 'type' => 'string', |
| 34 | - 'context' => array( 'view', 'edit' ), |
|
| 34 | + 'context' => array('view', 'edit'), |
|
| 35 | 35 | 'readonly' => true, |
| 36 | 36 | ), |
| 37 | 37 | |
| 38 | 38 | 'number' => array( |
| 39 | - 'description' => __( 'A unique number for the invoice.', 'invoicing' ), |
|
| 39 | + 'description' => __('A unique number for the invoice.', 'invoicing'), |
|
| 40 | 40 | 'type' => 'string', |
| 41 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 41 | + 'context' => array('view', 'edit', 'embed'), |
|
| 42 | 42 | ), |
| 43 | 43 | |
| 44 | 44 | 'type' => array( |
| 45 | - 'description' => __( 'Get the invoice type (e.g invoice, quote etc).', 'invoicing' ), |
|
| 45 | + 'description' => __('Get the invoice type (e.g invoice, quote etc).', 'invoicing'), |
|
| 46 | 46 | 'type' => 'string', |
| 47 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 47 | + 'context' => array('view', 'edit', 'embed'), |
|
| 48 | 48 | 'readonly' => true, |
| 49 | 49 | ), |
| 50 | 50 | |
| 51 | 51 | 'post_type' => array( |
| 52 | - 'description' => __( 'Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing' ), |
|
| 52 | + 'description' => __('Get the invoice post type (e.g wpi_invoice, wpi_quote etc).', 'invoicing'), |
|
| 53 | 53 | 'type' => 'string', |
| 54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 54 | + 'context' => array('view', 'edit', 'embed'), |
|
| 55 | 55 | 'readonly' => true, |
| 56 | 56 | ), |
| 57 | 57 | |
| 58 | 58 | 'version' => array( |
| 59 | - 'description' => __( 'Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing' ), |
|
| 59 | + 'description' => __('Version of GetPaid/Invoicing which last updated the invoice.', 'invoicing'), |
|
| 60 | 60 | 'type' => 'integer', |
| 61 | - 'context' => array( 'view', 'edit' ), |
|
| 61 | + 'context' => array('view', 'edit'), |
|
| 62 | 62 | 'readonly' => true, |
| 63 | 63 | ), |
| 64 | 64 | |
| 65 | 65 | 'template' => array( |
| 66 | - 'description' => __( 'The invoice template.', 'invoicing' ), |
|
| 66 | + 'description' => __('The invoice template.', 'invoicing'), |
|
| 67 | 67 | 'type' => 'string', |
| 68 | 68 | 'default' => 'quantity', |
| 69 | - 'enum' => array( 'quantity', 'hours', 'amount' ), |
|
| 70 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 69 | + 'enum' => array('quantity', 'hours', 'amount'), |
|
| 70 | + 'context' => array('view', 'edit', 'embed'), |
|
| 71 | 71 | ), |
| 72 | 72 | |
| 73 | 73 | 'status' => array( |
| 74 | - 'description' => __( 'Invoice status.', 'invoicing' ), |
|
| 74 | + 'description' => __('Invoice status.', 'invoicing'), |
|
| 75 | 75 | 'type' => 'string', |
| 76 | 76 | 'default' => 'wpi-pending', |
| 77 | - 'enum' => array_keys( wpinv_get_invoice_statuses( true ) ), |
|
| 78 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 77 | + 'enum' => array_keys(wpinv_get_invoice_statuses(true)), |
|
| 78 | + 'context' => array('view', 'edit', 'embed'), |
|
| 79 | 79 | ), |
| 80 | 80 | |
| 81 | 81 | 'status_nicename' => array( |
| 82 | - 'description' => __( 'A human readable name for the invoice status.', 'invoicing' ), |
|
| 82 | + 'description' => __('A human readable name for the invoice status.', 'invoicing'), |
|
| 83 | 83 | 'type' => 'string', |
| 84 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 84 | + 'context' => array('view', 'edit', 'embed'), |
|
| 85 | 85 | 'readonly' => true, |
| 86 | 86 | ), |
| 87 | 87 | |
| 88 | 88 | 'currency' => array( |
| 89 | - 'description' => __( 'The invoice currency in ISO format.', 'invoicing' ), |
|
| 89 | + 'description' => __('The invoice currency in ISO format.', 'invoicing'), |
|
| 90 | 90 | 'type' => 'string', |
| 91 | 91 | 'default' => wpinv_get_currency(), |
| 92 | - 'enum' => array_keys( wpinv_get_currencies() ), |
|
| 93 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 92 | + 'enum' => array_keys(wpinv_get_currencies()), |
|
| 93 | + 'context' => array('view', 'edit', 'embed'), |
|
| 94 | 94 | ), |
| 95 | 95 | |
| 96 | 96 | 'date_created' => array( |
| 97 | - 'description' => __( "The date the invoice was created, in the site's timezone.", 'invoicing' ), |
|
| 97 | + 'description' => __("The date the invoice was created, in the site's timezone.", 'invoicing'), |
|
| 98 | 98 | 'type' => 'string', |
| 99 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 99 | + 'context' => array('view', 'edit', 'embed'), |
|
| 100 | 100 | ), |
| 101 | 101 | |
| 102 | 102 | 'date_created_gmt' => array( |
| 103 | - 'description' => __( 'The GMT date the invoice was created.', 'invoicing' ), |
|
| 103 | + 'description' => __('The GMT date the invoice was created.', 'invoicing'), |
|
| 104 | 104 | 'type' => 'string', |
| 105 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 105 | + 'context' => array('view', 'edit', 'embed'), |
|
| 106 | 106 | 'readonly' => true, |
| 107 | 107 | ), |
| 108 | 108 | |
| 109 | 109 | 'date_modified' => array( |
| 110 | - 'description' => __( "The date the invoice was last modified, in the site's timezone.", 'invoicing' ), |
|
| 110 | + 'description' => __("The date the invoice was last modified, in the site's timezone.", 'invoicing'), |
|
| 111 | 111 | 'type' => 'string', |
| 112 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 112 | + 'context' => array('view', 'edit', 'embed'), |
|
| 113 | 113 | 'readonly' => true, |
| 114 | 114 | ), |
| 115 | 115 | |
| 116 | 116 | 'date_modified_gmt' => array( |
| 117 | - 'description' => __( 'The GMT date the invoice was last modified.', 'invoicing' ), |
|
| 117 | + 'description' => __('The GMT date the invoice was last modified.', 'invoicing'), |
|
| 118 | 118 | 'type' => 'string', |
| 119 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 119 | + 'context' => array('view', 'edit', 'embed'), |
|
| 120 | 120 | 'readonly' => true, |
| 121 | 121 | ), |
| 122 | 122 | |
| 123 | 123 | 'due_date' => array( |
| 124 | - 'description' => __( "The invoice's due date, in the site's timezone.", 'invoicing' ), |
|
| 124 | + 'description' => __("The invoice's due date, in the site's timezone.", 'invoicing'), |
|
| 125 | 125 | 'type' => 'string', |
| 126 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 126 | + 'context' => array('view', 'edit', 'embed'), |
|
| 127 | 127 | ), |
| 128 | 128 | |
| 129 | 129 | 'due_date_gmt' => array( |
| 130 | - 'description' => __( 'The GMT date the invoice is/was due.', 'invoicing' ), |
|
| 130 | + 'description' => __('The GMT date the invoice is/was due.', 'invoicing'), |
|
| 131 | 131 | 'type' => 'string', |
| 132 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 132 | + 'context' => array('view', 'edit', 'embed'), |
|
| 133 | 133 | 'readonly' => true, |
| 134 | 134 | ), |
| 135 | 135 | |
| 136 | 136 | 'completed_date' => array( |
| 137 | - 'description' => __( "The date the invoice was paid, in the site's timezone.", 'invoicing' ), |
|
| 137 | + 'description' => __("The date the invoice was paid, in the site's timezone.", 'invoicing'), |
|
| 138 | 138 | 'type' => 'string', |
| 139 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 139 | + 'context' => array('view', 'edit', 'embed'), |
|
| 140 | 140 | 'readonly' => true, |
| 141 | 141 | ), |
| 142 | 142 | |
| 143 | 143 | 'completed_date_gmt' => array( |
| 144 | - 'description' => __( 'The GMT date the invoice was paid.', 'invoicing' ), |
|
| 144 | + 'description' => __('The GMT date the invoice was paid.', 'invoicing'), |
|
| 145 | 145 | 'type' => 'string', |
| 146 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 146 | + 'context' => array('view', 'edit', 'embed'), |
|
| 147 | 147 | 'readonly' => true, |
| 148 | 148 | ), |
| 149 | 149 | |
| 150 | 150 | 'total_discount' => array( |
| 151 | - 'description' => __( 'Total discount amount for the invoice.', 'invoicing' ), |
|
| 151 | + 'description' => __('Total discount amount for the invoice.', 'invoicing'), |
|
| 152 | 152 | 'type' => 'number', |
| 153 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 153 | + 'context' => array('view', 'edit', 'embed'), |
|
| 154 | 154 | 'readonly' => true, |
| 155 | 155 | ), |
| 156 | 156 | |
| 157 | 157 | 'total_tax' => array( |
| 158 | - 'description' => __( 'Total tax amount for the invoice.', 'invoicing' ), |
|
| 158 | + 'description' => __('Total tax amount for the invoice.', 'invoicing'), |
|
| 159 | 159 | 'type' => 'number', |
| 160 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 160 | + 'context' => array('view', 'edit', 'embed'), |
|
| 161 | 161 | 'readonly' => true, |
| 162 | 162 | ), |
| 163 | 163 | |
| 164 | 164 | 'total_fees' => array( |
| 165 | - 'description' => __( 'Total fees amount for the invoice.', 'invoicing' ), |
|
| 165 | + 'description' => __('Total fees amount for the invoice.', 'invoicing'), |
|
| 166 | 166 | 'type' => 'number', |
| 167 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 167 | + 'context' => array('view', 'edit', 'embed'), |
|
| 168 | 168 | 'readonly' => true, |
| 169 | 169 | ), |
| 170 | 170 | |
| 171 | 171 | 'subtotal' => array( |
| 172 | - 'description' => __( 'Invoice subtotal.', 'invoicing' ), |
|
| 172 | + 'description' => __('Invoice subtotal.', 'invoicing'), |
|
| 173 | 173 | 'type' => 'number', |
| 174 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 174 | + 'context' => array('view', 'edit', 'embed'), |
|
| 175 | 175 | 'readonly' => true, |
| 176 | 176 | ), |
| 177 | 177 | |
| 178 | 178 | 'total' => array( |
| 179 | - 'description' => __( 'Grand total.', 'invoicing' ), |
|
| 179 | + 'description' => __('Grand total.', 'invoicing'), |
|
| 180 | 180 | 'type' => 'number', |
| 181 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 181 | + 'context' => array('view', 'edit', 'embed'), |
|
| 182 | 182 | 'readonly' => true, |
| 183 | 183 | ), |
| 184 | 184 | |
| 185 | 185 | 'initial_total' => array( |
| 186 | - 'description' => __( 'Initial total (for recurring invoices).', 'invoicing' ), |
|
| 186 | + 'description' => __('Initial total (for recurring invoices).', 'invoicing'), |
|
| 187 | 187 | 'type' => 'number', |
| 188 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 188 | + 'context' => array('view', 'edit', 'embed'), |
|
| 189 | 189 | 'readonly' => true, |
| 190 | 190 | ), |
| 191 | 191 | |
| 192 | 192 | 'recurring_total' => array( |
| 193 | - 'description' => __( 'Recurring total (for recurring invoices).', 'invoicing' ), |
|
| 193 | + 'description' => __('Recurring total (for recurring invoices).', 'invoicing'), |
|
| 194 | 194 | 'type' => 'number', |
| 195 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 195 | + 'context' => array('view', 'edit', 'embed'), |
|
| 196 | 196 | 'readonly' => true, |
| 197 | 197 | ), |
| 198 | 198 | |
| 199 | 199 | 'totals' => array( |
| 200 | - 'description' => __( 'Invoice totals.', 'invoicing' ), |
|
| 200 | + 'description' => __('Invoice totals.', 'invoicing'), |
|
| 201 | 201 | 'type' => 'object', |
| 202 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 202 | + 'context' => array('view', 'edit', 'embed'), |
|
| 203 | 203 | 'readonly' => true, |
| 204 | 204 | ), |
| 205 | 205 | |
| 206 | 206 | 'fees' => array( |
| 207 | - 'description' => __( 'Invoice fees (Name => properties).', 'invoicing' ), |
|
| 207 | + 'description' => __('Invoice fees (Name => properties).', 'invoicing'), |
|
| 208 | 208 | 'type' => 'object', |
| 209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 209 | + 'context' => array('view', 'edit', 'embed'), |
|
| 210 | 210 | 'items' => array( |
| 211 | 211 | 'type' => 'object', |
| 212 | - 'required' => array( 'amount' ), |
|
| 212 | + 'required' => array('amount'), |
|
| 213 | 213 | 'properties' => array( |
| 214 | 214 | 'amount' => array( |
| 215 | - 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 215 | + 'description' => __('Fee amount.', 'invoicing'), |
|
| 216 | 216 | 'type' => 'string', |
| 217 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 217 | + 'context' => array('view', 'edit', 'embed'), |
|
| 218 | 218 | ), |
| 219 | 219 | 'recurring' => array( |
| 220 | - 'description' => __( 'Whether this is a recurring or one-time fee.', 'invoicing' ), |
|
| 221 | - 'type' => array( 'boolean', 'integer' ), |
|
| 222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 220 | + 'description' => __('Whether this is a recurring or one-time fee.', 'invoicing'), |
|
| 221 | + 'type' => array('boolean', 'integer'), |
|
| 222 | + 'context' => array('view', 'edit', 'embed'), |
|
| 223 | 223 | ), |
| 224 | 224 | ), |
| 225 | 225 | ), |
| 226 | 226 | ), |
| 227 | 227 | |
| 228 | 228 | 'discounts' => array( |
| 229 | - 'description' => __( 'Invoice discounts (Name => properties).', 'invoicing' ), |
|
| 229 | + 'description' => __('Invoice discounts (Name => properties).', 'invoicing'), |
|
| 230 | 230 | 'type' => 'object', |
| 231 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 231 | + 'context' => array('view', 'edit', 'embed'), |
|
| 232 | 232 | 'items' => array( |
| 233 | 233 | 'type' => 'object', |
| 234 | - 'required' => array( 'amount' ), |
|
| 234 | + 'required' => array('amount'), |
|
| 235 | 235 | 'properties' => array( |
| 236 | 236 | 'amount' => array( |
| 237 | - 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 237 | + 'description' => __('Fee amount.', 'invoicing'), |
|
| 238 | 238 | 'type' => 'string', |
| 239 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 239 | + 'context' => array('view', 'edit', 'embed'), |
|
| 240 | 240 | ), |
| 241 | 241 | 'recurring' => array( |
| 242 | - 'description' => __( 'Whether this is a recurring or one-time discount.', 'invoicing' ), |
|
| 243 | - 'type' => array( 'boolean', 'integer' ), |
|
| 244 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 242 | + 'description' => __('Whether this is a recurring or one-time discount.', 'invoicing'), |
|
| 243 | + 'type' => array('boolean', 'integer'), |
|
| 244 | + 'context' => array('view', 'edit', 'embed'), |
|
| 245 | 245 | ), |
| 246 | 246 | ), |
| 247 | 247 | ), |
| 248 | 248 | ), |
| 249 | 249 | |
| 250 | 250 | 'taxes' => array( |
| 251 | - 'description' => __( 'Invoice taxes (Name => properties).', 'invoicing' ), |
|
| 251 | + 'description' => __('Invoice taxes (Name => properties).', 'invoicing'), |
|
| 252 | 252 | 'type' => 'object', |
| 253 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 253 | + 'context' => array('view', 'edit', 'embed'), |
|
| 254 | 254 | 'items' => array( |
| 255 | 255 | 'type' => 'object', |
| 256 | - 'required' => array( 'amount' ), |
|
| 256 | + 'required' => array('amount'), |
|
| 257 | 257 | 'properties' => array( |
| 258 | 258 | 'amount' => array( |
| 259 | - 'description' => __( 'Fee amount.', 'invoicing' ), |
|
| 259 | + 'description' => __('Fee amount.', 'invoicing'), |
|
| 260 | 260 | 'type' => 'string', |
| 261 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 261 | + 'context' => array('view', 'edit', 'embed'), |
|
| 262 | 262 | ), |
| 263 | 263 | 'recurring' => array( |
| 264 | - 'description' => __( 'Whether this is a recurring or one-time tax.', 'invoicing' ), |
|
| 265 | - 'type' => array( 'boolean', 'integer' ), |
|
| 266 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 264 | + 'description' => __('Whether this is a recurring or one-time tax.', 'invoicing'), |
|
| 265 | + 'type' => array('boolean', 'integer'), |
|
| 266 | + 'context' => array('view', 'edit', 'embed'), |
|
| 267 | 267 | ), |
| 268 | 268 | ), |
| 269 | 269 | ), |
| 270 | 270 | ), |
| 271 | 271 | |
| 272 | 272 | 'items' => array( |
| 273 | - 'description' => __( 'Invoice items.', 'invoicing' ), |
|
| 273 | + 'description' => __('Invoice items.', 'invoicing'), |
|
| 274 | 274 | 'type' => 'array', |
| 275 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 275 | + 'context' => array('view', 'edit', 'embed'), |
|
| 276 | 276 | 'items' => array( |
| 277 | 277 | 'type' => 'object', |
| 278 | - 'required' => array( 'item_id' ), |
|
| 278 | + 'required' => array('item_id'), |
|
| 279 | 279 | 'properties' => array( |
| 280 | 280 | 'item_id' => array( |
| 281 | - 'description' => __( 'Item ID.', 'invoicing' ), |
|
| 281 | + 'description' => __('Item ID.', 'invoicing'), |
|
| 282 | 282 | 'type' => 'integer', |
| 283 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 283 | + 'context' => array('view', 'edit', 'embed'), |
|
| 284 | 284 | ), |
| 285 | 285 | 'item_name' => array( |
| 286 | - 'description' => __( 'Item Name.', 'invoicing' ), |
|
| 286 | + 'description' => __('Item Name.', 'invoicing'), |
|
| 287 | 287 | 'type' => 'string', |
| 288 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 288 | + 'context' => array('view', 'edit', 'embed'), |
|
| 289 | 289 | ), |
| 290 | 290 | 'item_description' => array( |
| 291 | - 'description' => __( 'Item Description.', 'invoicing' ), |
|
| 291 | + 'description' => __('Item Description.', 'invoicing'), |
|
| 292 | 292 | 'type' => 'string', |
| 293 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 293 | + 'context' => array('view', 'edit', 'embed'), |
|
| 294 | 294 | ), |
| 295 | 295 | 'item_price' => array( |
| 296 | - 'description' => __( 'Item Price.', 'invoicing' ), |
|
| 296 | + 'description' => __('Item Price.', 'invoicing'), |
|
| 297 | 297 | 'type' => 'number', |
| 298 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 298 | + 'context' => array('view', 'edit', 'embed'), |
|
| 299 | 299 | ), |
| 300 | 300 | 'quantity' => array( |
| 301 | - 'description' => __( 'Item Quantity.', 'invoicing' ), |
|
| 301 | + 'description' => __('Item Quantity.', 'invoicing'), |
|
| 302 | 302 | 'type' => 'integer', |
| 303 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 303 | + 'context' => array('view', 'edit', 'embed'), |
|
| 304 | 304 | ), |
| 305 | 305 | 'subtotal' => array( |
| 306 | - 'description' => __( 'Item Subtotal.', 'invoicing' ), |
|
| 306 | + 'description' => __('Item Subtotal.', 'invoicing'), |
|
| 307 | 307 | 'type' => 'number', |
| 308 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 308 | + 'context' => array('view', 'edit', 'embed'), |
|
| 309 | 309 | 'readonly' => true, |
| 310 | 310 | ), |
| 311 | 311 | 'meta' => array( |
| 312 | - 'description' => __( 'Item Meta.', 'invoicing' ), |
|
| 312 | + 'description' => __('Item Meta.', 'invoicing'), |
|
| 313 | 313 | 'type' => 'object', |
| 314 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 314 | + 'context' => array('view', 'edit', 'embed'), |
|
| 315 | 315 | ), |
| 316 | 316 | ), |
| 317 | 317 | ), |
| 318 | 318 | ), |
| 319 | 319 | |
| 320 | 320 | 'mode' => array( |
| 321 | - 'description' => __( 'The invoice transaction mode.', 'invoicing' ), |
|
| 321 | + 'description' => __('The invoice transaction mode.', 'invoicing'), |
|
| 322 | 322 | 'type' => 'string', |
| 323 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 324 | - 'enum' => array( 'live', 'test' ), |
|
| 323 | + 'context' => array('view', 'edit', 'embed'), |
|
| 324 | + 'enum' => array('live', 'test'), |
|
| 325 | 325 | 'readonly' => true, |
| 326 | 326 | ), |
| 327 | 327 | |
| 328 | 328 | 'discount_code' => array( |
| 329 | - 'description' => __( 'The discount code used on this invoice.', 'invoicing' ), |
|
| 329 | + 'description' => __('The discount code used on this invoice.', 'invoicing'), |
|
| 330 | 330 | 'type' => 'string', |
| 331 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 331 | + 'context' => array('view', 'edit', 'embed'), |
|
| 332 | 332 | ), |
| 333 | 333 | |
| 334 | 334 | 'gateway' => array( |
| 335 | - 'description' => __( 'The gateway used to pay this invoice.', 'invoicing' ), |
|
| 335 | + 'description' => __('The gateway used to pay this invoice.', 'invoicing'), |
|
| 336 | 336 | 'type' => 'string', |
| 337 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 337 | + 'context' => array('view', 'edit', 'embed'), |
|
| 338 | 338 | ), |
| 339 | 339 | |
| 340 | 340 | 'gateway_title' => array( |
| 341 | - 'description' => __( 'The title of the gateway used to pay this invoice.', 'invoicing' ), |
|
| 341 | + 'description' => __('The title of the gateway used to pay this invoice.', 'invoicing'), |
|
| 342 | 342 | 'type' => 'string', |
| 343 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 343 | + 'context' => array('view', 'edit', 'embed'), |
|
| 344 | 344 | 'readonly' => true, |
| 345 | 345 | ), |
| 346 | 346 | |
| 347 | 347 | 'transaction_id' => array( |
| 348 | - 'description' => __( 'The transaction id for this invoice.', 'invoicing' ), |
|
| 348 | + 'description' => __('The transaction id for this invoice.', 'invoicing'), |
|
| 349 | 349 | 'type' => 'string', |
| 350 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 350 | + 'context' => array('view', 'edit', 'embed'), |
|
| 351 | 351 | ), |
| 352 | 352 | |
| 353 | 353 | 'disable_taxes' => array( |
| 354 | - 'description' => __( 'Whether or not taxes should be disabled for this invoice.', 'invoicing' ), |
|
| 354 | + 'description' => __('Whether or not taxes should be disabled for this invoice.', 'invoicing'), |
|
| 355 | 355 | 'type' => 'boolean ', |
| 356 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 356 | + 'context' => array('view', 'edit', 'embed'), |
|
| 357 | 357 | ), |
| 358 | 358 | |
| 359 | 359 | 'is_viewed' => array( |
| 360 | - 'description' => __( 'Whether or not this invoice has been viewed by the user.', 'invoicing' ), |
|
| 360 | + 'description' => __('Whether or not this invoice has been viewed by the user.', 'invoicing'), |
|
| 361 | 361 | 'type' => 'boolean ', |
| 362 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 362 | + 'context' => array('view', 'edit', 'embed'), |
|
| 363 | 363 | 'readonly' => true, |
| 364 | 364 | ), |
| 365 | 365 | |
| 366 | 366 | 'email_cc' => array( |
| 367 | - 'description' => __( 'A comma separated list of other emails that should receive communications for this invoice.', 'invoicing' ), |
|
| 367 | + 'description' => __('A comma separated list of other emails that should receive communications for this invoice.', 'invoicing'), |
|
| 368 | 368 | 'type' => 'string ', |
| 369 | - 'context' => array( 'view', 'edit' ), |
|
| 369 | + 'context' => array('view', 'edit'), |
|
| 370 | 370 | ), |
| 371 | 371 | |
| 372 | 372 | 'subscription_id' => array( |
| 373 | - 'description' => __( 'The ID of the subscription associated with this invoice.', 'invoicing' ), |
|
| 373 | + 'description' => __('The ID of the subscription associated with this invoice.', 'invoicing'), |
|
| 374 | 374 | 'type' => 'string ', |
| 375 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 375 | + 'context' => array('view', 'edit', 'embed'), |
|
| 376 | 376 | 'readonly' => true, |
| 377 | 377 | ), |
| 378 | 378 | |
| 379 | 379 | 'subscription_name' => array( |
| 380 | - 'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ), |
|
| 380 | + 'description' => __('The name of the subscription associated with this invoice.', 'invoicing'), |
|
| 381 | 381 | 'type' => 'string ', |
| 382 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 382 | + 'context' => array('view', 'edit', 'embed'), |
|
| 383 | 383 | 'readonly' => true, |
| 384 | 384 | ), |
| 385 | 385 | |
| 386 | 386 | 'subscription_name' => array( |
| 387 | - 'description' => __( 'The name of the subscription associated with this invoice.', 'invoicing' ), |
|
| 387 | + 'description' => __('The name of the subscription associated with this invoice.', 'invoicing'), |
|
| 388 | 388 | 'type' => 'string ', |
| 389 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 389 | + 'context' => array('view', 'edit', 'embed'), |
|
| 390 | 390 | 'readonly' => true, |
| 391 | 391 | ), |
| 392 | 392 | |
| 393 | 393 | 'is_parent' => array( |
| 394 | - 'description' => __( 'Whether or not this is a parent invoice.', 'invoicing' ), |
|
| 394 | + 'description' => __('Whether or not this is a parent invoice.', 'invoicing'), |
|
| 395 | 395 | 'type' => 'boolean', |
| 396 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 396 | + 'context' => array('view', 'edit', 'embed'), |
|
| 397 | 397 | 'readonly' => true, |
| 398 | 398 | ), |
| 399 | 399 | |
| 400 | 400 | 'is_renewal' => array( |
| 401 | - 'description' => __( 'Whether or not this is a renewal invoice.', 'invoicing' ), |
|
| 401 | + 'description' => __('Whether or not this is a renewal invoice.', 'invoicing'), |
|
| 402 | 402 | 'type' => 'boolean', |
| 403 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 403 | + 'context' => array('view', 'edit', 'embed'), |
|
| 404 | 404 | 'readonly' => true, |
| 405 | 405 | ), |
| 406 | 406 | |
| 407 | 407 | 'is_recurring' => array( |
| 408 | - 'description' => __( 'Whether or not this is a recurring invoice.', 'invoicing' ), |
|
| 408 | + 'description' => __('Whether or not this is a recurring invoice.', 'invoicing'), |
|
| 409 | 409 | 'type' => 'boolean', |
| 410 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 410 | + 'context' => array('view', 'edit', 'embed'), |
|
| 411 | 411 | 'readonly' => true, |
| 412 | 412 | ), |
| 413 | 413 | |
| 414 | 414 | 'is_free' => array( |
| 415 | - 'description' => __( 'Whether or not this invoice is free.', 'invoicing' ), |
|
| 415 | + 'description' => __('Whether or not this invoice is free.', 'invoicing'), |
|
| 416 | 416 | 'type' => 'boolean', |
| 417 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 417 | + 'context' => array('view', 'edit', 'embed'), |
|
| 418 | 418 | 'readonly' => true, |
| 419 | 419 | ), |
| 420 | 420 | |
| 421 | 421 | 'is_paid' => array( |
| 422 | - 'description' => __( 'Whether or not this invoice has been paid.', 'invoicing' ), |
|
| 422 | + 'description' => __('Whether or not this invoice has been paid.', 'invoicing'), |
|
| 423 | 423 | 'type' => 'boolean', |
| 424 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 424 | + 'context' => array('view', 'edit', 'embed'), |
|
| 425 | 425 | 'readonly' => true, |
| 426 | 426 | ), |
| 427 | 427 | |
| 428 | 428 | 'needs_payment' => array( |
| 429 | - 'description' => __( 'Whether or not this invoice needs payment.', 'invoicing' ), |
|
| 429 | + 'description' => __('Whether or not this invoice needs payment.', 'invoicing'), |
|
| 430 | 430 | 'type' => 'boolean', |
| 431 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 431 | + 'context' => array('view', 'edit', 'embed'), |
|
| 432 | 432 | 'readonly' => true, |
| 433 | 433 | ), |
| 434 | 434 | |
| 435 | 435 | 'is_refunded' => array( |
| 436 | - 'description' => __( 'Whether or not this invoice was refunded.', 'invoicing' ), |
|
| 436 | + 'description' => __('Whether or not this invoice was refunded.', 'invoicing'), |
|
| 437 | 437 | 'type' => 'boolean', |
| 438 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 438 | + 'context' => array('view', 'edit', 'embed'), |
|
| 439 | 439 | 'readonly' => true, |
| 440 | 440 | ), |
| 441 | 441 | |
| 442 | 442 | 'is_due' => array( |
| 443 | - 'description' => __( 'Whether or not this invoice is due.', 'invoicing' ), |
|
| 443 | + 'description' => __('Whether or not this invoice is due.', 'invoicing'), |
|
| 444 | 444 | 'type' => 'boolean', |
| 445 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 445 | + 'context' => array('view', 'edit', 'embed'), |
|
| 446 | 446 | 'readonly' => true, |
| 447 | 447 | ), |
| 448 | 448 | |
| 449 | 449 | 'is_held' => array( |
| 450 | - 'description' => __( 'Whether or not this invoice has been held for payment confirmation.', 'invoicing' ), |
|
| 450 | + 'description' => __('Whether or not this invoice has been held for payment confirmation.', 'invoicing'), |
|
| 451 | 451 | 'type' => 'boolean', |
| 452 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 452 | + 'context' => array('view', 'edit', 'embed'), |
|
| 453 | 453 | 'readonly' => true, |
| 454 | 454 | ), |
| 455 | 455 | |
| 456 | 456 | 'is_draft' => array( |
| 457 | - 'description' => __( 'Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing' ), |
|
| 457 | + 'description' => __('Whether or not this invoice is marked as draft (cannot be viewed on the frontend).', 'invoicing'), |
|
| 458 | 458 | 'type' => 'boolean', |
| 459 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 459 | + 'context' => array('view', 'edit', 'embed'), |
|
| 460 | 460 | 'readonly' => true, |
| 461 | 461 | ), |
| 462 | 462 | |
| 463 | 463 | 'path' => array( |
| 464 | - 'description' => __( 'The invoice path/slug/name.', 'invoicing' ), |
|
| 464 | + 'description' => __('The invoice path/slug/name.', 'invoicing'), |
|
| 465 | 465 | 'type' => 'string', |
| 466 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 466 | + 'context' => array('view', 'edit', 'embed'), |
|
| 467 | 467 | 'readonly' => true, |
| 468 | 468 | ), |
| 469 | 469 | |
| 470 | 470 | 'description' => array( |
| 471 | - 'description' => __( 'The invoice description.', 'invoicing' ), |
|
| 471 | + 'description' => __('The invoice description.', 'invoicing'), |
|
| 472 | 472 | 'type' => 'string', |
| 473 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 473 | + 'context' => array('view', 'edit', 'embed'), |
|
| 474 | 474 | ), |
| 475 | 475 | |
| 476 | 476 | 'payment_form' => array( |
| 477 | - 'description' => __( 'The id of the payment form used to pay for this invoice.', 'invoicing' ), |
|
| 477 | + 'description' => __('The id of the payment form used to pay for this invoice.', 'invoicing'), |
|
| 478 | 478 | 'type' => 'integer', |
| 479 | - 'context' => array( 'view', 'edit' ), |
|
| 479 | + 'context' => array('view', 'edit'), |
|
| 480 | 480 | 'readonly' => true, |
| 481 | 481 | ), |
| 482 | 482 | |
| 483 | 483 | 'submission_id' => array( |
| 484 | - 'description' => __( 'A uniques ID of the submission details used to pay for this invoice.', 'invoicing' ), |
|
| 484 | + 'description' => __('A uniques ID of the submission details used to pay for this invoice.', 'invoicing'), |
|
| 485 | 485 | 'type' => 'string', |
| 486 | - 'context' => array( 'view', 'edit' ), |
|
| 486 | + 'context' => array('view', 'edit'), |
|
| 487 | 487 | 'readonly' => true, |
| 488 | 488 | ), |
| 489 | 489 | |
| 490 | 490 | 'customer_id' => array( |
| 491 | - 'description' => __( 'The customer id.', 'invoicing' ), |
|
| 491 | + 'description' => __('The customer id.', 'invoicing'), |
|
| 492 | 492 | 'type' => 'integer', |
| 493 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 493 | + 'context' => array('view', 'edit', 'embed'), |
|
| 494 | 494 | ), |
| 495 | 495 | |
| 496 | 496 | 'customer_ip' => array( |
| 497 | - 'description' => __( "The customer's ip address.", 'invoicing' ), |
|
| 497 | + 'description' => __("The customer's ip address.", 'invoicing'), |
|
| 498 | 498 | 'type' => 'string', |
| 499 | 499 | 'format' => 'ip', |
| 500 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 500 | + 'context' => array('view', 'edit', 'embed'), |
|
| 501 | 501 | ), |
| 502 | 502 | |
| 503 | 503 | 'first_name' => array( |
| 504 | - 'description' => __( "The customer's first name.", 'invoicing' ), |
|
| 504 | + 'description' => __("The customer's first name.", 'invoicing'), |
|
| 505 | 505 | 'type' => 'string', |
| 506 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 506 | + 'context' => array('view', 'edit', 'embed'), |
|
| 507 | 507 | ), |
| 508 | 508 | |
| 509 | 509 | 'last_name' => array( |
| 510 | - 'description' => __( "The customer's last name.", 'invoicing' ), |
|
| 510 | + 'description' => __("The customer's last name.", 'invoicing'), |
|
| 511 | 511 | 'type' => 'string', |
| 512 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 512 | + 'context' => array('view', 'edit', 'embed'), |
|
| 513 | 513 | ), |
| 514 | 514 | |
| 515 | 515 | 'full_name' => array( |
| 516 | - 'description' => __( "The customer's full name.", 'invoicing' ), |
|
| 516 | + 'description' => __("The customer's full name.", 'invoicing'), |
|
| 517 | 517 | 'type' => 'string', |
| 518 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 518 | + 'context' => array('view', 'edit', 'embed'), |
|
| 519 | 519 | 'readonly' => true, |
| 520 | 520 | ), |
| 521 | 521 | |
| 522 | 522 | 'phone_number' => array( |
| 523 | - 'description' => __( "The customer's phone number.", 'invoicing' ), |
|
| 523 | + 'description' => __("The customer's phone number.", 'invoicing'), |
|
| 524 | 524 | 'type' => 'string', |
| 525 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 525 | + 'context' => array('view', 'edit', 'embed'), |
|
| 526 | 526 | ), |
| 527 | 527 | |
| 528 | 528 | 'email_address' => array( |
| 529 | - 'description' => __( "The customer's email address.", 'invoicing' ), |
|
| 529 | + 'description' => __("The customer's email address.", 'invoicing'), |
|
| 530 | 530 | 'type' => 'string', |
| 531 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 531 | + 'context' => array('view', 'edit', 'embed'), |
|
| 532 | 532 | 'readonly' => true, |
| 533 | 533 | ), |
| 534 | 534 | |
| 535 | 535 | 'customer_country' => array( |
| 536 | - 'description' => __( "The customer's country.", 'invoicing' ), |
|
| 536 | + 'description' => __("The customer's country.", 'invoicing'), |
|
| 537 | 537 | 'type' => 'string', |
| 538 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 538 | + 'context' => array('view', 'edit', 'embed'), |
|
| 539 | 539 | 'default' => wpinv_get_default_country(), |
| 540 | 540 | ), |
| 541 | 541 | |
| 542 | 542 | 'customer_state' => array( |
| 543 | - 'description' => __( "The customer's state.", 'invoicing' ), |
|
| 543 | + 'description' => __("The customer's state.", 'invoicing'), |
|
| 544 | 544 | 'type' => 'string', |
| 545 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 545 | + 'context' => array('view', 'edit', 'embed'), |
|
| 546 | 546 | ), |
| 547 | 547 | |
| 548 | 548 | 'customer_city' => array( |
| 549 | - 'description' => __( "The customer's city.", 'invoicing' ), |
|
| 549 | + 'description' => __("The customer's city.", 'invoicing'), |
|
| 550 | 550 | 'type' => 'string', |
| 551 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 551 | + 'context' => array('view', 'edit', 'embed'), |
|
| 552 | 552 | ), |
| 553 | 553 | |
| 554 | 554 | 'customer_zip' => array( |
| 555 | - 'description' => __( "The customer's zip/postal code.", 'invoicing' ), |
|
| 555 | + 'description' => __("The customer's zip/postal code.", 'invoicing'), |
|
| 556 | 556 | 'type' => 'string', |
| 557 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 557 | + 'context' => array('view', 'edit', 'embed'), |
|
| 558 | 558 | ), |
| 559 | 559 | |
| 560 | 560 | 'customer_company' => array( |
| 561 | - 'description' => __( "The customer's company name.", 'invoicing' ), |
|
| 561 | + 'description' => __("The customer's company name.", 'invoicing'), |
|
| 562 | 562 | 'type' => 'string', |
| 563 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 563 | + 'context' => array('view', 'edit', 'embed'), |
|
| 564 | 564 | ), |
| 565 | 565 | |
| 566 | 566 | 'vat_number' => array( |
| 567 | - 'description' => __( "The customer's VAT number.", 'invoicing' ), |
|
| 567 | + 'description' => __("The customer's VAT number.", 'invoicing'), |
|
| 568 | 568 | 'type' => 'string', |
| 569 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 569 | + 'context' => array('view', 'edit', 'embed'), |
|
| 570 | 570 | ), |
| 571 | 571 | |
| 572 | 572 | 'vat_rate' => array( |
| 573 | - 'description' => __( "The customer's VAT rate.", 'invoicing' ), |
|
| 573 | + 'description' => __("The customer's VAT rate.", 'invoicing'), |
|
| 574 | 574 | 'type' => 'number', |
| 575 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 575 | + 'context' => array('view', 'edit', 'embed'), |
|
| 576 | 576 | 'readonly' => true, |
| 577 | 577 | ), |
| 578 | 578 | |
| 579 | 579 | 'customer_address' => array( |
| 580 | - 'description' => __( "The customer's address.", 'invoicing' ), |
|
| 580 | + 'description' => __("The customer's address.", 'invoicing'), |
|
| 581 | 581 | 'type' => 'string', |
| 582 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 582 | + 'context' => array('view', 'edit', 'embed'), |
|
| 583 | 583 | ), |
| 584 | 584 | |
| 585 | 585 | 'address_confirmed' => array( |
| 586 | - 'description' => __( "Whether or not the customer's address is confirmed.", 'invoicing' ), |
|
| 586 | + 'description' => __("Whether or not the customer's address is confirmed.", 'invoicing'), |
|
| 587 | 587 | 'type' => 'boolean', |
| 588 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 588 | + 'context' => array('view', 'edit', 'embed'), |
|
| 589 | 589 | ), |
| 590 | 590 | |
| 591 | 591 | 'meta_data' => array( |
| 592 | - 'description' => __( 'Invoice meta data.', 'invoicing' ), |
|
| 592 | + 'description' => __('Invoice meta data.', 'invoicing'), |
|
| 593 | 593 | 'type' => 'array', |
| 594 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 594 | + 'context' => array('view', 'edit', 'embed'), |
|
| 595 | 595 | 'items' => array( |
| 596 | 596 | 'type' => 'object', |
| 597 | 597 | 'properties' => array( |
| 598 | 598 | 'id' => array( |
| 599 | - 'description' => __( 'Meta ID.', 'invoicing' ), |
|
| 599 | + 'description' => __('Meta ID.', 'invoicing'), |
|
| 600 | 600 | 'type' => 'string', |
| 601 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 601 | + 'context' => array('view', 'edit', 'embed'), |
|
| 602 | 602 | ), |
| 603 | 603 | 'key' => array( |
| 604 | - 'description' => __( 'Meta key.', 'invoicing' ), |
|
| 604 | + 'description' => __('Meta key.', 'invoicing'), |
|
| 605 | 605 | 'type' => 'string', |
| 606 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 606 | + 'context' => array('view', 'edit', 'embed'), |
|
| 607 | 607 | ), |
| 608 | 608 | 'value' => array( |
| 609 | - 'description' => __( 'Meta Value.', 'invoicing' ), |
|
| 610 | - 'type' => array( 'string', 'array', 'object', 'integer', 'null' ), |
|
| 611 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 609 | + 'description' => __('Meta Value.', 'invoicing'), |
|
| 610 | + 'type' => array('string', 'array', 'object', 'integer', 'null'), |
|
| 611 | + 'context' => array('view', 'edit', 'embed'), |
|
| 612 | 612 | ), |
| 613 | 613 | ), |
| 614 | 614 | ), |
| 615 | 615 | ), |
| 616 | 616 | |
| 617 | 617 | 'view_url' => array( |
| 618 | - 'description' => __( 'URL to the invoice.', 'invoicing' ), |
|
| 618 | + 'description' => __('URL to the invoice.', 'invoicing'), |
|
| 619 | 619 | 'type' => 'string', |
| 620 | 620 | 'format' => 'uri', |
| 621 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 621 | + 'context' => array('view', 'edit', 'embed'), |
|
| 622 | 622 | 'readonly' => true, |
| 623 | 623 | ), |
| 624 | 624 | |
| 625 | 625 | 'checkout_payment_url' => array( |
| 626 | - 'description' => __( 'URL to the invoice checkout page.', 'invoicing' ), |
|
| 626 | + 'description' => __('URL to the invoice checkout page.', 'invoicing'), |
|
| 627 | 627 | 'type' => 'string', |
| 628 | 628 | 'format' => 'uri', |
| 629 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 629 | + 'context' => array('view', 'edit', 'embed'), |
|
| 630 | 630 | 'readonly' => true, |
| 631 | 631 | ), |
| 632 | 632 | |
| 633 | 633 | 'receipt_url' => array( |
| 634 | - 'description' => __( 'URL to the invoice receipt page.', 'invoicing' ), |
|
| 634 | + 'description' => __('URL to the invoice receipt page.', 'invoicing'), |
|
| 635 | 635 | 'type' => 'string', |
| 636 | 636 | 'format' => 'uri', |
| 637 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 637 | + 'context' => array('view', 'edit', 'embed'), |
|
| 638 | 638 | 'readonly' => true, |
| 639 | 639 | ), |
| 640 | 640 | |
@@ -11,166 +11,166 @@ |
||
| 11 | 11 | defined( 'ABSPATH' ) || exit; |
| 12 | 12 | |
| 13 | 13 | return array( |
| 14 | - 'AED' => 'د.إ', |
|
| 15 | - 'AFN' => '؋', |
|
| 16 | - 'ALL' => 'L', |
|
| 17 | - 'AMD' => 'AMD', |
|
| 18 | - 'ANG' => 'ƒ', |
|
| 19 | - 'AOA' => 'Kz', |
|
| 20 | - 'ARS' => '$', |
|
| 21 | - 'AUD' => '$', |
|
| 22 | - 'AWG' => 'ƒ', |
|
| 23 | - 'AZN' => 'AZN', |
|
| 24 | - 'BAM' => 'KM', |
|
| 25 | - 'BBD' => '$', |
|
| 26 | - 'BDT' => '৳', |
|
| 27 | - 'BGN' => 'лв.', |
|
| 28 | - 'BHD' => '.د.ب', |
|
| 29 | - 'BIF' => 'Fr', |
|
| 30 | - 'BMD' => '$', |
|
| 31 | - 'BND' => '$', |
|
| 32 | - 'BOB' => 'Bs.', |
|
| 33 | - 'BRL' => 'R$', |
|
| 34 | - 'BSD' => '$', |
|
| 35 | - 'BTC' => '฿', |
|
| 36 | - 'BTN' => 'Nu.', |
|
| 37 | - 'BWP' => 'P', |
|
| 38 | - 'BYN' => 'Br', |
|
| 39 | - 'BZD' => '$', |
|
| 40 | - 'CAD' => '$', |
|
| 41 | - 'CDF' => 'Fr', |
|
| 42 | - 'CHF' => 'CHF', |
|
| 43 | - 'CLP' => '$', |
|
| 44 | - 'CNY' => '¥', |
|
| 45 | - 'COP' => '$', |
|
| 46 | - 'CRC' => '₡', |
|
| 47 | - 'CUC' => '$', |
|
| 48 | - 'CUP' => '$', |
|
| 49 | - 'CVE' => '$', |
|
| 50 | - 'CZK' => 'Kč', |
|
| 51 | - 'DJF' => 'Fr', |
|
| 52 | - 'DKK' => 'DKK', |
|
| 53 | - 'DOP' => 'RD$', |
|
| 54 | - 'DZD' => 'د.ج', |
|
| 55 | - 'EGP' => 'EGP', |
|
| 56 | - 'ERN' => 'Nfk', |
|
| 57 | - 'ETB' => 'Br', |
|
| 58 | - 'EUR' => '€', |
|
| 59 | - 'FJD' => '$', |
|
| 60 | - 'FKP' => '£', |
|
| 61 | - 'GBP' => '£', |
|
| 62 | - 'GEL' => 'ლ', |
|
| 63 | - 'GGP' => '£', |
|
| 64 | - 'GHS' => '₵', |
|
| 65 | - 'GIP' => '£', |
|
| 66 | - 'GMD' => 'D', |
|
| 67 | - 'GNF' => 'Fr', |
|
| 68 | - 'GTQ' => 'Q', |
|
| 69 | - 'GYD' => '$', |
|
| 70 | - 'HKD' => '$', |
|
| 71 | - 'HNL' => 'L', |
|
| 72 | - 'HRK' => 'Kn', |
|
| 73 | - 'HTG' => 'G', |
|
| 74 | - 'HUF' => 'Ft', |
|
| 75 | - 'IDR' => 'Rp', |
|
| 76 | - 'ILS' => '₪', |
|
| 77 | - 'IMP' => '£', |
|
| 78 | - 'INR' => '₹', |
|
| 79 | - 'IQD' => 'ع.د', |
|
| 80 | - 'IRR' => '﷼', |
|
| 81 | - 'IRT' => 'تومان', |
|
| 82 | - 'ISK' => 'kr.', |
|
| 83 | - 'JEP' => '£', |
|
| 84 | - 'JMD' => '$', |
|
| 85 | - 'JOD' => 'د.ا', |
|
| 86 | - 'JPY' => '¥', |
|
| 87 | - 'KES' => 'KSh', |
|
| 88 | - 'KGS' => 'сом', |
|
| 89 | - 'KHR' => '៛', |
|
| 90 | - 'KMF' => 'Fr', |
|
| 91 | - 'KPW' => '₩', |
|
| 92 | - 'KRW' => '₩', |
|
| 93 | - 'KWD' => 'د.ك', |
|
| 94 | - 'KYD' => '$', |
|
| 95 | - 'KZT' => 'KZT', |
|
| 96 | - 'LAK' => '₭', |
|
| 97 | - 'LBP' => 'ل.ل', |
|
| 98 | - 'LKR' => 'රු', |
|
| 99 | - 'LRD' => '$', |
|
| 100 | - 'LSL' => 'L', |
|
| 101 | - 'LYD' => 'ل.د', |
|
| 102 | - 'MAD' => 'د.م.', |
|
| 103 | - 'MDL' => 'MDL', |
|
| 104 | - 'MGA' => 'Ar', |
|
| 105 | - 'MKD' => 'ден', |
|
| 106 | - 'MMK' => 'Ks', |
|
| 107 | - 'MNT' => '₮', |
|
| 108 | - 'MOP' => 'P', |
|
| 109 | - 'MRO' => 'UM', |
|
| 110 | - 'MUR' => '₨', |
|
| 111 | - 'MVR' => '.ރ', |
|
| 112 | - 'MWK' => 'MK', |
|
| 113 | - 'MXN' => '$', |
|
| 114 | - 'MYR' => 'RM', |
|
| 115 | - 'MZN' => 'MT', |
|
| 116 | - 'NAD' => '$', |
|
| 117 | - 'NGN' => '₦', |
|
| 118 | - 'NIO' => 'C$', |
|
| 119 | - 'NOK' => 'kr', |
|
| 120 | - 'NPR' => '₨', |
|
| 121 | - 'NZD' => '$', |
|
| 122 | - 'OMR' => 'ر.ع.', |
|
| 123 | - 'PAB' => 'B/.', |
|
| 124 | - 'PEN' => 'S/.', |
|
| 125 | - 'PGK' => 'K', |
|
| 126 | - 'PHP' => '₱', |
|
| 127 | - 'PKR' => '₨', |
|
| 128 | - 'PLN' => 'zł', |
|
| 129 | - 'PRB' => 'р.', |
|
| 130 | - 'PYG' => '₲', |
|
| 131 | - 'QAR' => 'ر.ق', |
|
| 132 | - 'RMB' => '¥', |
|
| 133 | - 'RON' => 'lei', |
|
| 134 | - 'RSD' => 'дин.', |
|
| 135 | - 'RUB' => '₽', |
|
| 136 | - 'RWF' => 'Fr', |
|
| 137 | - 'SAR' => 'ر.س', |
|
| 138 | - 'SBD' => '$', |
|
| 139 | - 'SCR' => '₨', |
|
| 140 | - 'SDG' => 'ج.س.', |
|
| 141 | - 'SEK' => 'kr', |
|
| 142 | - 'SGD' => '$', |
|
| 143 | - 'SHP' => '£', |
|
| 144 | - 'SLL' => 'Le', |
|
| 145 | - 'SOS' => 'Sh', |
|
| 146 | - 'SRD' => '$', |
|
| 147 | - 'SSP' => '£', |
|
| 148 | - 'STD' => 'Db', |
|
| 149 | - 'SYP' => 'ل.س', |
|
| 150 | - 'SZL' => 'L', |
|
| 151 | - 'THB' => '฿', |
|
| 152 | - 'TJS' => 'ЅМ', |
|
| 153 | - 'TMT' => 'm', |
|
| 154 | - 'TND' => 'د.ت', |
|
| 155 | - 'TOP' => 'T$', |
|
| 156 | - 'TRY' => '₺', |
|
| 157 | - 'TTD' => '$', |
|
| 158 | - 'TWD' => 'NT$', |
|
| 159 | - 'TZS' => 'Sh', |
|
| 160 | - 'UAH' => '₴', |
|
| 161 | - 'UGX' => 'UGX', |
|
| 162 | - 'USD' => '$', |
|
| 163 | - 'UYU' => '$', |
|
| 164 | - 'UZS' => 'UZS', |
|
| 165 | - 'VEF' => 'Bs.', |
|
| 166 | - 'VND' => '₫', |
|
| 167 | - 'VUV' => 'Vt', |
|
| 168 | - 'WST' => 'T', |
|
| 169 | - 'XAF' => 'Fr', |
|
| 170 | - 'XCD' => '$', |
|
| 171 | - 'XOF' => 'Fr', |
|
| 172 | - 'XPF' => 'Fr', |
|
| 173 | - 'YER' => '﷼', |
|
| 174 | - 'ZAR' => 'R', |
|
| 175 | - 'ZMW' => 'ZK', |
|
| 14 | + 'AED' => 'د.إ', |
|
| 15 | + 'AFN' => '؋', |
|
| 16 | + 'ALL' => 'L', |
|
| 17 | + 'AMD' => 'AMD', |
|
| 18 | + 'ANG' => 'ƒ', |
|
| 19 | + 'AOA' => 'Kz', |
|
| 20 | + 'ARS' => '$', |
|
| 21 | + 'AUD' => '$', |
|
| 22 | + 'AWG' => 'ƒ', |
|
| 23 | + 'AZN' => 'AZN', |
|
| 24 | + 'BAM' => 'KM', |
|
| 25 | + 'BBD' => '$', |
|
| 26 | + 'BDT' => '৳', |
|
| 27 | + 'BGN' => 'лв.', |
|
| 28 | + 'BHD' => '.د.ب', |
|
| 29 | + 'BIF' => 'Fr', |
|
| 30 | + 'BMD' => '$', |
|
| 31 | + 'BND' => '$', |
|
| 32 | + 'BOB' => 'Bs.', |
|
| 33 | + 'BRL' => 'R$', |
|
| 34 | + 'BSD' => '$', |
|
| 35 | + 'BTC' => '฿', |
|
| 36 | + 'BTN' => 'Nu.', |
|
| 37 | + 'BWP' => 'P', |
|
| 38 | + 'BYN' => 'Br', |
|
| 39 | + 'BZD' => '$', |
|
| 40 | + 'CAD' => '$', |
|
| 41 | + 'CDF' => 'Fr', |
|
| 42 | + 'CHF' => 'CHF', |
|
| 43 | + 'CLP' => '$', |
|
| 44 | + 'CNY' => '¥', |
|
| 45 | + 'COP' => '$', |
|
| 46 | + 'CRC' => '₡', |
|
| 47 | + 'CUC' => '$', |
|
| 48 | + 'CUP' => '$', |
|
| 49 | + 'CVE' => '$', |
|
| 50 | + 'CZK' => 'Kč', |
|
| 51 | + 'DJF' => 'Fr', |
|
| 52 | + 'DKK' => 'DKK', |
|
| 53 | + 'DOP' => 'RD$', |
|
| 54 | + 'DZD' => 'د.ج', |
|
| 55 | + 'EGP' => 'EGP', |
|
| 56 | + 'ERN' => 'Nfk', |
|
| 57 | + 'ETB' => 'Br', |
|
| 58 | + 'EUR' => '€', |
|
| 59 | + 'FJD' => '$', |
|
| 60 | + 'FKP' => '£', |
|
| 61 | + 'GBP' => '£', |
|
| 62 | + 'GEL' => 'ლ', |
|
| 63 | + 'GGP' => '£', |
|
| 64 | + 'GHS' => '₵', |
|
| 65 | + 'GIP' => '£', |
|
| 66 | + 'GMD' => 'D', |
|
| 67 | + 'GNF' => 'Fr', |
|
| 68 | + 'GTQ' => 'Q', |
|
| 69 | + 'GYD' => '$', |
|
| 70 | + 'HKD' => '$', |
|
| 71 | + 'HNL' => 'L', |
|
| 72 | + 'HRK' => 'Kn', |
|
| 73 | + 'HTG' => 'G', |
|
| 74 | + 'HUF' => 'Ft', |
|
| 75 | + 'IDR' => 'Rp', |
|
| 76 | + 'ILS' => '₪', |
|
| 77 | + 'IMP' => '£', |
|
| 78 | + 'INR' => '₹', |
|
| 79 | + 'IQD' => 'ع.د', |
|
| 80 | + 'IRR' => '﷼', |
|
| 81 | + 'IRT' => 'تومان', |
|
| 82 | + 'ISK' => 'kr.', |
|
| 83 | + 'JEP' => '£', |
|
| 84 | + 'JMD' => '$', |
|
| 85 | + 'JOD' => 'د.ا', |
|
| 86 | + 'JPY' => '¥', |
|
| 87 | + 'KES' => 'KSh', |
|
| 88 | + 'KGS' => 'сом', |
|
| 89 | + 'KHR' => '៛', |
|
| 90 | + 'KMF' => 'Fr', |
|
| 91 | + 'KPW' => '₩', |
|
| 92 | + 'KRW' => '₩', |
|
| 93 | + 'KWD' => 'د.ك', |
|
| 94 | + 'KYD' => '$', |
|
| 95 | + 'KZT' => 'KZT', |
|
| 96 | + 'LAK' => '₭', |
|
| 97 | + 'LBP' => 'ل.ل', |
|
| 98 | + 'LKR' => 'රු', |
|
| 99 | + 'LRD' => '$', |
|
| 100 | + 'LSL' => 'L', |
|
| 101 | + 'LYD' => 'ل.د', |
|
| 102 | + 'MAD' => 'د.م.', |
|
| 103 | + 'MDL' => 'MDL', |
|
| 104 | + 'MGA' => 'Ar', |
|
| 105 | + 'MKD' => 'ден', |
|
| 106 | + 'MMK' => 'Ks', |
|
| 107 | + 'MNT' => '₮', |
|
| 108 | + 'MOP' => 'P', |
|
| 109 | + 'MRO' => 'UM', |
|
| 110 | + 'MUR' => '₨', |
|
| 111 | + 'MVR' => '.ރ', |
|
| 112 | + 'MWK' => 'MK', |
|
| 113 | + 'MXN' => '$', |
|
| 114 | + 'MYR' => 'RM', |
|
| 115 | + 'MZN' => 'MT', |
|
| 116 | + 'NAD' => '$', |
|
| 117 | + 'NGN' => '₦', |
|
| 118 | + 'NIO' => 'C$', |
|
| 119 | + 'NOK' => 'kr', |
|
| 120 | + 'NPR' => '₨', |
|
| 121 | + 'NZD' => '$', |
|
| 122 | + 'OMR' => 'ر.ع.', |
|
| 123 | + 'PAB' => 'B/.', |
|
| 124 | + 'PEN' => 'S/.', |
|
| 125 | + 'PGK' => 'K', |
|
| 126 | + 'PHP' => '₱', |
|
| 127 | + 'PKR' => '₨', |
|
| 128 | + 'PLN' => 'zł', |
|
| 129 | + 'PRB' => 'р.', |
|
| 130 | + 'PYG' => '₲', |
|
| 131 | + 'QAR' => 'ر.ق', |
|
| 132 | + 'RMB' => '¥', |
|
| 133 | + 'RON' => 'lei', |
|
| 134 | + 'RSD' => 'дин.', |
|
| 135 | + 'RUB' => '₽', |
|
| 136 | + 'RWF' => 'Fr', |
|
| 137 | + 'SAR' => 'ر.س', |
|
| 138 | + 'SBD' => '$', |
|
| 139 | + 'SCR' => '₨', |
|
| 140 | + 'SDG' => 'ج.س.', |
|
| 141 | + 'SEK' => 'kr', |
|
| 142 | + 'SGD' => '$', |
|
| 143 | + 'SHP' => '£', |
|
| 144 | + 'SLL' => 'Le', |
|
| 145 | + 'SOS' => 'Sh', |
|
| 146 | + 'SRD' => '$', |
|
| 147 | + 'SSP' => '£', |
|
| 148 | + 'STD' => 'Db', |
|
| 149 | + 'SYP' => 'ل.س', |
|
| 150 | + 'SZL' => 'L', |
|
| 151 | + 'THB' => '฿', |
|
| 152 | + 'TJS' => 'ЅМ', |
|
| 153 | + 'TMT' => 'm', |
|
| 154 | + 'TND' => 'د.ت', |
|
| 155 | + 'TOP' => 'T$', |
|
| 156 | + 'TRY' => '₺', |
|
| 157 | + 'TTD' => '$', |
|
| 158 | + 'TWD' => 'NT$', |
|
| 159 | + 'TZS' => 'Sh', |
|
| 160 | + 'UAH' => '₴', |
|
| 161 | + 'UGX' => 'UGX', |
|
| 162 | + 'USD' => '$', |
|
| 163 | + 'UYU' => '$', |
|
| 164 | + 'UZS' => 'UZS', |
|
| 165 | + 'VEF' => 'Bs.', |
|
| 166 | + 'VND' => '₫', |
|
| 167 | + 'VUV' => 'Vt', |
|
| 168 | + 'WST' => 'T', |
|
| 169 | + 'XAF' => 'Fr', |
|
| 170 | + 'XCD' => '$', |
|
| 171 | + 'XOF' => 'Fr', |
|
| 172 | + 'XPF' => 'Fr', |
|
| 173 | + 'YER' => '﷼', |
|
| 174 | + 'ZAR' => 'R', |
|
| 175 | + 'ZMW' => 'ZK', |
|
| 176 | 176 | ); |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | return array( |
| 14 | 14 | 'AED' => 'د.إ', |