@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,19 +13,19 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct() { |
| 15 | 15 | |
| 16 | - foreach( $this->get_elements() as $element ) { |
|
| 16 | + foreach ($this->get_elements() as $element) { |
|
| 17 | 17 | $element = $element['type']; |
| 18 | 18 | |
| 19 | - if ( method_exists( $this, "render_{$element}_template" ) ) { |
|
| 20 | - add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 ); |
|
| 19 | + if (method_exists($this, "render_{$element}_template")) { |
|
| 20 | + add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if ( method_exists( $this, "edit_{$element}_template" ) ) { |
|
| 24 | - add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 ); |
|
| 23 | + if (method_exists($this, "edit_{$element}_template")) { |
|
| 24 | + add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( method_exists( $this, "frontend_render_{$element}_template" ) ) { |
|
| 28 | - add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 ); |
|
| 27 | + if (method_exists($this, "frontend_render_{$element}_template")) { |
|
| 28 | + add_action("wpinv_frontend_render_payment_form_$element", array($this, "frontend_render_{$element}_template"), 10, 3); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function get_elements() { |
| 39 | 39 | |
| 40 | - if ( ! empty( $this->elements ) ) { |
|
| 40 | + if (!empty($this->elements)) { |
|
| 41 | 41 | return $this->elements; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,28 +45,28 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | array( |
| 47 | 47 | 'type' => 'heading', |
| 48 | - 'name' => __( 'Heading', 'invoicing' ), |
|
| 48 | + 'name' => __('Heading', 'invoicing'), |
|
| 49 | 49 | 'defaults' => array( |
| 50 | 50 | 'level' => 'h2', |
| 51 | - 'text' => __( 'Heading', 'invoicing' ), |
|
| 51 | + 'text' => __('Heading', 'invoicing'), |
|
| 52 | 52 | ) |
| 53 | 53 | ), |
| 54 | 54 | |
| 55 | 55 | array( |
| 56 | 56 | 'type' => 'paragraph', |
| 57 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
| 57 | + 'name' => __('Paragraph', 'invoicing'), |
|
| 58 | 58 | 'defaults' => array( |
| 59 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
| 59 | + 'text' => __('Paragraph text', 'invoicing'), |
|
| 60 | 60 | ) |
| 61 | 61 | ), |
| 62 | 62 | |
| 63 | 63 | array( |
| 64 | 64 | 'type' => 'alert', |
| 65 | - 'name' => __( 'Alert', 'invoicing' ), |
|
| 65 | + 'name' => __('Alert', 'invoicing'), |
|
| 66 | 66 | 'defaults' => array( |
| 67 | 67 | 'value' => '', |
| 68 | 68 | 'class' => 'alert-warning', |
| 69 | - 'text' => __( 'Alert', 'invoicing' ), |
|
| 69 | + 'text' => __('Alert', 'invoicing'), |
|
| 70 | 70 | 'dismissible' => false, |
| 71 | 71 | ) |
| 72 | 72 | ), |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | array( |
| 84 | 84 | 'type' => 'text', |
| 85 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
| 85 | + 'name' => __('Text Input', 'invoicing'), |
|
| 86 | 86 | 'defaults' => array( |
| 87 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
| 87 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
| 88 | 88 | 'value' => '', |
| 89 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
| 89 | + 'label' => __('Field Label', 'invoicing'), |
|
| 90 | 90 | 'description' => '', |
| 91 | 91 | 'required' => false, |
| 92 | 92 | ) |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | array( |
| 96 | 96 | 'type' => 'textarea', |
| 97 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
| 97 | + 'name' => __('Textarea', 'invoicing'), |
|
| 98 | 98 | 'defaults' => array( |
| 99 | - 'placeholder' => __( 'Enter your text hear', 'invoicing' ), |
|
| 99 | + 'placeholder' => __('Enter your text hear', 'invoicing'), |
|
| 100 | 100 | 'value' => '', |
| 101 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
| 101 | + 'label' => __('Textarea Label', 'invoicing'), |
|
| 102 | 102 | 'description' => '', |
| 103 | 103 | 'required' => false, |
| 104 | 104 | ) |
@@ -106,27 +106,27 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | array( |
| 108 | 108 | 'type' => 'select', |
| 109 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
| 109 | + 'name' => __('Dropdown', 'invoicing'), |
|
| 110 | 110 | 'defaults' => array( |
| 111 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
| 111 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
| 112 | 112 | 'value' => '', |
| 113 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
| 113 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
| 114 | 114 | 'description' => '', |
| 115 | 115 | 'required' => false, |
| 116 | 116 | 'options' => array( |
| 117 | - esc_attr__( 'Option One', 'invoicing' ), |
|
| 118 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
| 119 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
| 117 | + esc_attr__('Option One', 'invoicing'), |
|
| 118 | + esc_attr__('Option Two', 'invoicing'), |
|
| 119 | + esc_attr__('Option Three', 'invoicing') |
|
| 120 | 120 | ), |
| 121 | 121 | ) |
| 122 | 122 | ), |
| 123 | 123 | |
| 124 | 124 | array( |
| 125 | 125 | 'type' => 'checkbox', |
| 126 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
| 126 | + 'name' => __('Checkbox', 'invoicing'), |
|
| 127 | 127 | 'defaults' => array( |
| 128 | 128 | 'value' => '', |
| 129 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
| 129 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
| 130 | 130 | 'description' => '', |
| 131 | 131 | 'required' => false, |
| 132 | 132 | ) |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | array( |
| 136 | 136 | 'type' => 'radio', |
| 137 | - 'name' => __( 'Multiple Choice', 'invoicing' ), |
|
| 137 | + 'name' => __('Multiple Choice', 'invoicing'), |
|
| 138 | 138 | 'defaults' => array( |
| 139 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
| 139 | + 'label' => __('Select one choice', 'invoicing'), |
|
| 140 | 140 | 'options' => array( |
| 141 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
| 142 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
| 143 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
| 141 | + esc_attr__('Choice One', 'invoicing'), |
|
| 142 | + esc_attr__('Choice Two', 'invoicing'), |
|
| 143 | + esc_attr__('Choice Three', 'invoicing') |
|
| 144 | 144 | ), |
| 145 | 145 | ) |
| 146 | 146 | ), |
| 147 | 147 | |
| 148 | 148 | array( |
| 149 | 149 | 'type' => 'date', |
| 150 | - 'name' => __( 'Date', 'invoicing' ), |
|
| 150 | + 'name' => __('Date', 'invoicing'), |
|
| 151 | 151 | 'defaults' => array( |
| 152 | 152 | 'placeholder' => '', |
| 153 | 153 | 'value' => '', |
| 154 | - 'label' => __( 'Date', 'invoicing' ), |
|
| 154 | + 'label' => __('Date', 'invoicing'), |
|
| 155 | 155 | 'description' => '', |
| 156 | 156 | 'required' => false, |
| 157 | 157 | ) |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | array( |
| 161 | 161 | 'type' => 'time', |
| 162 | - 'name' => __( 'Time', 'invoicing' ), |
|
| 162 | + 'name' => __('Time', 'invoicing'), |
|
| 163 | 163 | 'defaults' => array( |
| 164 | 164 | 'placeholder' => '', |
| 165 | 165 | 'value' => '', |
| 166 | - 'label' => __( 'Time', 'invoicing' ), |
|
| 166 | + 'label' => __('Time', 'invoicing'), |
|
| 167 | 167 | 'description' => '', |
| 168 | 168 | 'required' => false, |
| 169 | 169 | ) |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | array( |
| 173 | 173 | 'type' => 'number', |
| 174 | - 'name' => __( 'Number', 'invoicing' ), |
|
| 174 | + 'name' => __('Number', 'invoicing'), |
|
| 175 | 175 | 'defaults' => array( |
| 176 | 176 | 'placeholder' => '', |
| 177 | 177 | 'value' => '', |
| 178 | - 'label' => __( 'Number', 'invoicing' ), |
|
| 178 | + 'label' => __('Number', 'invoicing'), |
|
| 179 | 179 | 'description' => '', |
| 180 | 180 | 'required' => false, |
| 181 | 181 | ) |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | array( |
| 185 | 185 | 'type' => 'website', |
| 186 | - 'name' => __( 'Website', 'invoicing' ), |
|
| 186 | + 'name' => __('Website', 'invoicing'), |
|
| 187 | 187 | 'defaults' => array( |
| 188 | 188 | 'placeholder' => 'http://example.com', |
| 189 | 189 | 'value' => '', |
| 190 | - 'label' => __( 'Website', 'invoicing' ), |
|
| 190 | + 'label' => __('Website', 'invoicing'), |
|
| 191 | 191 | 'description' => '', |
| 192 | 192 | 'required' => false, |
| 193 | 193 | ) |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | array( |
| 197 | 197 | 'type' => 'email', |
| 198 | - 'name' => __( 'Email', 'invoicing' ), |
|
| 198 | + 'name' => __('Email', 'invoicing'), |
|
| 199 | 199 | 'defaults' => array( |
| 200 | 200 | 'placeholder' => '[email protected]', |
| 201 | 201 | 'value' => '', |
| 202 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
| 202 | + 'label' => __('Email Address', 'invoicing'), |
|
| 203 | 203 | 'description' => '', |
| 204 | 204 | 'required' => false, |
| 205 | 205 | ) |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | array( |
| 209 | 209 | 'type' => 'address', |
| 210 | - 'name' => __( 'Address', 'invoicing' ), |
|
| 210 | + 'name' => __('Address', 'invoicing'), |
|
| 211 | 211 | 'defaults' => array( |
| 212 | 212 | |
| 213 | 213 | 'fields' => array( |
| 214 | 214 | array( |
| 215 | 215 | 'placeholder' => 'Jon', |
| 216 | 216 | 'value' => '', |
| 217 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 217 | + 'label' => __('First Name', 'invoicing'), |
|
| 218 | 218 | 'description' => '', |
| 219 | 219 | 'required' => false, |
| 220 | 220 | 'visible' => true, |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | array( |
| 225 | 225 | 'placeholder' => 'Snow', |
| 226 | 226 | 'value' => '', |
| 227 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 227 | + 'label' => __('Last Name', 'invoicing'), |
|
| 228 | 228 | 'description' => '', |
| 229 | 229 | 'required' => false, |
| 230 | 230 | 'visible' => true, |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | array( |
| 235 | 235 | 'placeholder' => '', |
| 236 | 236 | 'value' => '', |
| 237 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 237 | + 'label' => __('Address', 'invoicing'), |
|
| 238 | 238 | 'description' => '', |
| 239 | 239 | 'required' => false, |
| 240 | 240 | 'visible' => true, |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | array( |
| 245 | 245 | 'placeholder' => '', |
| 246 | 246 | 'value' => '', |
| 247 | - 'label' => __( 'City', 'invoicing' ), |
|
| 247 | + 'label' => __('City', 'invoicing'), |
|
| 248 | 248 | 'description' => '', |
| 249 | 249 | 'required' => false, |
| 250 | 250 | 'visible' => true, |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | array( |
| 255 | 255 | 'placeholder' => '', |
| 256 | 256 | 'value' => '', |
| 257 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 257 | + 'label' => __('Country', 'invoicing'), |
|
| 258 | 258 | 'description' => '', |
| 259 | 259 | 'required' => false, |
| 260 | 260 | 'visible' => true, |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | ), |
| 263 | 263 | |
| 264 | 264 | array( |
| 265 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 265 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 266 | 266 | 'value' => '', |
| 267 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
| 267 | + 'label' => __('State / Province', 'invoicing'), |
|
| 268 | 268 | 'description' => '', |
| 269 | 269 | 'required' => false, |
| 270 | 270 | 'visible' => true, |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | array( |
| 275 | 275 | 'placeholder' => '', |
| 276 | 276 | 'value' => '', |
| 277 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 277 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
| 278 | 278 | 'description' => '', |
| 279 | 279 | 'required' => false, |
| 280 | 280 | 'visible' => true, |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | array( |
| 285 | 285 | 'placeholder' => '', |
| 286 | 286 | 'value' => '', |
| 287 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 287 | + 'label' => __('Phone', 'invoicing'), |
|
| 288 | 288 | 'description' => '', |
| 289 | 289 | 'required' => false, |
| 290 | 290 | 'visible' => true, |
@@ -296,11 +296,11 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | array( |
| 298 | 298 | 'type' => 'billing_email', |
| 299 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
| 299 | + 'name' => __('Billing Email', 'invoicing'), |
|
| 300 | 300 | 'defaults' => array( |
| 301 | 301 | 'placeholder' => '[email protected]', |
| 302 | 302 | 'value' => '', |
| 303 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
| 303 | + 'label' => __('Billing Email', 'invoicing'), |
|
| 304 | 304 | 'description' => '', |
| 305 | 305 | 'premade' => true, |
| 306 | 306 | ) |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | array( |
| 321 | 321 | 'type' => 'items', |
| 322 | - 'name' => __( 'Items', 'invoicing' ), |
|
| 322 | + 'name' => __('Items', 'invoicing'), |
|
| 323 | 323 | 'defaults' => array( |
| 324 | 324 | 'value' => '', |
| 325 | 325 | 'items_type' => 'total', |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | array( |
| 332 | 332 | 'type' => 'pay_button', |
| 333 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
| 333 | + 'name' => __('Payment Button', 'invoicing'), |
|
| 334 | 334 | 'defaults' => array( |
| 335 | 335 | 'value' => '', |
| 336 | 336 | 'class' => 'btn-primary', |
| 337 | - 'label' => __( 'Pay Now »', 'invoicing' ), |
|
| 338 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
| 337 | + 'label' => __('Pay Now »', 'invoicing'), |
|
| 338 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
| 339 | 339 | 'premade' => true, |
| 340 | 340 | ) |
| 341 | 341 | ) |
| 342 | 342 | ); |
| 343 | 343 | |
| 344 | - $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
|
| 344 | + $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements); |
|
| 345 | 345 | return $this->elements; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | 349 | * Returns the restrict markup. |
| 350 | 350 | */ |
| 351 | - public function get_restrict_markup( $field, $field_type ) { |
|
| 351 | + public function get_restrict_markup($field, $field_type) { |
|
| 352 | 352 | $restrict = "$field.type=='$field_type'"; |
| 353 | 353 | return "v-if=\"$restrict\""; |
| 354 | 354 | } |
@@ -356,15 +356,15 @@ discard block |
||
| 356 | 356 | /** |
| 357 | 357 | * Renders the title element template. |
| 358 | 358 | */ |
| 359 | - public function render_heading_template( $field ) { |
|
| 360 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
| 359 | + public function render_heading_template($field) { |
|
| 360 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
| 361 | 361 | echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | 365 | * Renders the title element on the frontend. |
| 366 | 366 | */ |
| 367 | - public function frontend_render_heading_template( $field ) { |
|
| 367 | + public function frontend_render_heading_template($field) { |
|
| 368 | 368 | $tag = $field['level']; |
| 369 | 369 | echo "<$tag>{$field['text']}</$tag>"; |
| 370 | 370 | } |
@@ -372,10 +372,10 @@ discard block |
||
| 372 | 372 | /** |
| 373 | 373 | * Renders the edit title element template. |
| 374 | 374 | */ |
| 375 | - public function edit_heading_template( $field ) { |
|
| 376 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
| 377 | - $label = __( 'Heading', 'invoicing' ); |
|
| 378 | - $label2 = __( 'Select Heading Level', 'invoicing' ); |
|
| 375 | + public function edit_heading_template($field) { |
|
| 376 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
| 377 | + $label = __('Heading', 'invoicing'); |
|
| 378 | + $label2 = __('Select Heading Level', 'invoicing'); |
|
| 379 | 379 | $id = $field . '.id + "_edit"'; |
| 380 | 380 | $id2 = $field . '.id + "_edit2"'; |
| 381 | 381 | |
@@ -407,8 +407,8 @@ discard block |
||
| 407 | 407 | /** |
| 408 | 408 | * Renders a paragraph element template. |
| 409 | 409 | */ |
| 410 | - public function render_paragraph_template( $field ) { |
|
| 411 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
| 410 | + public function render_paragraph_template($field) { |
|
| 411 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
| 412 | 412 | $label = "$field.text"; |
| 413 | 413 | echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
| 414 | 414 | } |
@@ -416,16 +416,16 @@ discard block |
||
| 416 | 416 | /** |
| 417 | 417 | * Renders the paragraph element on the frontend. |
| 418 | 418 | */ |
| 419 | - public function frontend_render_paragraph_template( $field ) { |
|
| 419 | + public function frontend_render_paragraph_template($field) { |
|
| 420 | 420 | echo "<p>{$field['text']}</p>"; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * Renders the edit paragraph element template. |
| 425 | 425 | */ |
| 426 | - public function edit_paragraph_template( $field ) { |
|
| 427 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
| 428 | - $label = __( 'Enter your text', 'invoicing' ); |
|
| 426 | + public function edit_paragraph_template($field) { |
|
| 427 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
| 428 | + $label = __('Enter your text', 'invoicing'); |
|
| 429 | 429 | $id = $field . '.id + "_edit"'; |
| 430 | 430 | echo " |
| 431 | 431 | <div $restrict> |
@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | /** |
| 442 | 442 | * Renders the text element template. |
| 443 | 443 | */ |
| 444 | - public function render_text_template( $field ) { |
|
| 445 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
| 444 | + public function render_text_template($field) { |
|
| 445 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
| 446 | 446 | $label = "$field.label"; |
| 447 | 447 | echo " |
| 448 | 448 | <div $restrict> |
@@ -456,23 +456,23 @@ discard block |
||
| 456 | 456 | /** |
| 457 | 457 | * Renders the text element on the frontend. |
| 458 | 458 | */ |
| 459 | - public function frontend_render_text_template( $field ) { |
|
| 459 | + public function frontend_render_text_template($field) { |
|
| 460 | 460 | |
| 461 | 461 | echo "<div class='form-group'>"; |
| 462 | 462 | |
| 463 | 463 | echo aui()->input( |
| 464 | 464 | array( |
| 465 | - 'name' => esc_attr( $field['id'] ), |
|
| 466 | - 'id' => esc_attr( $field['id'] ), |
|
| 467 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
| 465 | + 'name' => esc_attr($field['id']), |
|
| 466 | + 'id' => esc_attr($field['id']), |
|
| 467 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
| 468 | 468 | 'required' => (bool) $field['required'], |
| 469 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 469 | + 'label' => wp_kses_post($field['label']), |
|
| 470 | 470 | 'no_wrap' => true, |
| 471 | 471 | ) |
| 472 | 472 | ); |
| 473 | 473 | |
| 474 | - if ( ! empty( $field['description'] ) ) { |
|
| 475 | - $description = wp_kses_post( $field['description'] ); |
|
| 474 | + if (!empty($field['description'])) { |
|
| 475 | + $description = wp_kses_post($field['description']); |
|
| 476 | 476 | echo "<small class='form-text text-muted'>$description</small>"; |
| 477 | 477 | } |
| 478 | 478 | |
@@ -483,16 +483,16 @@ discard block |
||
| 483 | 483 | /** |
| 484 | 484 | * Renders the edit text element template. |
| 485 | 485 | */ |
| 486 | - public function edit_text_template( $field ) { |
|
| 487 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
| 488 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 486 | + public function edit_text_template($field) { |
|
| 487 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
| 488 | + $label = __('Field Label', 'invoicing'); |
|
| 489 | 489 | $id = $field . '.id + "_edit"'; |
| 490 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 490 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 491 | 491 | $id2 = $field . '.id + "_edit2"'; |
| 492 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 493 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 492 | + $label3 = __('Help text', 'invoicing'); |
|
| 493 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 494 | 494 | $id3 = $field . '.id + "_edit3"'; |
| 495 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 495 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 496 | 496 | $id4 = $field . '.id + "_edit4"'; |
| 497 | 497 | echo " |
| 498 | 498 | <div $restrict> |
@@ -520,8 +520,8 @@ discard block |
||
| 520 | 520 | /** |
| 521 | 521 | * Renders the textarea element template. |
| 522 | 522 | */ |
| 523 | - public function render_textarea_template( $field ) { |
|
| 524 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
| 523 | + public function render_textarea_template($field) { |
|
| 524 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
| 525 | 525 | $label = "$field.label"; |
| 526 | 526 | echo " |
| 527 | 527 | <div $restrict> |
@@ -535,24 +535,24 @@ discard block |
||
| 535 | 535 | /** |
| 536 | 536 | * Renders the textarea element on the frontend. |
| 537 | 537 | */ |
| 538 | - public function frontend_render_textarea_template( $field ) { |
|
| 538 | + public function frontend_render_textarea_template($field) { |
|
| 539 | 539 | |
| 540 | 540 | echo "<div class='form-group'>"; |
| 541 | 541 | |
| 542 | 542 | echo aui()->textarea( |
| 543 | 543 | array( |
| 544 | - 'name' => esc_attr( $field['id'] ), |
|
| 545 | - 'id' => esc_attr( $field['id'] ), |
|
| 546 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
| 544 | + 'name' => esc_attr($field['id']), |
|
| 545 | + 'id' => esc_attr($field['id']), |
|
| 546 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
| 547 | 547 | 'required' => (bool) $field['required'], |
| 548 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 548 | + 'label' => wp_kses_post($field['label']), |
|
| 549 | 549 | 'no_wrap' => true, |
| 550 | 550 | 'rows' => 3, |
| 551 | 551 | ) |
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | - if ( ! empty( $field['description'] ) ) { |
|
| 555 | - $description = wp_kses_post( $field['description'] ); |
|
| 554 | + if (!empty($field['description'])) { |
|
| 555 | + $description = wp_kses_post($field['description']); |
|
| 556 | 556 | echo "<small class='form-text text-muted'>$description</small>"; |
| 557 | 557 | } |
| 558 | 558 | |
@@ -563,16 +563,16 @@ discard block |
||
| 563 | 563 | /** |
| 564 | 564 | * Renders the edit textarea element template. |
| 565 | 565 | */ |
| 566 | - public function edit_textarea_template( $field ) { |
|
| 567 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
| 568 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 566 | + public function edit_textarea_template($field) { |
|
| 567 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
| 568 | + $label = __('Field Label', 'invoicing'); |
|
| 569 | 569 | $id = $field . '.id + "_edit"'; |
| 570 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 570 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 571 | 571 | $id2 = $field . '.id + "_edit2"'; |
| 572 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 573 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 572 | + $label3 = __('Help text', 'invoicing'); |
|
| 573 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 574 | 574 | $id3 = $field . '.id + "_edit3"'; |
| 575 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 575 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 576 | 576 | $id4 = $field . '.id + "_edit4"'; |
| 577 | 577 | echo " |
| 578 | 578 | <div $restrict> |
@@ -600,8 +600,8 @@ discard block |
||
| 600 | 600 | /** |
| 601 | 601 | * Renders the select element template. |
| 602 | 602 | */ |
| 603 | - public function render_select_template( $field ) { |
|
| 604 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
| 603 | + public function render_select_template($field) { |
|
| 604 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
| 605 | 605 | $label = "$field.label"; |
| 606 | 606 | $placeholder = "$field.placeholder"; |
| 607 | 607 | $id = $field . '.id'; |
@@ -620,24 +620,24 @@ discard block |
||
| 620 | 620 | /** |
| 621 | 621 | * Renders the select element on the frontend. |
| 622 | 622 | */ |
| 623 | - public function frontend_render_select_template( $field ) { |
|
| 623 | + public function frontend_render_select_template($field) { |
|
| 624 | 624 | |
| 625 | 625 | echo "<div class='form-group'>"; |
| 626 | 626 | |
| 627 | 627 | echo aui()->select( |
| 628 | 628 | array( |
| 629 | - 'name' => esc_attr( $field['id'] ), |
|
| 630 | - 'id' => esc_attr( $field['id'] ), |
|
| 631 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
| 629 | + 'name' => esc_attr($field['id']), |
|
| 630 | + 'id' => esc_attr($field['id']), |
|
| 631 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
| 632 | 632 | 'required' => (bool) $field['required'], |
| 633 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 633 | + 'label' => wp_kses_post($field['label']), |
|
| 634 | 634 | 'no_wrap' => true, |
| 635 | - 'options' => array_combine( $field['options'], $field['options'] ), |
|
| 635 | + 'options' => array_combine($field['options'], $field['options']), |
|
| 636 | 636 | ) |
| 637 | 637 | ); |
| 638 | 638 | |
| 639 | - if ( ! empty( $field['description'] ) ) { |
|
| 640 | - $description = wp_kses_post( $field['description'] ); |
|
| 639 | + if (!empty($field['description'])) { |
|
| 640 | + $description = wp_kses_post($field['description']); |
|
| 641 | 641 | echo "<small class='form-text text-muted'>$description</small>"; |
| 642 | 642 | } |
| 643 | 643 | |
@@ -648,18 +648,18 @@ discard block |
||
| 648 | 648 | /** |
| 649 | 649 | * Renders the edit select element template. |
| 650 | 650 | */ |
| 651 | - public function edit_select_template( $field ) { |
|
| 652 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
| 653 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 651 | + public function edit_select_template($field) { |
|
| 652 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
| 653 | + $label = __('Field Label', 'invoicing'); |
|
| 654 | 654 | $id = $field . '.id + "_edit"'; |
| 655 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 655 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 656 | 656 | $id2 = $field . '.id + "_edit2"'; |
| 657 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 658 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 657 | + $label3 = __('Help text', 'invoicing'); |
|
| 658 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 659 | 659 | $id3 = $field . '.id + "_edit3"'; |
| 660 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 660 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 661 | 661 | $id4 = $field . '.id + "_edit4"'; |
| 662 | - $label6 = __( 'Available Options', 'invoicing' ); |
|
| 662 | + $label6 = __('Available Options', 'invoicing'); |
|
| 663 | 663 | echo " |
| 664 | 664 | <div $restrict> |
| 665 | 665 | <div class='form-group'> |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | /** |
| 698 | 698 | * Renders the checkbox element template. |
| 699 | 699 | */ |
| 700 | - public function render_checkbox_template( $field ) { |
|
| 701 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
| 700 | + public function render_checkbox_template($field) { |
|
| 701 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
| 702 | 702 | $label = "$field.label"; |
| 703 | 703 | echo " |
| 704 | 704 | <div class='form-check' $restrict> |
@@ -712,24 +712,24 @@ discard block |
||
| 712 | 712 | /** |
| 713 | 713 | * Renders the checkbox element on the frontend. |
| 714 | 714 | */ |
| 715 | - public function frontend_render_checkbox_template( $field ) { |
|
| 715 | + public function frontend_render_checkbox_template($field) { |
|
| 716 | 716 | |
| 717 | 717 | echo "<div class='form-group'>"; |
| 718 | 718 | |
| 719 | 719 | echo aui()->input( |
| 720 | 720 | array( |
| 721 | - 'name' => esc_attr( $field['id'] ), |
|
| 722 | - 'id' => esc_attr( $field['id'] ), |
|
| 721 | + 'name' => esc_attr($field['id']), |
|
| 722 | + 'id' => esc_attr($field['id']), |
|
| 723 | 723 | 'required' => (bool) $field['required'], |
| 724 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 724 | + 'label' => wp_kses_post($field['label']), |
|
| 725 | 725 | 'no_wrap' => true, |
| 726 | - 'value' => esc_attr__( 'Yes', 'invoicing' ), |
|
| 726 | + 'value' => esc_attr__('Yes', 'invoicing'), |
|
| 727 | 727 | 'type' => 'checkbox', |
| 728 | 728 | ) |
| 729 | 729 | ); |
| 730 | 730 | |
| 731 | - if ( ! empty( $field['description'] ) ) { |
|
| 732 | - $description = wp_kses_post( $field['description'] ); |
|
| 731 | + if (!empty($field['description'])) { |
|
| 732 | + $description = wp_kses_post($field['description']); |
|
| 733 | 733 | echo "<small class='form-text text-muted'>$description</small>"; |
| 734 | 734 | } |
| 735 | 735 | |
@@ -740,14 +740,14 @@ discard block |
||
| 740 | 740 | /** |
| 741 | 741 | * Renders the edit checkbox element template. |
| 742 | 742 | */ |
| 743 | - public function edit_checkbox_template( $field ) { |
|
| 744 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
| 745 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 743 | + public function edit_checkbox_template($field) { |
|
| 744 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
| 745 | + $label = __('Field Label', 'invoicing'); |
|
| 746 | 746 | $id = $field . '.id + "_edit"'; |
| 747 | - $label2 = __( 'Help text', 'invoicing' ); |
|
| 748 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 747 | + $label2 = __('Help text', 'invoicing'); |
|
| 748 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 749 | 749 | $id2 = $field . '.id + "_edit2"'; |
| 750 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
| 750 | + $label4 = __('Is this field required?', 'invoicing'); |
|
| 751 | 751 | $id3 = $field . '.id + "_edit3"'; |
| 752 | 752 | echo " |
| 753 | 753 | <div $restrict> |
@@ -771,8 +771,8 @@ discard block |
||
| 771 | 771 | /** |
| 772 | 772 | * Renders the radio element template. |
| 773 | 773 | */ |
| 774 | - public function render_radio_template( $field ) { |
|
| 775 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
| 774 | + public function render_radio_template($field) { |
|
| 775 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
| 776 | 776 | $label = "$field.label"; |
| 777 | 777 | $id = $field . '.id'; |
| 778 | 778 | echo " |
@@ -790,20 +790,20 @@ discard block |
||
| 790 | 790 | /** |
| 791 | 791 | * Renders the radio element on the frontend. |
| 792 | 792 | */ |
| 793 | - public function frontend_render_radio_template( $field ) { |
|
| 793 | + public function frontend_render_radio_template($field) { |
|
| 794 | 794 | |
| 795 | 795 | echo "<div class='form-group'>"; |
| 796 | 796 | |
| 797 | - if ( ! empty( $field['label'] ) ) { |
|
| 798 | - $label = wp_kses_post( $field['label'] ); |
|
| 797 | + if (!empty($field['label'])) { |
|
| 798 | + $label = wp_kses_post($field['label']); |
|
| 799 | 799 | echo "<legend class='col-form-label'>$label</legend>"; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - foreach( $field['options'] as $index => $option ) { |
|
| 802 | + foreach ($field['options'] as $index => $option) { |
|
| 803 | 803 | $id = $field['id'] . $index; |
| 804 | 804 | $name = $field['id']; |
| 805 | - $value = esc_attr( $option ); |
|
| 806 | - $label = wp_kses_post( $option ); |
|
| 805 | + $value = esc_attr($option); |
|
| 806 | + $label = wp_kses_post($option); |
|
| 807 | 807 | |
| 808 | 808 | echo " |
| 809 | 809 | <div class='form-check'> |
@@ -813,8 +813,8 @@ discard block |
||
| 813 | 813 | "; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if ( ! empty( $field['description'] ) ) { |
|
| 817 | - $description = wp_kses_post( $field['description'] ); |
|
| 816 | + if (!empty($field['description'])) { |
|
| 817 | + $description = wp_kses_post($field['description']); |
|
| 818 | 818 | echo "<small class='form-text text-muted'>$description</small>"; |
| 819 | 819 | } |
| 820 | 820 | |
@@ -825,16 +825,16 @@ discard block |
||
| 825 | 825 | /** |
| 826 | 826 | * Renders the edit radio element template. |
| 827 | 827 | */ |
| 828 | - public function edit_radio_template( $field ) { |
|
| 829 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
| 830 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 828 | + public function edit_radio_template($field) { |
|
| 829 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
| 830 | + $label = __('Field Label', 'invoicing'); |
|
| 831 | 831 | $id = $field . '.id + "_edit"'; |
| 832 | - $label2 = __( 'Help text', 'invoicing' ); |
|
| 833 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 832 | + $label2 = __('Help text', 'invoicing'); |
|
| 833 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 834 | 834 | $id2 = $field . '.id + "_edit3"'; |
| 835 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
| 835 | + $label4 = __('Is this field required?', 'invoicing'); |
|
| 836 | 836 | $id3 = $field . '.id + "_edit4"'; |
| 837 | - $label5 = __( 'Available Options', 'invoicing' ); |
|
| 837 | + $label5 = __('Available Options', 'invoicing'); |
|
| 838 | 838 | echo " |
| 839 | 839 | <div $restrict> |
| 840 | 840 | <div class='form-group'> |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | /** |
| 869 | 869 | * Renders the address element template. |
| 870 | 870 | */ |
| 871 | - public function render_address_template( $field ) { |
|
| 872 | - $restrict = $this->get_restrict_markup( $field, 'address' ); |
|
| 871 | + public function render_address_template($field) { |
|
| 872 | + $restrict = $this->get_restrict_markup($field, 'address'); |
|
| 873 | 873 | |
| 874 | 874 | echo " |
| 875 | 875 | <div class='wpinv-address-wrapper' $restrict> |
@@ -887,38 +887,38 @@ discard block |
||
| 887 | 887 | /** |
| 888 | 888 | * Renders the address element on the frontend. |
| 889 | 889 | */ |
| 890 | - public function frontend_render_address_template( $field ) { |
|
| 890 | + public function frontend_render_address_template($field) { |
|
| 891 | 891 | |
| 892 | 892 | echo "<div class='wpinv-address-fields'>"; |
| 893 | 893 | |
| 894 | - foreach( $field['fields'] as $address_field ) { |
|
| 894 | + foreach ($field['fields'] as $address_field) { |
|
| 895 | 895 | |
| 896 | - if ( empty( $address_field['visible'] ) ) { |
|
| 896 | + if (empty($address_field['visible'])) { |
|
| 897 | 897 | continue; |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | - $class = esc_attr( $address_field['name'] ); |
|
| 900 | + $class = esc_attr($address_field['name']); |
|
| 901 | 901 | echo "<div class='form-group $class'>"; |
| 902 | 902 | |
| 903 | 903 | $label = $address_field['label']; |
| 904 | 904 | |
| 905 | - if ( ! empty( $address_field['required'] ) ) { |
|
| 905 | + if (!empty($address_field['required'])) { |
|
| 906 | 906 | $label .= "<span class='text-danger'> *</span>"; |
| 907 | 907 | } |
| 908 | 908 | echo aui()->input( |
| 909 | 909 | array( |
| 910 | - 'name' => esc_attr( $address_field['name'] ), |
|
| 911 | - 'id' => esc_attr( $address_field['name'] ), |
|
| 910 | + 'name' => esc_attr($address_field['name']), |
|
| 911 | + 'id' => esc_attr($address_field['name']), |
|
| 912 | 912 | 'required' => (bool) $address_field['required'], |
| 913 | - 'label' => wp_kses_post( $label ), |
|
| 913 | + 'label' => wp_kses_post($label), |
|
| 914 | 914 | 'no_wrap' => true, |
| 915 | - 'placeholder' => esc_attr( $address_field['placeholder'] ), |
|
| 915 | + 'placeholder' => esc_attr($address_field['placeholder']), |
|
| 916 | 916 | 'type' => 'text', |
| 917 | 917 | ) |
| 918 | 918 | ); |
| 919 | 919 | |
| 920 | - if ( ! empty( $address_field['description'] ) ) { |
|
| 921 | - $description = wp_kses_post( $address_field['description'] ); |
|
| 920 | + if (!empty($address_field['description'])) { |
|
| 921 | + $description = wp_kses_post($address_field['description']); |
|
| 922 | 922 | echo "<small class='form-text text-muted'>$description</small>"; |
| 923 | 923 | } |
| 924 | 924 | |
@@ -933,13 +933,13 @@ discard block |
||
| 933 | 933 | /** |
| 934 | 934 | * Renders the edit address element template. |
| 935 | 935 | */ |
| 936 | - public function edit_address_template( $field ) { |
|
| 937 | - $restrict = $this->get_restrict_markup( $field, 'address' ); |
|
| 938 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 939 | - $label2 = __( 'Placeholder', 'invoicing' ); |
|
| 940 | - $label3 = __( 'Description', 'invoicing' ); |
|
| 941 | - $label4 = __( 'Is required', 'invoicing' ); |
|
| 942 | - $label5 = __( 'Is visible', 'invoicing' ); |
|
| 936 | + public function edit_address_template($field) { |
|
| 937 | + $restrict = $this->get_restrict_markup($field, 'address'); |
|
| 938 | + $label = __('Field Label', 'invoicing'); |
|
| 939 | + $label2 = __('Placeholder', 'invoicing'); |
|
| 940 | + $label3 = __('Description', 'invoicing'); |
|
| 941 | + $label4 = __('Is required', 'invoicing'); |
|
| 942 | + $label5 = __('Is visible', 'invoicing'); |
|
| 943 | 943 | $id = $field . '.id + "_edit_label"'; |
| 944 | 944 | $id2 = $field . '.id + "_edit_placeholder"'; |
| 945 | 945 | $id3 = $field . '.id + "_edit_description"'; |
@@ -1007,8 +1007,8 @@ discard block |
||
| 1007 | 1007 | /** |
| 1008 | 1008 | * Renders the email element template. |
| 1009 | 1009 | */ |
| 1010 | - public function render_email_template( $field ) { |
|
| 1011 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
| 1010 | + public function render_email_template($field) { |
|
| 1011 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
| 1012 | 1012 | $label = "$field.label"; |
| 1013 | 1013 | echo " |
| 1014 | 1014 | <div $restrict> |
@@ -1022,8 +1022,8 @@ discard block |
||
| 1022 | 1022 | /** |
| 1023 | 1023 | * Renders the billing_email element template. |
| 1024 | 1024 | */ |
| 1025 | - public function render_billing_email_template( $field ) { |
|
| 1026 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
| 1025 | + public function render_billing_email_template($field) { |
|
| 1026 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
| 1027 | 1027 | $label = "$field.label"; |
| 1028 | 1028 | echo " |
| 1029 | 1029 | <div $restrict> |
@@ -1037,24 +1037,24 @@ discard block |
||
| 1037 | 1037 | /** |
| 1038 | 1038 | * Renders the email element on the frontend. |
| 1039 | 1039 | */ |
| 1040 | - public function frontend_render_email_template( $field ) { |
|
| 1040 | + public function frontend_render_email_template($field) { |
|
| 1041 | 1041 | |
| 1042 | 1042 | echo "<div class='form-group'>"; |
| 1043 | 1043 | |
| 1044 | 1044 | echo aui()->input( |
| 1045 | 1045 | array( |
| 1046 | - 'name' => esc_attr( $field['id'] ), |
|
| 1047 | - 'id' => esc_attr( $field['id'] ), |
|
| 1046 | + 'name' => esc_attr($field['id']), |
|
| 1047 | + 'id' => esc_attr($field['id']), |
|
| 1048 | 1048 | 'required' => (bool) $field['required'], |
| 1049 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1049 | + 'label' => wp_kses_post($field['label']), |
|
| 1050 | 1050 | 'no_wrap' => true, |
| 1051 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1051 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1052 | 1052 | 'type' => 'email', |
| 1053 | 1053 | ) |
| 1054 | 1054 | ); |
| 1055 | 1055 | |
| 1056 | - if ( ! empty( $field['description'] ) ) { |
|
| 1057 | - $description = wp_kses_post( $field['description'] ); |
|
| 1056 | + if (!empty($field['description'])) { |
|
| 1057 | + $description = wp_kses_post($field['description']); |
|
| 1058 | 1058 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1059 | 1059 | } |
| 1060 | 1060 | |
@@ -1065,30 +1065,30 @@ discard block |
||
| 1065 | 1065 | /** |
| 1066 | 1066 | * Renders the billing email element on the frontend. |
| 1067 | 1067 | */ |
| 1068 | - public function frontend_render_billing_email_template( $field ) { |
|
| 1068 | + public function frontend_render_billing_email_template($field) { |
|
| 1069 | 1069 | |
| 1070 | 1070 | echo "<div class='form-group'>"; |
| 1071 | 1071 | $value = ''; |
| 1072 | 1072 | |
| 1073 | - if ( is_user_logged_in() ) { |
|
| 1073 | + if (is_user_logged_in()) { |
|
| 1074 | 1074 | $user = wp_get_current_user(); |
| 1075 | - $value = sanitize_email( $user->user_email ); |
|
| 1075 | + $value = sanitize_email($user->user_email); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | echo aui()->input( |
| 1078 | 1078 | array( |
| 1079 | 1079 | 'name' => 'billing_email', |
| 1080 | 1080 | 'value' => $value, |
| 1081 | - 'id' => esc_attr( $field['id'] ), |
|
| 1081 | + 'id' => esc_attr($field['id']), |
|
| 1082 | 1082 | 'required' => true, |
| 1083 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1083 | + 'label' => wp_kses_post($field['label']), |
|
| 1084 | 1084 | 'no_wrap' => true, |
| 1085 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1085 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1086 | 1086 | 'type' => 'email', |
| 1087 | 1087 | ) |
| 1088 | 1088 | ); |
| 1089 | 1089 | |
| 1090 | - if ( ! empty( $field['description'] ) ) { |
|
| 1091 | - $description = wp_kses_post( $field['description'] ); |
|
| 1090 | + if (!empty($field['description'])) { |
|
| 1091 | + $description = wp_kses_post($field['description']); |
|
| 1092 | 1092 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1093 | 1093 | } |
| 1094 | 1094 | |
@@ -1099,16 +1099,16 @@ discard block |
||
| 1099 | 1099 | /** |
| 1100 | 1100 | * Renders the edit email element template. |
| 1101 | 1101 | */ |
| 1102 | - public function edit_email_template( $field ) { |
|
| 1103 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
| 1104 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1102 | + public function edit_email_template($field) { |
|
| 1103 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
| 1104 | + $label = __('Field Label', 'invoicing'); |
|
| 1105 | 1105 | $id = $field . '.id + "_edit"'; |
| 1106 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1106 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1107 | 1107 | $id2 = $field . '.id + "_edit2"'; |
| 1108 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1109 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1108 | + $label3 = __('Help text', 'invoicing'); |
|
| 1109 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1110 | 1110 | $id3 = $field . '.id + "_edit3"'; |
| 1111 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1111 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1112 | 1112 | $id4 = $field . '.id + "_edit4"'; |
| 1113 | 1113 | echo " |
| 1114 | 1114 | <div $restrict> |
@@ -1136,16 +1136,16 @@ discard block |
||
| 1136 | 1136 | /** |
| 1137 | 1137 | * Renders the edit billing_email element template. |
| 1138 | 1138 | */ |
| 1139 | - public function edit_billing_email_template( $field ) { |
|
| 1140 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
| 1141 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1139 | + public function edit_billing_email_template($field) { |
|
| 1140 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
| 1141 | + $label = __('Field Label', 'invoicing'); |
|
| 1142 | 1142 | $id = $field . '.id + "_edit"'; |
| 1143 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1143 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1144 | 1144 | $id2 = $field . '.id + "_edit2"'; |
| 1145 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1146 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1145 | + $label3 = __('Help text', 'invoicing'); |
|
| 1146 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1147 | 1147 | $id3 = $field . '.id + "_edit3"'; |
| 1148 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1148 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1149 | 1149 | $id4 = $field . '.id + "_edit4"'; |
| 1150 | 1150 | echo " |
| 1151 | 1151 | <div $restrict> |
@@ -1169,8 +1169,8 @@ discard block |
||
| 1169 | 1169 | /** |
| 1170 | 1170 | * Renders the website element template. |
| 1171 | 1171 | */ |
| 1172 | - public function render_website_template( $field ) { |
|
| 1173 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
| 1172 | + public function render_website_template($field) { |
|
| 1173 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
| 1174 | 1174 | $label = "$field.label"; |
| 1175 | 1175 | echo " |
| 1176 | 1176 | <div $restrict> |
@@ -1184,24 +1184,24 @@ discard block |
||
| 1184 | 1184 | /** |
| 1185 | 1185 | * Renders the website element on the frontend. |
| 1186 | 1186 | */ |
| 1187 | - public function frontend_render_website_template( $field ) { |
|
| 1187 | + public function frontend_render_website_template($field) { |
|
| 1188 | 1188 | |
| 1189 | 1189 | echo "<div class='form-group'>"; |
| 1190 | 1190 | |
| 1191 | 1191 | echo aui()->input( |
| 1192 | 1192 | array( |
| 1193 | - 'name' => esc_attr( $field['id'] ), |
|
| 1194 | - 'id' => esc_attr( $field['id'] ), |
|
| 1193 | + 'name' => esc_attr($field['id']), |
|
| 1194 | + 'id' => esc_attr($field['id']), |
|
| 1195 | 1195 | 'required' => (bool) $field['required'], |
| 1196 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1196 | + 'label' => wp_kses_post($field['label']), |
|
| 1197 | 1197 | 'no_wrap' => true, |
| 1198 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1198 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1199 | 1199 | 'type' => 'url', |
| 1200 | 1200 | ) |
| 1201 | 1201 | ); |
| 1202 | 1202 | |
| 1203 | - if ( ! empty( $field['description'] ) ) { |
|
| 1204 | - $description = wp_kses_post( $field['description'] ); |
|
| 1203 | + if (!empty($field['description'])) { |
|
| 1204 | + $description = wp_kses_post($field['description']); |
|
| 1205 | 1205 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
@@ -1212,16 +1212,16 @@ discard block |
||
| 1212 | 1212 | /** |
| 1213 | 1213 | * Renders the edit website element template. |
| 1214 | 1214 | */ |
| 1215 | - public function edit_website_template( $field ) { |
|
| 1216 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
| 1217 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1215 | + public function edit_website_template($field) { |
|
| 1216 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
| 1217 | + $label = __('Field Label', 'invoicing'); |
|
| 1218 | 1218 | $id = $field . '.id + "_edit"'; |
| 1219 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1219 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1220 | 1220 | $id2 = $field . '.id + "_edit2"'; |
| 1221 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1222 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1221 | + $label3 = __('Help text', 'invoicing'); |
|
| 1222 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1223 | 1223 | $id3 = $field . '.id + "_edit3"'; |
| 1224 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1224 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1225 | 1225 | $id4 = $field . '.id + "_edit4"'; |
| 1226 | 1226 | echo " |
| 1227 | 1227 | <div $restrict> |
@@ -1249,8 +1249,8 @@ discard block |
||
| 1249 | 1249 | /** |
| 1250 | 1250 | * Renders the date element template. |
| 1251 | 1251 | */ |
| 1252 | - public function render_date_template( $field ) { |
|
| 1253 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
| 1252 | + public function render_date_template($field) { |
|
| 1253 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
| 1254 | 1254 | $label = "$field.label"; |
| 1255 | 1255 | echo " |
| 1256 | 1256 | <div $restrict> |
@@ -1264,24 +1264,24 @@ discard block |
||
| 1264 | 1264 | /** |
| 1265 | 1265 | * Renders the date element on the frontend. |
| 1266 | 1266 | */ |
| 1267 | - public function frontend_render_date_template( $field ) { |
|
| 1267 | + public function frontend_render_date_template($field) { |
|
| 1268 | 1268 | |
| 1269 | 1269 | echo "<div class='form-group'>"; |
| 1270 | 1270 | |
| 1271 | 1271 | echo aui()->input( |
| 1272 | 1272 | array( |
| 1273 | - 'name' => esc_attr( $field['id'] ), |
|
| 1274 | - 'id' => esc_attr( $field['id'] ), |
|
| 1273 | + 'name' => esc_attr($field['id']), |
|
| 1274 | + 'id' => esc_attr($field['id']), |
|
| 1275 | 1275 | 'required' => (bool) $field['required'], |
| 1276 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1277 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1276 | + 'label' => wp_kses_post($field['label']), |
|
| 1277 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1278 | 1278 | 'no_wrap' => true, |
| 1279 | 1279 | 'type' => 'date', |
| 1280 | 1280 | ) |
| 1281 | 1281 | ); |
| 1282 | 1282 | |
| 1283 | - if ( ! empty( $field['description'] ) ) { |
|
| 1284 | - $description = wp_kses_post( $field['description'] ); |
|
| 1283 | + if (!empty($field['description'])) { |
|
| 1284 | + $description = wp_kses_post($field['description']); |
|
| 1285 | 1285 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1286 | 1286 | } |
| 1287 | 1287 | |
@@ -1292,16 +1292,16 @@ discard block |
||
| 1292 | 1292 | /** |
| 1293 | 1293 | * Renders the edit date element template. |
| 1294 | 1294 | */ |
| 1295 | - public function edit_date_template( $field ) { |
|
| 1296 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
| 1297 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1295 | + public function edit_date_template($field) { |
|
| 1296 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
| 1297 | + $label = __('Field Label', 'invoicing'); |
|
| 1298 | 1298 | $id = $field . '.id + "_edit"'; |
| 1299 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1299 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1300 | 1300 | $id2 = $field . '.id + "_edit2"'; |
| 1301 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1302 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1301 | + $label3 = __('Help text', 'invoicing'); |
|
| 1302 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1303 | 1303 | $id3 = $field . '.id + "_edit3"'; |
| 1304 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1304 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1305 | 1305 | $id4 = $field . '.id + "_edit4"'; |
| 1306 | 1306 | echo " |
| 1307 | 1307 | <div $restrict> |
@@ -1329,8 +1329,8 @@ discard block |
||
| 1329 | 1329 | /** |
| 1330 | 1330 | * Renders the time element template. |
| 1331 | 1331 | */ |
| 1332 | - public function render_time_template( $field ) { |
|
| 1333 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
| 1332 | + public function render_time_template($field) { |
|
| 1333 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
| 1334 | 1334 | $label = "$field.label"; |
| 1335 | 1335 | echo " |
| 1336 | 1336 | <div $restrict> |
@@ -1344,24 +1344,24 @@ discard block |
||
| 1344 | 1344 | /** |
| 1345 | 1345 | * Renders the time element on the frontend. |
| 1346 | 1346 | */ |
| 1347 | - public function frontend_render_time_template( $field ) { |
|
| 1347 | + public function frontend_render_time_template($field) { |
|
| 1348 | 1348 | |
| 1349 | 1349 | echo "<div class='form-group'>"; |
| 1350 | 1350 | |
| 1351 | 1351 | echo aui()->input( |
| 1352 | 1352 | array( |
| 1353 | - 'name' => esc_attr( $field['id'] ), |
|
| 1354 | - 'id' => esc_attr( $field['id'] ), |
|
| 1353 | + 'name' => esc_attr($field['id']), |
|
| 1354 | + 'id' => esc_attr($field['id']), |
|
| 1355 | 1355 | 'required' => (bool) $field['required'], |
| 1356 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1356 | + 'label' => wp_kses_post($field['label']), |
|
| 1357 | 1357 | 'no_wrap' => true, |
| 1358 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1358 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1359 | 1359 | 'type' => 'time', |
| 1360 | 1360 | ) |
| 1361 | 1361 | ); |
| 1362 | 1362 | |
| 1363 | - if ( ! empty( $field['description'] ) ) { |
|
| 1364 | - $description = wp_kses_post( $field['description'] ); |
|
| 1363 | + if (!empty($field['description'])) { |
|
| 1364 | + $description = wp_kses_post($field['description']); |
|
| 1365 | 1365 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1366 | 1366 | } |
| 1367 | 1367 | |
@@ -1372,16 +1372,16 @@ discard block |
||
| 1372 | 1372 | /** |
| 1373 | 1373 | * Renders the edit time element template. |
| 1374 | 1374 | */ |
| 1375 | - public function edit_time_template( $field ) { |
|
| 1376 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
| 1377 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1375 | + public function edit_time_template($field) { |
|
| 1376 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
| 1377 | + $label = __('Field Label', 'invoicing'); |
|
| 1378 | 1378 | $id = $field . '.id + "_edit"'; |
| 1379 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1379 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1380 | 1380 | $id2 = $field . '.id + "_edit2"'; |
| 1381 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1382 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1381 | + $label3 = __('Help text', 'invoicing'); |
|
| 1382 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1383 | 1383 | $id3 = $field . '.id + "_edit3"'; |
| 1384 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1384 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1385 | 1385 | $id4 = $field . '.id + "_edit4"'; |
| 1386 | 1386 | echo " |
| 1387 | 1387 | <div $restrict> |
@@ -1409,8 +1409,8 @@ discard block |
||
| 1409 | 1409 | /** |
| 1410 | 1410 | * Renders the number element template. |
| 1411 | 1411 | */ |
| 1412 | - public function render_number_template( $field ) { |
|
| 1413 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
| 1412 | + public function render_number_template($field) { |
|
| 1413 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
| 1414 | 1414 | $label = "$field.label"; |
| 1415 | 1415 | echo " |
| 1416 | 1416 | <div $restrict> |
@@ -1424,24 +1424,24 @@ discard block |
||
| 1424 | 1424 | /** |
| 1425 | 1425 | * Renders the number element on the frontend. |
| 1426 | 1426 | */ |
| 1427 | - public function frontend_render_number_template( $field ) { |
|
| 1427 | + public function frontend_render_number_template($field) { |
|
| 1428 | 1428 | |
| 1429 | 1429 | echo "<div class='form-group'>"; |
| 1430 | 1430 | |
| 1431 | 1431 | echo aui()->input( |
| 1432 | 1432 | array( |
| 1433 | - 'name' => esc_attr( $field['id'] ), |
|
| 1434 | - 'id' => esc_attr( $field['id'] ), |
|
| 1433 | + 'name' => esc_attr($field['id']), |
|
| 1434 | + 'id' => esc_attr($field['id']), |
|
| 1435 | 1435 | 'required' => (bool) $field['required'], |
| 1436 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1437 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1436 | + 'label' => wp_kses_post($field['label']), |
|
| 1437 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1438 | 1438 | 'no_wrap' => true, |
| 1439 | 1439 | 'type' => 'number', |
| 1440 | 1440 | ) |
| 1441 | 1441 | ); |
| 1442 | 1442 | |
| 1443 | - if ( ! empty( $field['description'] ) ) { |
|
| 1444 | - $description = wp_kses_post( $field['description'] ); |
|
| 1443 | + if (!empty($field['description'])) { |
|
| 1444 | + $description = wp_kses_post($field['description']); |
|
| 1445 | 1445 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
@@ -1452,16 +1452,16 @@ discard block |
||
| 1452 | 1452 | /** |
| 1453 | 1453 | * Renders the edit number element template. |
| 1454 | 1454 | */ |
| 1455 | - public function edit_number_template( $field ) { |
|
| 1456 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
| 1457 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1455 | + public function edit_number_template($field) { |
|
| 1456 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
| 1457 | + $label = __('Field Label', 'invoicing'); |
|
| 1458 | 1458 | $id = $field . '.id + "_edit"'; |
| 1459 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1459 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1460 | 1460 | $id2 = $field . '.id + "_edit2"'; |
| 1461 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1462 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1461 | + $label3 = __('Help text', 'invoicing'); |
|
| 1462 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1463 | 1463 | $id3 = $field . '.id + "_edit3"'; |
| 1464 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1464 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1465 | 1465 | $id4 = $field . '.id + "_edit4"'; |
| 1466 | 1466 | echo " |
| 1467 | 1467 | <div $restrict> |
@@ -1489,23 +1489,23 @@ discard block |
||
| 1489 | 1489 | /** |
| 1490 | 1490 | * Renders the separator element template. |
| 1491 | 1491 | */ |
| 1492 | - public function render_separator_template( $field ) { |
|
| 1493 | - $restrict = $this->get_restrict_markup( $field, 'separator' ); |
|
| 1492 | + public function render_separator_template($field) { |
|
| 1493 | + $restrict = $this->get_restrict_markup($field, 'separator'); |
|
| 1494 | 1494 | echo "<hr class='featurette-divider mt-0 mb-2' $restrict>"; |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
| 1498 | 1498 | * Renders the separator element on the frontend. |
| 1499 | 1499 | */ |
| 1500 | - public function frontend_render_separator_template( $field ) { |
|
| 1500 | + public function frontend_render_separator_template($field) { |
|
| 1501 | 1501 | echo '<hr class="featurette-divider mt-0 mb-2" />'; |
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | /** |
| 1505 | 1505 | * Renders the pay button element template. |
| 1506 | 1506 | */ |
| 1507 | - public function render_pay_button_template( $field ) { |
|
| 1508 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
| 1507 | + public function render_pay_button_template($field) { |
|
| 1508 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
| 1509 | 1509 | $label = "$field.label"; |
| 1510 | 1510 | echo " |
| 1511 | 1511 | <div $restrict> |
@@ -1518,24 +1518,24 @@ discard block |
||
| 1518 | 1518 | /** |
| 1519 | 1519 | * Renders the pay_button element on the frontend. |
| 1520 | 1520 | */ |
| 1521 | - public function frontend_render_pay_button_template( $field ) { |
|
| 1521 | + public function frontend_render_pay_button_template($field) { |
|
| 1522 | 1522 | |
| 1523 | 1523 | echo "<div class='form-group'>"; |
| 1524 | 1524 | |
| 1525 | - $class = 'btn btn-block submit-button ' . sanitize_html_class( $field['class'] ); |
|
| 1525 | + $class = 'btn btn-block submit-button ' . sanitize_html_class($field['class']); |
|
| 1526 | 1526 | echo aui()->input( |
| 1527 | 1527 | array( |
| 1528 | - 'name' => esc_attr( $field['id'] ), |
|
| 1529 | - 'id' => esc_attr( $field['id'] ), |
|
| 1530 | - 'value' => esc_attr( $field['label'] ), |
|
| 1528 | + 'name' => esc_attr($field['id']), |
|
| 1529 | + 'id' => esc_attr($field['id']), |
|
| 1530 | + 'value' => esc_attr($field['label']), |
|
| 1531 | 1531 | 'no_wrap' => true, |
| 1532 | 1532 | 'type' => 'submit', |
| 1533 | 1533 | 'class' => $class, |
| 1534 | 1534 | ) |
| 1535 | 1535 | ); |
| 1536 | 1536 | |
| 1537 | - if ( ! empty( $field['description'] ) ) { |
|
| 1538 | - $description = wp_kses_post( $field['description'] ); |
|
| 1537 | + if (!empty($field['description'])) { |
|
| 1538 | + $description = wp_kses_post($field['description']); |
|
| 1539 | 1539 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1540 | 1540 | } |
| 1541 | 1541 | |
@@ -1546,14 +1546,14 @@ discard block |
||
| 1546 | 1546 | /** |
| 1547 | 1547 | * Renders the pay button element template. |
| 1548 | 1548 | */ |
| 1549 | - public function edit_pay_button_template( $field ) { |
|
| 1550 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
| 1551 | - $label = __( 'Button Text', 'invoicing' ); |
|
| 1549 | + public function edit_pay_button_template($field) { |
|
| 1550 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
| 1551 | + $label = __('Button Text', 'invoicing'); |
|
| 1552 | 1552 | $id = $field . '.id + "_edit"'; |
| 1553 | - $label2 = __( 'Help text', 'invoicing' ); |
|
| 1554 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1553 | + $label2 = __('Help text', 'invoicing'); |
|
| 1554 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1555 | 1555 | $id2 = $field . '.id + "_edit2"'; |
| 1556 | - $label4 = esc_attr__( 'Button Type', 'invoicing' ); |
|
| 1556 | + $label4 = esc_attr__('Button Type', 'invoicing'); |
|
| 1557 | 1557 | $id3 = $field . '.id + "_edit3"'; |
| 1558 | 1558 | echo " |
| 1559 | 1559 | <div $restrict> |
@@ -1569,15 +1569,15 @@ discard block |
||
| 1569 | 1569 | <label :for='$id3'>$label4</label> |
| 1570 | 1570 | |
| 1571 | 1571 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
| 1572 | - <option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
| 1573 | - <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
| 1574 | - <option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
| 1575 | - <option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
| 1576 | - <option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
| 1577 | - <option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
| 1578 | - <option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
| 1579 | - <option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
| 1580 | - <option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
|
| 1572 | + <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option> |
|
| 1573 | + <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
| 1574 | + <option value='btn-success'>" . __('Success', 'invoicing') . "</option> |
|
| 1575 | + <option value='btn-danger'>" . __('Danger', 'invoicing') . "</option> |
|
| 1576 | + <option value='btn-warning'>" . __('Warning', 'invoicing') . "</option> |
|
| 1577 | + <option value='btn-info'>" . __('Info', 'invoicing') . "</option> |
|
| 1578 | + <option value='btn-light'>" . __('Light', 'invoicing') . "</option> |
|
| 1579 | + <option value='btn-dark'>" . __('Dark', 'invoicing') . "</option> |
|
| 1580 | + <option value='btn-link'>" . __('Link', 'invoicing') . "</option> |
|
| 1581 | 1581 | </select> |
| 1582 | 1582 | </div> |
| 1583 | 1583 | </div> |
@@ -1588,8 +1588,8 @@ discard block |
||
| 1588 | 1588 | /** |
| 1589 | 1589 | * Renders the alert element template. |
| 1590 | 1590 | */ |
| 1591 | - public function render_alert_template( $field ) { |
|
| 1592 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
| 1591 | + public function render_alert_template($field) { |
|
| 1592 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
| 1593 | 1593 | $text = "$field.text"; |
| 1594 | 1594 | echo " |
| 1595 | 1595 | <div $restrict class='alert' :class='$field.class' role='alert'> |
@@ -1604,15 +1604,15 @@ discard block |
||
| 1604 | 1604 | /** |
| 1605 | 1605 | * Renders the alert element on the frontend. |
| 1606 | 1606 | */ |
| 1607 | - public function frontend_render_alert_template( $field ) { |
|
| 1607 | + public function frontend_render_alert_template($field) { |
|
| 1608 | 1608 | |
| 1609 | 1609 | echo "<div class='form-group'>"; |
| 1610 | 1610 | |
| 1611 | 1611 | echo aui()->alert( |
| 1612 | 1612 | array( |
| 1613 | - 'content' => wp_kses_post( $field['text'] ), |
|
| 1613 | + 'content' => wp_kses_post($field['text']), |
|
| 1614 | 1614 | 'dismissible' => $field['dismissible'], |
| 1615 | - 'type' => str_replace( 'alert-', '', $field['class'] ), |
|
| 1615 | + 'type' => str_replace('alert-', '', $field['class']), |
|
| 1616 | 1616 | ) |
| 1617 | 1617 | ); |
| 1618 | 1618 | |
@@ -1623,14 +1623,14 @@ discard block |
||
| 1623 | 1623 | /** |
| 1624 | 1624 | * Renders the alert element template. |
| 1625 | 1625 | */ |
| 1626 | - public function edit_alert_template( $field ) { |
|
| 1627 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
| 1628 | - $label = __( 'Alert Text', 'invoicing' ); |
|
| 1629 | - $label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
|
| 1626 | + public function edit_alert_template($field) { |
|
| 1627 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
| 1628 | + $label = __('Alert Text', 'invoicing'); |
|
| 1629 | + $label2 = esc_attr__('Enter your alert text here', 'invoicing'); |
|
| 1630 | 1630 | $id = $field . '.id + "_edit"'; |
| 1631 | - $label3 = __( 'Is Dismissible?', 'invoicing' ); |
|
| 1631 | + $label3 = __('Is Dismissible?', 'invoicing'); |
|
| 1632 | 1632 | $id2 = $field . '.id + "_edit2"'; |
| 1633 | - $label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
|
| 1633 | + $label4 = esc_attr__('Alert Type', 'invoicing'); |
|
| 1634 | 1634 | $id3 = $field . '.id + "_edit3"'; |
| 1635 | 1635 | echo " |
| 1636 | 1636 | <div $restrict> |
@@ -1646,14 +1646,14 @@ discard block |
||
| 1646 | 1646 | <label :for='$id3'>$label4</label> |
| 1647 | 1647 | |
| 1648 | 1648 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
| 1649 | - <option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
| 1650 | - <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
| 1651 | - <option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
| 1652 | - <option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
| 1653 | - <option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
| 1654 | - <option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
| 1655 | - <option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
| 1656 | - <option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
| 1649 | + <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option> |
|
| 1650 | + <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
| 1651 | + <option value='alert-success'>" . __('Success', 'invoicing') . "</option> |
|
| 1652 | + <option value='alert-danger'>" . __('Danger', 'invoicing') . "</option> |
|
| 1653 | + <option value='alert-warning'>" . __('Warning', 'invoicing') . "</option> |
|
| 1654 | + <option value='alert-info'>" . __('Info', 'invoicing') . "</option> |
|
| 1655 | + <option value='alert-light'>" . __('Light', 'invoicing') . "</option> |
|
| 1656 | + <option value='alert-dark'>" . __('Dark', 'invoicing') . "</option> |
|
| 1657 | 1657 | </select> |
| 1658 | 1658 | </div> |
| 1659 | 1659 | </div> |
@@ -1664,8 +1664,8 @@ discard block |
||
| 1664 | 1664 | /** |
| 1665 | 1665 | * Renders the discount element template. |
| 1666 | 1666 | */ |
| 1667 | - public function render_discount_template( $field ) { |
|
| 1668 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
| 1667 | + public function render_discount_template($field) { |
|
| 1668 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
| 1669 | 1669 | ?> |
| 1670 | 1670 | |
| 1671 | 1671 | <div <?php echo $restrict; ?> class="discount_field border rounded p-3"> |
@@ -1682,13 +1682,13 @@ discard block |
||
| 1682 | 1682 | /** |
| 1683 | 1683 | * Renders the discount element on the frontend. |
| 1684 | 1684 | */ |
| 1685 | - public function frontend_render_discount_template( $field ) { |
|
| 1685 | + public function frontend_render_discount_template($field) { |
|
| 1686 | 1686 | |
| 1687 | - $placeholder = esc_attr( $field['input_label'] ); |
|
| 1688 | - $label = sanitize_text_field( $field['button_label'] ); |
|
| 1687 | + $placeholder = esc_attr($field['input_label']); |
|
| 1688 | + $label = sanitize_text_field($field['button_label']); |
|
| 1689 | 1689 | $description = ''; |
| 1690 | 1690 | |
| 1691 | - if ( ! empty( $field['description'] ) ) { |
|
| 1691 | + if (!empty($field['description'])) { |
|
| 1692 | 1692 | $description = "<small class='form-text text-muted'>{$field['description']}</small>"; |
| 1693 | 1693 | } |
| 1694 | 1694 | ?> |
@@ -1709,12 +1709,12 @@ discard block |
||
| 1709 | 1709 | /** |
| 1710 | 1710 | * Renders the discount element template. |
| 1711 | 1711 | */ |
| 1712 | - public function edit_discount_template( $field ) { |
|
| 1713 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
| 1714 | - $label = __( 'Discount Input Placeholder', 'invoicing' ); |
|
| 1715 | - $label2 = __( 'Help Text', 'invoicing' ); |
|
| 1716 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1717 | - $label4 = __( 'Button Text', 'invoicing' ); |
|
| 1712 | + public function edit_discount_template($field) { |
|
| 1713 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
| 1714 | + $label = __('Discount Input Placeholder', 'invoicing'); |
|
| 1715 | + $label2 = __('Help Text', 'invoicing'); |
|
| 1716 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1717 | + $label4 = __('Button Text', 'invoicing'); |
|
| 1718 | 1718 | $id = $field . '.id + "_edit"'; |
| 1719 | 1719 | $id2 = $field . '.id + "_edit2"'; |
| 1720 | 1720 | $id3 = $field . '.id + "_edit3"'; |
@@ -1743,48 +1743,48 @@ discard block |
||
| 1743 | 1743 | /** |
| 1744 | 1744 | * Renders the items element template. |
| 1745 | 1745 | */ |
| 1746 | - public function render_items_template( $field ) { |
|
| 1747 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
| 1748 | - $label = __( 'Item totals placeholder. Item totals will appear here. Click to set items.', 'invoicing' ); |
|
| 1746 | + public function render_items_template($field) { |
|
| 1747 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
| 1748 | + $label = __('Item totals placeholder. Item totals will appear here. Click to set items.', 'invoicing'); |
|
| 1749 | 1749 | echo "<div $restrict class='item_totals p-4 bg-warning'>$label</div>"; |
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | 1752 | /** |
| 1753 | 1753 | * Renders the items element on the frontend. |
| 1754 | 1754 | */ |
| 1755 | - public function frontend_render_items_template( $field, $items ) { |
|
| 1755 | + public function frontend_render_items_template($field, $items) { |
|
| 1756 | 1756 | |
| 1757 | 1757 | echo "<div class='form-group item_totals'>"; |
| 1758 | 1758 | |
| 1759 | - $id = esc_attr( $field['id'] ); |
|
| 1760 | - if ( 'total' == $field[ 'items_type' ] ) { |
|
| 1759 | + $id = esc_attr($field['id']); |
|
| 1760 | + if ('total' == $field['items_type']) { |
|
| 1761 | 1761 | $total = 0; |
| 1762 | 1762 | |
| 1763 | 1763 | ?> |
| 1764 | 1764 | <div class="border item_totals_type_total"> |
| 1765 | 1765 | |
| 1766 | 1766 | <?php |
| 1767 | - foreach( $items as $item ) { |
|
| 1768 | - $total = $total + floatval( $item['price'] ); |
|
| 1767 | + foreach ($items as $item) { |
|
| 1768 | + $total = $total + floatval($item['price']); |
|
| 1769 | 1769 | |
| 1770 | 1770 | $class = 'col-8'; |
| 1771 | 1771 | $class2 = ''; |
| 1772 | 1772 | |
| 1773 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
| 1773 | + if (!empty($item['allow_quantities'])) { |
|
| 1774 | 1774 | $class = 'col-6 pt-2'; |
| 1775 | 1775 | $class2 = 'pt-2'; |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | - if ( ! empty( $item['custom_price'] ) ) { |
|
| 1778 | + if (!empty($item['custom_price'])) { |
|
| 1779 | 1779 | $class .= ' pt-2'; |
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | 1782 | ?> |
| 1783 | 1783 | <div class="item_totals_item"> |
| 1784 | 1784 | <div class='row pl-2 pr-2 pt-2'> |
| 1785 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
| 1785 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
| 1786 | 1786 | |
| 1787 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
| 1787 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
| 1788 | 1788 | |
| 1789 | 1789 | <div class='col-2'> |
| 1790 | 1790 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -1792,11 +1792,11 @@ discard block |
||
| 1792 | 1792 | |
| 1793 | 1793 | <?php } else { ?> |
| 1794 | 1794 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
| 1795 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
| 1795 | + <?php } if (empty($item['custom_price'])) { ?> |
|
| 1796 | 1796 | |
| 1797 | 1797 | <div class='col-4 <?php echo $class2; ?>'> |
| 1798 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
| 1799 | - <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
| 1798 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
| 1799 | + <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
| 1800 | 1800 | </div> |
| 1801 | 1801 | |
| 1802 | 1802 | <?php } else {?> |
@@ -1804,15 +1804,15 @@ discard block |
||
| 1804 | 1804 | <div class='col-4'> |
| 1805 | 1805 | <div class='input-group'> |
| 1806 | 1806 | |
| 1807 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
| 1807 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
| 1808 | 1808 | <div class='input-group-prepend'> |
| 1809 | 1809 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 1810 | 1810 | </div> |
| 1811 | 1811 | <?php } ?> |
| 1812 | 1812 | |
| 1813 | - <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
| 1813 | + <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
| 1814 | 1814 | |
| 1815 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
| 1815 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
| 1816 | 1816 | <div class='input-group-append'> |
| 1817 | 1817 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 1818 | 1818 | </div> |
@@ -1823,38 +1823,38 @@ discard block |
||
| 1823 | 1823 | <?php } ?> |
| 1824 | 1824 | |
| 1825 | 1825 | </div> |
| 1826 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 1827 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 1826 | + <?php if (!empty($item['description'])) { ?> |
|
| 1827 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 1828 | 1828 | <?php } ?> |
| 1829 | 1829 | </div> |
| 1830 | 1830 | <?php } ?> |
| 1831 | 1831 | |
| 1832 | 1832 | <div class='mt-4 border-top item_totals_total'> |
| 1833 | 1833 | <div class='row p-2'> |
| 1834 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
| 1835 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
| 1834 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
| 1835 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
| 1836 | 1836 | </div> |
| 1837 | 1837 | </div> |
| 1838 | 1838 | |
| 1839 | 1839 | </div> |
| 1840 | 1840 | <?php } ?> |
| 1841 | 1841 | |
| 1842 | - <?php if ( 'radio' == $field[ 'items_type' ] ) { ?> |
|
| 1842 | + <?php if ('radio' == $field['items_type']) { ?> |
|
| 1843 | 1843 | <div class="item_totals_type_radio"> |
| 1844 | 1844 | |
| 1845 | 1845 | <?php |
| 1846 | - foreach( $items as $index => $item ) { |
|
| 1846 | + foreach ($items as $index => $item) { |
|
| 1847 | 1847 | |
| 1848 | - if ( ! empty( $item['required'] ) ) { |
|
| 1848 | + if (!empty($item['required'])) { |
|
| 1849 | 1849 | continue; |
| 1850 | 1850 | } |
| 1851 | 1851 | ?> |
| 1852 | 1852 | <div class="form-check"> |
| 1853 | - <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'> |
|
| 1854 | - <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?> <strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); ?></strong></label> |
|
| 1853 | + <input class='form-check-input wpinv-items-selector' <?php checked(!isset($selected_radio_item)); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'> |
|
| 1854 | + <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?> <strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label> |
|
| 1855 | 1855 | </div> |
| 1856 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 1857 | - <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 1856 | + <?php if (!empty($item['description'])) { ?> |
|
| 1857 | + <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 1858 | 1858 | <?php } ?> |
| 1859 | 1859 | <?php } ?> |
| 1860 | 1860 | |
@@ -1864,29 +1864,29 @@ discard block |
||
| 1864 | 1864 | |
| 1865 | 1865 | $total = 0; |
| 1866 | 1866 | |
| 1867 | - foreach ( $items as $item ) { |
|
| 1867 | + foreach ($items as $item) { |
|
| 1868 | 1868 | |
| 1869 | 1869 | $class = 'col-8'; |
| 1870 | 1870 | $class2 = ''; |
| 1871 | 1871 | |
| 1872 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
| 1872 | + if (!empty($item['allow_quantities'])) { |
|
| 1873 | 1873 | $class = 'col-6 pt-2'; |
| 1874 | 1874 | $class2 = 'pt-2'; |
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | - if ( ! empty( $item['custom_price'] ) ) { |
|
| 1877 | + if (!empty($item['custom_price'])) { |
|
| 1878 | 1878 | $class .= ' pt-2'; |
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | 1881 | $class3 = 'd-none'; |
| 1882 | 1882 | $name = ''; |
| 1883 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) { |
|
| 1883 | + if (!empty($item['required']) || !isset($totals_selected_radio_item)) { |
|
| 1884 | 1884 | |
| 1885 | - $total = $total + floatval( $item['price'] ); |
|
| 1885 | + $total = $total + floatval($item['price']); |
|
| 1886 | 1886 | $class3 = ''; |
| 1887 | 1887 | $name = "wpinv-items[{$item['id']}]"; |
| 1888 | 1888 | |
| 1889 | - if ( empty( $item['required'] ) ) { |
|
| 1889 | + if (empty($item['required'])) { |
|
| 1890 | 1890 | $totals_selected_radio_item = 1; |
| 1891 | 1891 | } |
| 1892 | 1892 | |
@@ -1898,9 +1898,9 @@ discard block |
||
| 1898 | 1898 | |
| 1899 | 1899 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
| 1900 | 1900 | <div class='row pl-2 pr-2 pt-2'> |
| 1901 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
| 1901 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
| 1902 | 1902 | |
| 1903 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
| 1903 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
| 1904 | 1904 | |
| 1905 | 1905 | <div class='col-2'> |
| 1906 | 1906 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -1908,11 +1908,11 @@ discard block |
||
| 1908 | 1908 | |
| 1909 | 1909 | <?php } else { ?> |
| 1910 | 1910 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
| 1911 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
| 1911 | + <?php } if (empty($item['custom_price'])) { ?> |
|
| 1912 | 1912 | |
| 1913 | 1913 | <div class='col-4 <?php echo $class2; ?>'> |
| 1914 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
| 1915 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
| 1914 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
| 1915 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
| 1916 | 1916 | </div> |
| 1917 | 1917 | |
| 1918 | 1918 | <?php } else {?> |
@@ -1920,15 +1920,15 @@ discard block |
||
| 1920 | 1920 | <div class='col-4'> |
| 1921 | 1921 | <div class='input-group'> |
| 1922 | 1922 | |
| 1923 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
| 1923 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
| 1924 | 1924 | <div class='input-group-prepend'> |
| 1925 | 1925 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 1926 | 1926 | </div> |
| 1927 | 1927 | <?php } ?> |
| 1928 | 1928 | |
| 1929 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
| 1929 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
| 1930 | 1930 | |
| 1931 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
| 1931 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
| 1932 | 1932 | <div class='input-group-append'> |
| 1933 | 1933 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 1934 | 1934 | </div> |
@@ -1939,16 +1939,16 @@ discard block |
||
| 1939 | 1939 | <?php } ?> |
| 1940 | 1940 | |
| 1941 | 1941 | </div> |
| 1942 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 1943 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 1942 | + <?php if (!empty($item['description'])) { ?> |
|
| 1943 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 1944 | 1944 | <?php } ?> |
| 1945 | 1945 | </div> |
| 1946 | 1946 | <?php } ?> |
| 1947 | 1947 | |
| 1948 | 1948 | <div class='mt-4 border-top item_totals_total'> |
| 1949 | 1949 | <div class='row p-2'> |
| 1950 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
| 1951 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
| 1950 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
| 1951 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
| 1952 | 1952 | </div> |
| 1953 | 1953 | </div> |
| 1954 | 1954 | |
@@ -1956,22 +1956,22 @@ discard block |
||
| 1956 | 1956 | </div> |
| 1957 | 1957 | <?php } ?> |
| 1958 | 1958 | |
| 1959 | - <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?> |
|
| 1959 | + <?php if ('checkbox' == $field['items_type']) { ?> |
|
| 1960 | 1960 | |
| 1961 | 1961 | <div class="item_totals_type_checkbox"> |
| 1962 | 1962 | |
| 1963 | 1963 | <?php |
| 1964 | - foreach ( $items as $index => $item ) { |
|
| 1964 | + foreach ($items as $index => $item) { |
|
| 1965 | 1965 | |
| 1966 | - if ( ! empty( $item['required'] ) ) { |
|
| 1966 | + if (!empty($item['required'])) { |
|
| 1967 | 1967 | continue; |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | - $title = sanitize_text_field( $item['title'] ); |
|
| 1971 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
| 1972 | - $item_id = esc_attr( $id . "_$index" ); |
|
| 1973 | - $value = esc_attr( $item['id'] ); |
|
| 1974 | - $checked = checked( ! isset( $selected_checkbox_item ), true, false ); |
|
| 1970 | + $title = sanitize_text_field($item['title']); |
|
| 1971 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
| 1972 | + $item_id = esc_attr($id . "_$index"); |
|
| 1973 | + $value = esc_attr($item['id']); |
|
| 1974 | + $checked = checked(!isset($selected_checkbox_item), true, false); |
|
| 1975 | 1975 | $selected_checkbox_item = 1; |
| 1976 | 1976 | |
| 1977 | 1977 | echo " |
@@ -1980,7 +1980,7 @@ discard block |
||
| 1980 | 1980 | <label for='$item_id' class='custom-control-label'>$title ($price)</label> |
| 1981 | 1981 | </div>"; |
| 1982 | 1982 | |
| 1983 | - if ( ! empty( $item['description'] ) ) { |
|
| 1983 | + if (!empty($item['description'])) { |
|
| 1984 | 1984 | echo "<small class='form-text text-muted'>{$item['description']}</small>"; |
| 1985 | 1985 | } |
| 1986 | 1986 | } |
@@ -1992,29 +1992,29 @@ discard block |
||
| 1992 | 1992 | |
| 1993 | 1993 | $total = 0; |
| 1994 | 1994 | |
| 1995 | - foreach ( $items as $item ) { |
|
| 1995 | + foreach ($items as $item) { |
|
| 1996 | 1996 | |
| 1997 | 1997 | $class = 'col-8'; |
| 1998 | 1998 | $class2 = ''; |
| 1999 | 1999 | |
| 2000 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
| 2000 | + if (!empty($item['allow_quantities'])) { |
|
| 2001 | 2001 | $class = 'col-6 pt-2'; |
| 2002 | 2002 | $class2 = 'pt-2'; |
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | - if ( ! empty( $item['custom_price'] ) ) { |
|
| 2005 | + if (!empty($item['custom_price'])) { |
|
| 2006 | 2006 | $class .= ' pt-2'; |
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | 2009 | $class3 = 'd-none'; |
| 2010 | - $name = ''; |
|
| 2011 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) { |
|
| 2010 | + $name = ''; |
|
| 2011 | + if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) { |
|
| 2012 | 2012 | |
| 2013 | - $total = $total + floatval( $item['price'] ); |
|
| 2013 | + $total = $total + floatval($item['price']); |
|
| 2014 | 2014 | $class3 = ''; |
| 2015 | 2015 | $name = "wpinv-items[{$item['id']}]"; |
| 2016 | 2016 | |
| 2017 | - if ( empty( $item['required'] ) ) { |
|
| 2017 | + if (empty($item['required'])) { |
|
| 2018 | 2018 | $totals_selected_checkbox_item = 1; |
| 2019 | 2019 | } |
| 2020 | 2020 | |
@@ -2026,9 +2026,9 @@ discard block |
||
| 2026 | 2026 | |
| 2027 | 2027 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
| 2028 | 2028 | <div class='row pl-2 pr-2 pt-2'> |
| 2029 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
| 2029 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
| 2030 | 2030 | |
| 2031 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
| 2031 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
| 2032 | 2032 | |
| 2033 | 2033 | <div class='col-2'> |
| 2034 | 2034 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -2036,11 +2036,11 @@ discard block |
||
| 2036 | 2036 | |
| 2037 | 2037 | <?php } else { ?> |
| 2038 | 2038 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
| 2039 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
| 2039 | + <?php } if (empty($item['custom_price'])) { ?> |
|
| 2040 | 2040 | |
| 2041 | 2041 | <div class='col-4 <?php echo $class2; ?>'> |
| 2042 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
| 2043 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
| 2042 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
| 2043 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
| 2044 | 2044 | </div> |
| 2045 | 2045 | |
| 2046 | 2046 | <?php } else {?> |
@@ -2048,15 +2048,15 @@ discard block |
||
| 2048 | 2048 | <div class='col-4'> |
| 2049 | 2049 | <div class='input-group'> |
| 2050 | 2050 | |
| 2051 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
| 2051 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
| 2052 | 2052 | <div class='input-group-prepend'> |
| 2053 | 2053 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 2054 | 2054 | </div> |
| 2055 | 2055 | <?php } ?> |
| 2056 | 2056 | |
| 2057 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
| 2057 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
| 2058 | 2058 | |
| 2059 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
| 2059 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
| 2060 | 2060 | <div class='input-group-append'> |
| 2061 | 2061 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 2062 | 2062 | </div> |
@@ -2067,23 +2067,23 @@ discard block |
||
| 2067 | 2067 | <?php } ?> |
| 2068 | 2068 | |
| 2069 | 2069 | </div> |
| 2070 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 2071 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 2070 | + <?php if (!empty($item['description'])) { ?> |
|
| 2071 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 2072 | 2072 | <?php } ?> |
| 2073 | 2073 | </div> |
| 2074 | 2074 | <?php } ?> |
| 2075 | 2075 | |
| 2076 | 2076 | <div class='mt-4 border-top item_totals_total'> |
| 2077 | 2077 | <div class='row p-2'> |
| 2078 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
| 2079 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
| 2078 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
| 2079 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
| 2080 | 2080 | </div> |
| 2081 | 2081 | </div> |
| 2082 | 2082 | </div> |
| 2083 | 2083 | </div> |
| 2084 | 2084 | <?php } ?> |
| 2085 | 2085 | |
| 2086 | - <?php if ( 'select' == $field[ 'items_type' ] ) { ?> |
|
| 2086 | + <?php if ('select' == $field['items_type']) { ?> |
|
| 2087 | 2087 | |
| 2088 | 2088 | <div class="item_totals_type_select"> |
| 2089 | 2089 | |
@@ -2091,17 +2091,17 @@ discard block |
||
| 2091 | 2091 | |
| 2092 | 2092 | $options = array(); |
| 2093 | 2093 | $selected = ''; |
| 2094 | - foreach ( $items as $index => $item ) { |
|
| 2094 | + foreach ($items as $index => $item) { |
|
| 2095 | 2095 | |
| 2096 | - if ( ! empty( $item['required'] ) ) { |
|
| 2096 | + if (!empty($item['required'])) { |
|
| 2097 | 2097 | continue; |
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | - $title = sanitize_text_field( $item['title'] ); |
|
| 2101 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
| 2102 | - $options[ $item['id'] ] = "$title ($price)"; |
|
| 2100 | + $title = sanitize_text_field($item['title']); |
|
| 2101 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
| 2102 | + $options[$item['id']] = "$title ($price)"; |
|
| 2103 | 2103 | |
| 2104 | - if ( ! isset( $selected_item ) ) { |
|
| 2104 | + if (!isset($selected_item)) { |
|
| 2105 | 2105 | $selected = $item['id']; |
| 2106 | 2106 | $selected_item = 1; |
| 2107 | 2107 | } |
@@ -2112,7 +2112,7 @@ discard block |
||
| 2112 | 2112 | array( |
| 2113 | 2113 | 'name' => 'payment-form-items', |
| 2114 | 2114 | 'id' => $id, |
| 2115 | - 'placeholder' => __( 'Select an item', 'invoicing' ), |
|
| 2115 | + 'placeholder' => __('Select an item', 'invoicing'), |
|
| 2116 | 2116 | 'no_wrap' => true, |
| 2117 | 2117 | 'options' => $options, |
| 2118 | 2118 | 'class' => 'wpi_select2 wpinv-items-select-selector', |
@@ -2127,29 +2127,29 @@ discard block |
||
| 2127 | 2127 | |
| 2128 | 2128 | $total = 0; |
| 2129 | 2129 | |
| 2130 | - foreach ( $items as $item ) { |
|
| 2130 | + foreach ($items as $item) { |
|
| 2131 | 2131 | |
| 2132 | 2132 | $class = 'col-8'; |
| 2133 | 2133 | $class2 = ''; |
| 2134 | 2134 | |
| 2135 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
| 2135 | + if (!empty($item['allow_quantities'])) { |
|
| 2136 | 2136 | $class = 'col-6 pt-2'; |
| 2137 | 2137 | $class2 = 'pt-2'; |
| 2138 | 2138 | } |
| 2139 | 2139 | |
| 2140 | - if ( ! empty( $item['custom_price'] ) ) { |
|
| 2140 | + if (!empty($item['custom_price'])) { |
|
| 2141 | 2141 | $class .= ' pt-2'; |
| 2142 | 2142 | } |
| 2143 | 2143 | |
| 2144 | 2144 | $class3 = 'd-none'; |
| 2145 | - $name = ''; |
|
| 2146 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) { |
|
| 2145 | + $name = ''; |
|
| 2146 | + if (!empty($item['required']) || !isset($totals_selected_select_item)) { |
|
| 2147 | 2147 | |
| 2148 | - $total = $total + floatval( $item['price'] ); |
|
| 2148 | + $total = $total + floatval($item['price']); |
|
| 2149 | 2149 | $class3 = ''; |
| 2150 | 2150 | $name = "wpinv-items[{$item['id']}]"; |
| 2151 | 2151 | |
| 2152 | - if ( empty( $item['required'] ) ) { |
|
| 2152 | + if (empty($item['required'])) { |
|
| 2153 | 2153 | $totals_selected_select_item = 1; |
| 2154 | 2154 | } |
| 2155 | 2155 | |
@@ -2161,9 +2161,9 @@ discard block |
||
| 2161 | 2161 | |
| 2162 | 2162 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
| 2163 | 2163 | <div class='row pl-2 pr-2 pt-2'> |
| 2164 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
| 2164 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
| 2165 | 2165 | |
| 2166 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
| 2166 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
| 2167 | 2167 | |
| 2168 | 2168 | <div class='col-2'> |
| 2169 | 2169 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -2171,11 +2171,11 @@ discard block |
||
| 2171 | 2171 | |
| 2172 | 2172 | <?php } else { ?> |
| 2173 | 2173 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
| 2174 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
| 2174 | + <?php } if (empty($item['custom_price'])) { ?> |
|
| 2175 | 2175 | |
| 2176 | 2176 | <div class='col-4 <?php echo $class2; ?>'> |
| 2177 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
| 2178 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
| 2177 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
| 2178 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
| 2179 | 2179 | </div> |
| 2180 | 2180 | |
| 2181 | 2181 | <?php } else {?> |
@@ -2183,15 +2183,15 @@ discard block |
||
| 2183 | 2183 | <div class='col-4'> |
| 2184 | 2184 | <div class='input-group'> |
| 2185 | 2185 | |
| 2186 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
| 2186 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
| 2187 | 2187 | <div class='input-group-prepend'> |
| 2188 | 2188 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 2189 | 2189 | </div> |
| 2190 | 2190 | <?php } ?> |
| 2191 | 2191 | |
| 2192 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
| 2192 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
| 2193 | 2193 | |
| 2194 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
| 2194 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
| 2195 | 2195 | <div class='input-group-append'> |
| 2196 | 2196 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 2197 | 2197 | </div> |
@@ -2202,23 +2202,23 @@ discard block |
||
| 2202 | 2202 | <?php } ?> |
| 2203 | 2203 | |
| 2204 | 2204 | </div> |
| 2205 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 2206 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 2205 | + <?php if (!empty($item['description'])) { ?> |
|
| 2206 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 2207 | 2207 | <?php } ?> |
| 2208 | 2208 | </div> |
| 2209 | 2209 | <?php } ?> |
| 2210 | 2210 | |
| 2211 | 2211 | <div class='mt-4 border-top item_totals_total'> |
| 2212 | 2212 | <div class='row p-2'> |
| 2213 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
| 2214 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
| 2213 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
| 2214 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
| 2215 | 2215 | </div> |
| 2216 | 2216 | </div> |
| 2217 | 2217 | |
| 2218 | 2218 | </div> |
| 2219 | 2219 | <?php } ?> |
| 2220 | 2220 | |
| 2221 | - <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?> |
|
| 2221 | + <?php if ('multi_select' == $field['items_type']) { ?> |
|
| 2222 | 2222 | |
| 2223 | 2223 | <div class="item_totals_type_multi_select"> |
| 2224 | 2224 | |
@@ -2227,18 +2227,18 @@ discard block |
||
| 2227 | 2227 | $options = array(); |
| 2228 | 2228 | $selected = array(); |
| 2229 | 2229 | |
| 2230 | - foreach ( $items as $index => $item ) { |
|
| 2230 | + foreach ($items as $index => $item) { |
|
| 2231 | 2231 | |
| 2232 | - if ( ! empty( $item['required'] ) ) { |
|
| 2232 | + if (!empty($item['required'])) { |
|
| 2233 | 2233 | continue; |
| 2234 | 2234 | } |
| 2235 | 2235 | |
| 2236 | - $title = sanitize_text_field( $item['title'] ); |
|
| 2237 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
| 2238 | - $options[ $item['id'] ] = "$title ($price)"; |
|
| 2236 | + $title = sanitize_text_field($item['title']); |
|
| 2237 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
| 2238 | + $options[$item['id']] = "$title ($price)"; |
|
| 2239 | 2239 | |
| 2240 | - if ( ! isset( $selected_item ) ) { |
|
| 2241 | - $selected = array( $item['id'] ); |
|
| 2240 | + if (!isset($selected_item)) { |
|
| 2241 | + $selected = array($item['id']); |
|
| 2242 | 2242 | $selected_item = 1; |
| 2243 | 2243 | } |
| 2244 | 2244 | |
@@ -2263,29 +2263,29 @@ discard block |
||
| 2263 | 2263 | |
| 2264 | 2264 | $total = 0; |
| 2265 | 2265 | |
| 2266 | - foreach ( $items as $item ) { |
|
| 2266 | + foreach ($items as $item) { |
|
| 2267 | 2267 | |
| 2268 | 2268 | $class = 'col-8'; |
| 2269 | 2269 | $class2 = ''; |
| 2270 | 2270 | |
| 2271 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
| 2271 | + if (!empty($item['allow_quantities'])) { |
|
| 2272 | 2272 | $class = 'col-6 pt-2'; |
| 2273 | 2273 | $class2 = 'pt-2'; |
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | - if ( ! empty( $item['custom_price'] ) ) { |
|
| 2276 | + if (!empty($item['custom_price'])) { |
|
| 2277 | 2277 | $class .= ' pt-2'; |
| 2278 | 2278 | } |
| 2279 | 2279 | |
| 2280 | 2280 | $class3 = 'd-none'; |
| 2281 | - $name = ''; |
|
| 2282 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) { |
|
| 2281 | + $name = ''; |
|
| 2282 | + if (!empty($item['required']) || !isset($totals_selected_select_item)) { |
|
| 2283 | 2283 | |
| 2284 | - $total = $total + floatval( $item['price'] ); |
|
| 2284 | + $total = $total + floatval($item['price']); |
|
| 2285 | 2285 | $class3 = ''; |
| 2286 | 2286 | $name = "wpinv-items[{$item['id']}]"; |
| 2287 | 2287 | |
| 2288 | - if ( empty( $item['required'] ) ) { |
|
| 2288 | + if (empty($item['required'])) { |
|
| 2289 | 2289 | $totals_selected_select_item = 1; |
| 2290 | 2290 | } |
| 2291 | 2291 | |
@@ -2297,9 +2297,9 @@ discard block |
||
| 2297 | 2297 | |
| 2298 | 2298 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
| 2299 | 2299 | <div class='row pl-2 pr-2 pt-2'> |
| 2300 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
| 2300 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
| 2301 | 2301 | |
| 2302 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
| 2302 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
| 2303 | 2303 | |
| 2304 | 2304 | <div class='col-2'> |
| 2305 | 2305 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -2307,11 +2307,11 @@ discard block |
||
| 2307 | 2307 | |
| 2308 | 2308 | <?php } else { ?> |
| 2309 | 2309 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
| 2310 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
| 2310 | + <?php } if (empty($item['custom_price'])) { ?> |
|
| 2311 | 2311 | |
| 2312 | 2312 | <div class='col-4 <?php echo $class2; ?>'> |
| 2313 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
| 2314 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
| 2313 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
| 2314 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
| 2315 | 2315 | </div> |
| 2316 | 2316 | |
| 2317 | 2317 | <?php } else {?> |
@@ -2319,15 +2319,15 @@ discard block |
||
| 2319 | 2319 | <div class='col-4'> |
| 2320 | 2320 | <div class='input-group'> |
| 2321 | 2321 | |
| 2322 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
| 2322 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
| 2323 | 2323 | <div class='input-group-prepend'> |
| 2324 | 2324 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 2325 | 2325 | </div> |
| 2326 | 2326 | <?php } ?> |
| 2327 | 2327 | |
| 2328 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
| 2328 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
| 2329 | 2329 | |
| 2330 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
| 2330 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
| 2331 | 2331 | <div class='input-group-append'> |
| 2332 | 2332 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
| 2333 | 2333 | </div> |
@@ -2338,23 +2338,23 @@ discard block |
||
| 2338 | 2338 | <?php } ?> |
| 2339 | 2339 | |
| 2340 | 2340 | </div> |
| 2341 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 2342 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 2341 | + <?php if (!empty($item['description'])) { ?> |
|
| 2342 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 2343 | 2343 | <?php } ?> |
| 2344 | 2344 | </div> |
| 2345 | 2345 | <?php } ?> |
| 2346 | 2346 | |
| 2347 | 2347 | <div class='mt-4 border-top item_totals_total'> |
| 2348 | 2348 | <div class='row p-2'> |
| 2349 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
| 2350 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
| 2349 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
| 2350 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
| 2351 | 2351 | </div> |
| 2352 | 2352 | </div> |
| 2353 | 2353 | |
| 2354 | 2354 | </div> |
| 2355 | 2355 | <?php } ?> |
| 2356 | - <?php if ( ! empty( $field[ 'description' ] ) ) { ?> |
|
| 2357 | - <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small> |
|
| 2356 | + <?php if (!empty($field['description'])) { ?> |
|
| 2357 | + <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small> |
|
| 2358 | 2358 | <?php } ?> |
| 2359 | 2359 | </div> |
| 2360 | 2360 | <?php |
@@ -2363,20 +2363,20 @@ discard block |
||
| 2363 | 2363 | /** |
| 2364 | 2364 | * Renders the items element template. |
| 2365 | 2365 | */ |
| 2366 | - public function edit_items_template( $field ) { |
|
| 2367 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
| 2368 | - $label = __( 'Let customers...', 'invoicing' ); |
|
| 2369 | - $label2 = __( 'Available Items', 'invoicing' ); |
|
| 2370 | - $label3 = esc_attr__( 'Add some help text for this element', 'invoicing' ); |
|
| 2366 | + public function edit_items_template($field) { |
|
| 2367 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
| 2368 | + $label = __('Let customers...', 'invoicing'); |
|
| 2369 | + $label2 = __('Available Items', 'invoicing'); |
|
| 2370 | + $label3 = esc_attr__('Add some help text for this element', 'invoicing'); |
|
| 2371 | 2371 | $id = $field . '.id + "_edit"'; |
| 2372 | 2372 | $id2 = $field . '.id + "_edit2"'; |
| 2373 | 2373 | $id3 = $field . '.id + "_edit3"'; |
| 2374 | 2374 | $id4 = $field . '.id + "_edit4"'; |
| 2375 | - $label4 = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' ); |
|
| 2376 | - $label5 = esc_attr__( 'Allow users to pay what they want', 'invoicing' ); |
|
| 2377 | - $label6 = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' ); |
|
| 2378 | - $label7 = esc_attr__( 'Allow users to buy several quantities', 'invoicing' ); |
|
| 2379 | - $label8 = esc_attr__( 'This item is required', 'invoicing' ); |
|
| 2375 | + $label4 = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing'); |
|
| 2376 | + $label5 = esc_attr__('Allow users to pay what they want', 'invoicing'); |
|
| 2377 | + $label6 = esc_attr__('Enter the minimum price that a user can pay', 'invoicing'); |
|
| 2378 | + $label7 = esc_attr__('Allow users to buy several quantities', 'invoicing'); |
|
| 2379 | + $label8 = esc_attr__('This item is required', 'invoicing'); |
|
| 2380 | 2380 | echo "<div $restrict> |
| 2381 | 2381 | |
| 2382 | 2382 | <label>$label2</label> |
@@ -2446,7 +2446,7 @@ discard block |
||
| 2446 | 2446 | <div class='form-group mt-2'> |
| 2447 | 2447 | |
| 2448 | 2448 | <select class='form-control custom-select' v-model='selected_item'> |
| 2449 | - <option value=''>" . __( 'Add an existing item to the form', 'invoicing' ) ."</option> |
|
| 2449 | + <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option> |
|
| 2450 | 2450 | <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
| 2451 | 2451 | </select> |
| 2452 | 2452 | |
@@ -2461,11 +2461,11 @@ discard block |
||
| 2461 | 2461 | <label :for='$id2'>$label</label> |
| 2462 | 2462 | |
| 2463 | 2463 | <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'> |
| 2464 | - <option value='total'>" . __( 'Buy all items on the list', 'invoicing' ) ."</option> |
|
| 2465 | - <option value='radio'>" . __( 'Select a single item from the list', 'invoicing' ) ."</option> |
|
| 2466 | - <option value='checkbox'>" . __( 'Select one or more items on the list', 'invoicing' ) ."</option> |
|
| 2467 | - <option value='select'>" . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option> |
|
| 2468 | - <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option> |
|
| 2464 | + <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option> |
|
| 2465 | + <option value='radio'>" . __('Select a single item from the list', 'invoicing') . "</option> |
|
| 2466 | + <option value='checkbox'>" . __('Select one or more items on the list', 'invoicing') . "</option> |
|
| 2467 | + <option value='select'>" . __('Select a single item from a dropdown', 'invoicing') . "</option> |
|
| 2468 | + <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option> |
|
| 2469 | 2469 | </select> |
| 2470 | 2470 | |
| 2471 | 2471 | </div> |
@@ -2490,27 +2490,27 @@ discard block |
||
| 2490 | 2490 | 'orderby' => 'title', |
| 2491 | 2491 | 'order' => 'ASC', |
| 2492 | 2492 | 'posts_per_page' => -1, |
| 2493 | - 'post_status' => array( 'publish' ), |
|
| 2493 | + 'post_status' => array('publish'), |
|
| 2494 | 2494 | ); |
| 2495 | 2495 | |
| 2496 | - $items = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) ); |
|
| 2496 | + $items = get_posts(apply_filters('wpinv_item_dropdown_query_args', $item_args)); |
|
| 2497 | 2497 | |
| 2498 | - if ( empty( $items ) ) { |
|
| 2498 | + if (empty($items)) { |
|
| 2499 | 2499 | return array(); |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 2502 | - $options = array(); |
|
| 2503 | - foreach ( $items as $item ) { |
|
| 2504 | - $title = esc_html( $item->post_title ); |
|
| 2505 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 2506 | - $id = absint( $item->ID ); |
|
| 2507 | - $price = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) ); |
|
| 2508 | - $recurring = (bool) get_post_meta( $id, '_wpinv_is_recurring', true ); |
|
| 2502 | + $options = array(); |
|
| 2503 | + foreach ($items as $item) { |
|
| 2504 | + $title = esc_html($item->post_title); |
|
| 2505 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 2506 | + $id = absint($item->ID); |
|
| 2507 | + $price = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true)); |
|
| 2508 | + $recurring = (bool) get_post_meta($id, '_wpinv_is_recurring', true); |
|
| 2509 | 2509 | $description = $item->post_excerpt; |
| 2510 | - $custom_price = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true ); |
|
| 2511 | - $minimum_price = (float) get_post_meta( $id, '_minimum_price', true ); |
|
| 2510 | + $custom_price = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true); |
|
| 2511 | + $minimum_price = (float) get_post_meta($id, '_minimum_price', true); |
|
| 2512 | 2512 | $allow_quantities = false; |
| 2513 | - $options[] = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' ); |
|
| 2513 | + $options[] = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities'); |
|
| 2514 | 2514 | |
| 2515 | 2515 | } |
| 2516 | 2516 | return $options; |
@@ -2520,38 +2520,38 @@ discard block |
||
| 2520 | 2520 | /** |
| 2521 | 2521 | * Returns an array of items for the currently being edited form. |
| 2522 | 2522 | */ |
| 2523 | - public function get_form_items( $id = false ) { |
|
| 2523 | + public function get_form_items($id = false) { |
|
| 2524 | 2524 | |
| 2525 | - if ( empty( $id ) ) { |
|
| 2526 | - return wpinv_get_data( 'sample-payment-form-items' ); |
|
| 2525 | + if (empty($id)) { |
|
| 2526 | + return wpinv_get_data('sample-payment-form-items'); |
|
| 2527 | 2527 | } |
| 2528 | 2528 | |
| 2529 | - $form_elements = get_post_meta( $id, 'wpinv_form_items', true ); |
|
| 2529 | + $form_elements = get_post_meta($id, 'wpinv_form_items', true); |
|
| 2530 | 2530 | |
| 2531 | - if ( is_array( $form_elements ) ) { |
|
| 2531 | + if (is_array($form_elements)) { |
|
| 2532 | 2532 | return $form_elements; |
| 2533 | 2533 | } |
| 2534 | 2534 | |
| 2535 | - return wpinv_get_data( 'sample-payment-form-items' ); |
|
| 2535 | + return wpinv_get_data('sample-payment-form-items'); |
|
| 2536 | 2536 | |
| 2537 | 2537 | } |
| 2538 | 2538 | |
| 2539 | 2539 | /** |
| 2540 | 2540 | * Returns an array of elements for the currently being edited form. |
| 2541 | 2541 | */ |
| 2542 | - public function get_form_elements( $id = false ) { |
|
| 2542 | + public function get_form_elements($id = false) { |
|
| 2543 | 2543 | |
| 2544 | - if ( empty( $id ) ) { |
|
| 2545 | - return wpinv_get_data( 'sample-payment-form' ); |
|
| 2544 | + if (empty($id)) { |
|
| 2545 | + return wpinv_get_data('sample-payment-form'); |
|
| 2546 | 2546 | } |
| 2547 | 2547 | |
| 2548 | - $form_elements = get_post_meta( $id, 'wpinv_form_elements', true ); |
|
| 2548 | + $form_elements = get_post_meta($id, 'wpinv_form_elements', true); |
|
| 2549 | 2549 | |
| 2550 | - if ( is_array( $form_elements ) ) { |
|
| 2550 | + if (is_array($form_elements)) { |
|
| 2551 | 2551 | return $form_elements; |
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | - return wpinv_get_data( 'sample-payment-form' ); |
|
| 2554 | + return wpinv_get_data('sample-payment-form'); |
|
| 2555 | 2555 | } |
| 2556 | 2556 | |
| 2557 | 2557 | } |
@@ -7,28 +7,28 @@ 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 | class WPInv_Ajax { |
| 15 | 15 | public static function init() { |
| 16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
| 17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
| 16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
| 17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
| 18 | 18 | self::add_ajax_events(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public static function define_ajax() { |
| 22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
| 23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
| 24 | - define( 'DOING_AJAX', true ); |
|
| 22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 23 | + if (!defined('DOING_AJAX')) { |
|
| 24 | + define('DOING_AJAX', true); |
|
| 25 | 25 | } |
| 26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
| 27 | - define( 'WC_DOING_AJAX', true ); |
|
| 26 | + if (!defined('WC_DOING_AJAX')) { |
|
| 27 | + define('WC_DOING_AJAX', true); |
|
| 28 | 28 | } |
| 29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
| 30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
| 31 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
| 30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
| 31 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
| 32 | 32 | } |
| 33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
| 34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
| 37 | 37 | public static function do_wpinv_ajax() { |
| 38 | 38 | global $wp_query; |
| 39 | 39 | |
| 40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
| 41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
| 40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
| 44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
| 45 | 45 | self::wpinv_ajax_headers(); |
| 46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
| 46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
| 47 | 47 | die(); |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | private static function wpinv_ajax_headers() { |
| 52 | 52 | send_origin_headers(); |
| 53 | - /** @scrutinizer ignore-unhandled */ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 54 | - /** @scrutinizer ignore-unhandled */ @header( 'X-Robots-Tag: noindex' ); |
|
| 53 | + /** @scrutinizer ignore-unhandled */ @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
| 54 | + /** @scrutinizer ignore-unhandled */ @header('X-Robots-Tag: noindex'); |
|
| 55 | 55 | send_nosniff_header(); |
| 56 | 56 | nocache_headers(); |
| 57 | - status_header( 200 ); |
|
| 57 | + status_header(200); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function add_ajax_events() { |
@@ -78,39 +78,39 @@ discard block |
||
| 78 | 78 | 'buy_items' => true, |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
| 82 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 81 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
| 82 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 83 | 83 | |
| 84 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
| 85 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
| 84 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
| 85 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( $nopriv ) { |
|
| 89 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 88 | + if ($nopriv) { |
|
| 89 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 90 | 90 | |
| 91 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 91 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public static function add_note() { |
| 97 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
| 97 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
| 98 | 98 | |
| 99 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 99 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 100 | 100 | die(-1); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $post_id = absint( $_POST['post_id'] ); |
|
| 104 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
| 105 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
| 103 | + $post_id = absint($_POST['post_id']); |
|
| 104 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
| 105 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
| 106 | 106 | |
| 107 | 107 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
| 108 | 108 | |
| 109 | - if ( $post_id > 0 ) { |
|
| 110 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
| 109 | + if ($post_id > 0) { |
|
| 110 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
| 111 | 111 | |
| 112 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
| 113 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
| 112 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
| 113 | + wpinv_get_invoice_note_line_item($note_id); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public static function delete_note() { |
| 121 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
| 121 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
| 122 | 122 | |
| 123 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 123 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 124 | 124 | die(-1); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $note_id = (int)$_POST['note_id']; |
|
| 127 | + $note_id = (int) $_POST['note_id']; |
|
| 128 | 128 | |
| 129 | - if ( $note_id > 0 ) { |
|
| 130 | - wp_delete_comment( $note_id, true ); |
|
| 129 | + if ($note_id > 0) { |
|
| 130 | + wp_delete_comment($note_id, true); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | die(); |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public static function checkout() { |
| 143 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
| 144 | - define( 'WPINV_CHECKOUT', true ); |
|
| 143 | + if (!defined('WPINV_CHECKOUT')) { |
|
| 144 | + define('WPINV_CHECKOUT', true); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | wpinv_process_checkout(); |
@@ -150,53 +150,53 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | public static function add_invoice_item() { |
| 152 | 152 | global $wpi_userID, $wpinv_ip_address_country; |
| 153 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
| 154 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 153 | + check_ajax_referer('invoice-item', '_nonce'); |
|
| 154 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 155 | 155 | die(-1); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
| 159 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 158 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
| 159 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 160 | 160 | |
| 161 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
| 161 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
| 162 | 162 | die(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 166 | - if ( empty( $invoice ) ) { |
|
| 165 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 166 | + if (empty($invoice)) { |
|
| 167 | 167 | die(); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 170 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 171 | 171 | die(); // Don't allow modify items for paid invoice. |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( !empty( $_POST['user_id'] ) ) { |
|
| 175 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
| 174 | + if (!empty($_POST['user_id'])) { |
|
| 175 | + $wpi_userID = absint($_POST['user_id']); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $item = new WPInv_Item( $item_id ); |
|
| 179 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
| 178 | + $item = new WPInv_Item($item_id); |
|
| 179 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
| 180 | 180 | die(); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Validate item before adding to invoice because recurring item must be paid individually. |
| 184 | - if ( !empty( $invoice->cart_details ) ) { |
|
| 184 | + if (!empty($invoice->cart_details)) { |
|
| 185 | 185 | $valid = true; |
| 186 | 186 | |
| 187 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
| 188 | - if ( $recurring_item != $item_id ) { |
|
| 187 | + if ($recurring_item = $invoice->get_recurring()) { |
|
| 188 | + if ($recurring_item != $item_id) { |
|
| 189 | 189 | $valid = false; |
| 190 | 190 | } |
| 191 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
| 191 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
| 192 | 192 | $valid = false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( !$valid ) { |
|
| 195 | + if (!$valid) { |
|
| 196 | 196 | $response = array(); |
| 197 | 197 | $response['success'] = false; |
| 198 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
| 199 | - wp_send_json( $response ); |
|
| 198 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
| 199 | + wp_send_json($response); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
@@ -204,11 +204,11 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $data = array(); |
| 206 | 206 | $data['invoice_id'] = $invoice_id; |
| 207 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 207 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 208 | 208 | |
| 209 | - wpinv_set_checkout_session( $data ); |
|
| 209 | + wpinv_set_checkout_session($data); |
|
| 210 | 210 | |
| 211 | - $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
|
| 211 | + $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1; |
|
| 212 | 212 | |
| 213 | 213 | $args = array( |
| 214 | 214 | 'id' => $item_id, |
@@ -221,21 +221,21 @@ discard block |
||
| 221 | 221 | 'fees' => array() |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - $invoice->add_item( $item_id, $args ); |
|
| 224 | + $invoice->add_item($item_id, $args); |
|
| 225 | 225 | $invoice->save(); |
| 226 | 226 | |
| 227 | - if ( empty( $_POST['country'] ) ) { |
|
| 227 | + if (empty($_POST['country'])) { |
|
| 228 | 228 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 229 | 229 | } |
| 230 | - if ( empty( $_POST['state'] ) ) { |
|
| 230 | + if (empty($_POST['state'])) { |
|
| 231 | 231 | $_POST['state'] = $invoice->state; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
| 235 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
| 234 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
| 235 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
| 236 | 236 | |
| 237 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 238 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 237 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 238 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 239 | 239 | |
| 240 | 240 | $wpinv_ip_address_country = $invoice->country; |
| 241 | 241 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $response = array(); |
| 245 | 245 | $response['success'] = true; |
| 246 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
| 246 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
| 247 | 247 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 248 | 248 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
| 249 | 249 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -255,41 +255,41 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | wpinv_set_checkout_session($checkout_session); |
| 257 | 257 | |
| 258 | - wp_send_json( $response ); |
|
| 258 | + wp_send_json($response); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | public static function remove_invoice_item() { |
| 263 | 263 | global $wpi_userID, $wpinv_ip_address_country; |
| 264 | 264 | |
| 265 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
| 266 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 265 | + check_ajax_referer('invoice-item', '_nonce'); |
|
| 266 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 267 | 267 | die(-1); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
| 271 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 272 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
| 270 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
| 271 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 272 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
| 273 | 273 | |
| 274 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
| 274 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
| 275 | 275 | die(); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 279 | - if ( empty( $invoice ) ) { |
|
| 278 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 279 | + if (empty($invoice)) { |
|
| 280 | 280 | die(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 283 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 284 | 284 | die(); // Don't allow modify items for paid invoice. |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if ( !empty( $_POST['user_id'] ) ) { |
|
| 288 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
| 287 | + if (!empty($_POST['user_id'])) { |
|
| 288 | + $wpi_userID = absint($_POST['user_id']); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $item = new WPInv_Item( $item_id ); |
|
| 292 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
| 291 | + $item = new WPInv_Item($item_id); |
|
| 292 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
| 293 | 293 | die(); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | $data = array(); |
| 299 | 299 | $data['invoice_id'] = $invoice_id; |
| 300 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 300 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 301 | 301 | |
| 302 | - wpinv_set_checkout_session( $data ); |
|
| 302 | + wpinv_set_checkout_session($data); |
|
| 303 | 303 | |
| 304 | 304 | $args = array( |
| 305 | 305 | 'id' => $item_id, |
@@ -307,21 +307,21 @@ discard block |
||
| 307 | 307 | 'cart_index' => $cart_index |
| 308 | 308 | ); |
| 309 | 309 | |
| 310 | - $invoice->remove_item( $item_id, $args ); |
|
| 310 | + $invoice->remove_item($item_id, $args); |
|
| 311 | 311 | $invoice->save(); |
| 312 | 312 | |
| 313 | - if ( empty( $_POST['country'] ) ) { |
|
| 313 | + if (empty($_POST['country'])) { |
|
| 314 | 314 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 315 | 315 | } |
| 316 | - if ( empty( $_POST['state'] ) ) { |
|
| 316 | + if (empty($_POST['state'])) { |
|
| 317 | 317 | $_POST['state'] = $invoice->state; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
| 321 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
| 320 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
| 321 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
| 322 | 322 | |
| 323 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 324 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 323 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 324 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 325 | 325 | |
| 326 | 326 | $wpinv_ip_address_country = $invoice->country; |
| 327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | $response = array(); |
| 331 | 331 | $response['success'] = true; |
| 332 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
| 332 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
| 333 | 333 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 334 | 334 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
| 335 | 335 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -341,55 +341,55 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | wpinv_set_checkout_session($checkout_session); |
| 343 | 343 | |
| 344 | - wp_send_json( $response ); |
|
| 344 | + wp_send_json($response); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | public static function create_invoice_item() { |
| 348 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
| 349 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 348 | + check_ajax_referer('invoice-item', '_nonce'); |
|
| 349 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 350 | 350 | die(-1); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 353 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 354 | 354 | |
| 355 | 355 | // Find the item |
| 356 | - if ( !is_numeric( $invoice_id ) ) { |
|
| 356 | + if (!is_numeric($invoice_id)) { |
|
| 357 | 357 | die(); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 361 | - if ( empty( $invoice ) ) { |
|
| 360 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 361 | + if (empty($invoice)) { |
|
| 362 | 362 | die(); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Validate item before adding to invoice because recurring item must be paid individually. |
| 366 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
| 366 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
| 367 | 367 | $response = array(); |
| 368 | 368 | $response['success'] = false; |
| 369 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
| 370 | - wp_send_json( $response ); |
|
| 369 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
| 370 | + wp_send_json($response); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - $save_item = wp_unslash( $_POST['_wpinv_quick'] ); |
|
| 373 | + $save_item = wp_unslash($_POST['_wpinv_quick']); |
|
| 374 | 374 | |
| 375 | 375 | $meta = array(); |
| 376 | 376 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
| 377 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
| 377 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
| 378 | 378 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
| 379 | 379 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
| 380 | 380 | |
| 381 | 381 | $data = array(); |
| 382 | 382 | $data['post_title'] = sanitize_text_field($save_item['name']); |
| 383 | 383 | $data['post_status'] = 'publish'; |
| 384 | - $data['post_excerpt'] = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : ''; |
|
| 384 | + $data['post_excerpt'] = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : ''; |
|
| 385 | 385 | $data['meta'] = $meta; |
| 386 | 386 | |
| 387 | 387 | $item = new WPInv_Item(); |
| 388 | - $item->create( $data ); |
|
| 388 | + $item->create($data); |
|
| 389 | 389 | |
| 390 | - if ( !empty( $item ) ) { |
|
| 390 | + if (!empty($item)) { |
|
| 391 | 391 | $_POST['item_id'] = $item->ID; |
| 392 | - $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
|
| 392 | + $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1; |
|
| 393 | 393 | |
| 394 | 394 | self::add_invoice_item(); |
| 395 | 395 | } |
@@ -397,15 +397,15 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | public static function get_billing_details() { |
| 400 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
| 400 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
| 401 | 401 | |
| 402 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 402 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 403 | 403 | die(-1); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $user_id = (int)$_POST['user_id']; |
|
| 406 | + $user_id = (int) $_POST['user_id']; |
|
| 407 | 407 | $billing_details = wpinv_get_user_address($user_id); |
| 408 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
| 408 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
| 409 | 409 | |
| 410 | 410 | if (isset($billing_details['user_id'])) { |
| 411 | 411 | unset($billing_details['user_id']); |
@@ -419,20 +419,20 @@ discard block |
||
| 419 | 419 | $response['success'] = true; |
| 420 | 420 | $response['data']['billing_details'] = $billing_details; |
| 421 | 421 | |
| 422 | - wp_send_json( $response ); |
|
| 422 | + wp_send_json($response); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | public static function admin_recalculate_totals() { |
| 426 | 426 | global $wpi_userID, $wpinv_ip_address_country; |
| 427 | 427 | |
| 428 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 429 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 428 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 429 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 430 | 430 | die(-1); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 434 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 435 | - if ( empty( $invoice ) ) { |
|
| 433 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 434 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 435 | + if (empty($invoice)) { |
|
| 436 | 436 | die(); |
| 437 | 437 | } |
| 438 | 438 | |
@@ -440,29 +440,29 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | $data = array(); |
| 442 | 442 | $data['invoice_id'] = $invoice_id; |
| 443 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 443 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 444 | 444 | |
| 445 | - wpinv_set_checkout_session( $data ); |
|
| 445 | + wpinv_set_checkout_session($data); |
|
| 446 | 446 | |
| 447 | - if ( !empty( $_POST['user_id'] ) ) { |
|
| 448 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
| 447 | + if (!empty($_POST['user_id'])) { |
|
| 448 | + $wpi_userID = absint($_POST['user_id']); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - if ( empty( $_POST['country'] ) ) { |
|
| 451 | + if (empty($_POST['country'])) { |
|
| 452 | 452 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | $disable_taxes = 0; |
| 456 | - if ( ! empty( $_POST['disable_taxes'] ) ) { |
|
| 456 | + if (!empty($_POST['disable_taxes'])) { |
|
| 457 | 457 | $disable_taxes = 1; |
| 458 | 458 | } |
| 459 | - $invoice->set( 'disable_taxes', $disable_taxes ); |
|
| 459 | + $invoice->set('disable_taxes', $disable_taxes); |
|
| 460 | 460 | |
| 461 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
| 462 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 463 | - if ( isset( $_POST['state'] ) ) { |
|
| 464 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
| 465 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 461 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
| 462 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 463 | + if (isset($_POST['state'])) { |
|
| 464 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
| 465 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | $wpinv_ip_address_country = $invoice->country; |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | $response = array(); |
| 473 | 473 | $response['success'] = true; |
| 474 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
| 474 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
| 475 | 475 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 476 | 476 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
| 477 | 477 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -483,25 +483,25 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | wpinv_set_checkout_session($checkout_session); |
| 485 | 485 | |
| 486 | - wp_send_json( $response ); |
|
| 486 | + wp_send_json($response); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | public static function admin_apply_discount() { |
| 490 | 490 | global $wpi_userID; |
| 491 | 491 | |
| 492 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 493 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 492 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 493 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 494 | 494 | die(-1); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 498 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 499 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
| 497 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 498 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 499 | + if (empty($invoice_id) || empty($discount_code)) { |
|
| 500 | 500 | die(); |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 504 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
| 503 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 504 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
| 505 | 505 | die(); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -509,49 +509,49 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | $data = array(); |
| 511 | 511 | $data['invoice_id'] = $invoice_id; |
| 512 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 512 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 513 | 513 | |
| 514 | - wpinv_set_checkout_session( $data ); |
|
| 514 | + wpinv_set_checkout_session($data); |
|
| 515 | 515 | |
| 516 | 516 | $response = array(); |
| 517 | 517 | $response['success'] = false; |
| 518 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
| 518 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
| 519 | 519 | $response['data']['code'] = $discount_code; |
| 520 | 520 | |
| 521 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
| 522 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
| 521 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
| 522 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
| 523 | 523 | |
| 524 | 524 | $response['success'] = true; |
| 525 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
| 526 | - } else { |
|
| 525 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
| 526 | + } else { |
|
| 527 | 527 | $errors = wpinv_get_errors(); |
| 528 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
| 528 | + if (!empty($errors['wpinv-discount-error'])) { |
|
| 529 | 529 | $response['msg'] = $errors['wpinv-discount-error']; |
| 530 | 530 | } |
| 531 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
| 531 | + wpinv_unset_error('wpinv-discount-error'); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | wpinv_set_checkout_session($checkout_session); |
| 535 | 535 | |
| 536 | - wp_send_json( $response ); |
|
| 536 | + wp_send_json($response); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | public static function admin_remove_discount() { |
| 540 | 540 | global $wpi_userID; |
| 541 | 541 | |
| 542 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 543 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 542 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 543 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 544 | 544 | die(-1); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 548 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 549 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
| 547 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 548 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 549 | + if (empty($invoice_id) || empty($discount_code)) { |
|
| 550 | 550 | die(); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 554 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
| 553 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 554 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
| 555 | 555 | die(); |
| 556 | 556 | } |
| 557 | 557 | |
@@ -559,38 +559,38 @@ discard block |
||
| 559 | 559 | |
| 560 | 560 | $data = array(); |
| 561 | 561 | $data['invoice_id'] = $invoice_id; |
| 562 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 562 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 563 | 563 | |
| 564 | - wpinv_set_checkout_session( $data ); |
|
| 564 | + wpinv_set_checkout_session($data); |
|
| 565 | 565 | |
| 566 | 566 | $response = array(); |
| 567 | 567 | $response['success'] = false; |
| 568 | 568 | $response['msg'] = NULL; |
| 569 | 569 | |
| 570 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
| 570 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
| 571 | 571 | $response['success'] = true; |
| 572 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
| 572 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
| 573 | 573 | |
| 574 | 574 | wpinv_set_checkout_session($checkout_session); |
| 575 | 575 | |
| 576 | - wp_send_json( $response ); |
|
| 576 | + wp_send_json($response); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | public static function check_email() { |
| 580 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 581 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 580 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 581 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 582 | 582 | die(-1); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $email = sanitize_text_field( $_POST['email'] ); |
|
| 585 | + $email = sanitize_text_field($_POST['email']); |
|
| 586 | 586 | |
| 587 | 587 | $response = array(); |
| 588 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
| 588 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
| 589 | 589 | $user_id = $user_data->ID; |
| 590 | 590 | $user_login = $user_data->user_login; |
| 591 | 591 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
| 592 | 592 | $billing_details = wpinv_get_user_address($user_id); |
| 593 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
| 593 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
| 594 | 594 | |
| 595 | 595 | if (isset($billing_details['user_id'])) { |
| 596 | 596 | unset($billing_details['user_id']); |
@@ -606,54 +606,54 @@ discard block |
||
| 606 | 606 | $response['data']['billing_details'] = $billing_details; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - wp_send_json( $response ); |
|
| 609 | + wp_send_json($response); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | public static function run_tool() { |
| 613 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 614 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 613 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 614 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 615 | 615 | die(-1); |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
| 618 | + $tool = sanitize_text_field($_POST['tool']); |
|
| 619 | 619 | |
| 620 | - do_action( 'wpinv_run_tool' ); |
|
| 620 | + do_action('wpinv_run_tool'); |
|
| 621 | 621 | |
| 622 | - if ( !empty( $tool ) ) { |
|
| 623 | - do_action( 'wpinv_tool_' . $tool ); |
|
| 622 | + if (!empty($tool)) { |
|
| 623 | + do_action('wpinv_tool_' . $tool); |
|
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | public static function apply_discount() { |
| 628 | 628 | global $wpi_userID; |
| 629 | 629 | |
| 630 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 630 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 631 | 631 | |
| 632 | 632 | $response = array(); |
| 633 | 633 | |
| 634 | - if ( isset( $_POST['code'] ) ) { |
|
| 635 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 634 | + if (isset($_POST['code'])) { |
|
| 635 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 636 | 636 | |
| 637 | 637 | $response['success'] = false; |
| 638 | 638 | $response['msg'] = ''; |
| 639 | 639 | $response['data']['code'] = $discount_code; |
| 640 | 640 | |
| 641 | 641 | $invoice = wpinv_get_invoice_cart(); |
| 642 | - if ( empty( $invoice->ID ) ) { |
|
| 643 | - $response['msg'] = __( 'Invalid checkout request.', 'invoicing' ); |
|
| 644 | - wp_send_json( $response ); |
|
| 642 | + if (empty($invoice->ID)) { |
|
| 643 | + $response['msg'] = __('Invalid checkout request.', 'invoicing'); |
|
| 644 | + wp_send_json($response); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | $wpi_userID = $invoice->get_user_id(); |
| 648 | 648 | |
| 649 | - if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) { |
|
| 650 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
| 651 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
| 652 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
| 653 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
| 654 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
| 649 | + if (wpinv_is_discount_valid($discount_code, $wpi_userID)) { |
|
| 650 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
| 651 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
| 652 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
| 653 | + $total = wpinv_get_cart_total(null, $discounts); |
|
| 654 | + $cart_totals = wpinv_recalculate_tax(true); |
|
| 655 | 655 | |
| 656 | - if ( !empty( $cart_totals ) ) { |
|
| 656 | + if (!empty($cart_totals)) { |
|
| 657 | 657 | $response['success'] = true; |
| 658 | 658 | $response['data'] = $cart_totals; |
| 659 | 659 | $response['data']['code'] = $discount_code; |
@@ -662,29 +662,29 @@ discard block |
||
| 662 | 662 | } |
| 663 | 663 | } else { |
| 664 | 664 | $errors = wpinv_get_errors(); |
| 665 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
| 666 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
| 665 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
| 666 | + wpinv_unset_error('wpinv-discount-error'); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | // Allow for custom discount code handling |
| 670 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
| 670 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - wp_send_json( $response ); |
|
| 673 | + wp_send_json($response); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | public static function remove_discount() { |
| 677 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 677 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 678 | 678 | |
| 679 | 679 | $response = array(); |
| 680 | 680 | |
| 681 | - if ( isset( $_POST['code'] ) ) { |
|
| 682 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 683 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
| 684 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
| 685 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
| 681 | + if (isset($_POST['code'])) { |
|
| 682 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 683 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
| 684 | + $total = wpinv_get_cart_total(null, $discounts); |
|
| 685 | + $cart_totals = wpinv_recalculate_tax(true); |
|
| 686 | 686 | |
| 687 | - if ( !empty( $cart_totals ) ) { |
|
| 687 | + if (!empty($cart_totals)) { |
|
| 688 | 688 | $response['success'] = true; |
| 689 | 689 | $response['data'] = $cart_totals; |
| 690 | 690 | $response['data']['code'] = $discount_code; |
@@ -693,10 +693,10 @@ discard block |
||
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | // Allow for custom discount code handling |
| 696 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
| 696 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - wp_send_json( $response ); |
|
| 699 | + wp_send_json($response); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -708,75 +708,75 @@ discard block |
||
| 708 | 708 | global $invoicing, $wpi_checkout_id, $cart_total; |
| 709 | 709 | |
| 710 | 710 | // Check nonce. |
| 711 | - if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) { |
|
| 712 | - wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) ); |
|
| 711 | + if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) { |
|
| 712 | + wp_send_json_error(__('Security checks failed.', 'invoicing')); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | // Prepare submitted data... |
| 716 | - $data = wp_unslash( $_POST ); |
|
| 716 | + $data = wp_unslash($_POST); |
|
| 717 | 717 | |
| 718 | 718 | // ... form fields... |
| 719 | - if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) { |
|
| 720 | - wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) ); |
|
| 719 | + if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) { |
|
| 720 | + wp_send_json_error(__('This payment form is no longer active.', 'invoicing')); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) { |
|
| 724 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
| 723 | + if (empty($data['billing_email']) || !is_email($data['billing_email'])) { |
|
| 724 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | $prepared = array( |
| 728 | - 'billing_email' => sanitize_email( $data['billing_email'] ), |
|
| 729 | - __( 'Billing Email', 'invoicing' ) => sanitize_email( $data['billing_email'] ), |
|
| 730 | - __( 'Form Id', 'invoicing' ) => absint( $data['form_id'] ), |
|
| 728 | + 'billing_email' => sanitize_email($data['billing_email']), |
|
| 729 | + __('Billing Email', 'invoicing') => sanitize_email($data['billing_email']), |
|
| 730 | + __('Form Id', 'invoicing') => absint($data['form_id']), |
|
| 731 | 731 | ); |
| 732 | 732 | |
| 733 | - $prepared['billing_email'] = sanitize_email( $data['billing_email'] ); |
|
| 733 | + $prepared['billing_email'] = sanitize_email($data['billing_email']); |
|
| 734 | 734 | |
| 735 | - $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] ); |
|
| 735 | + $fields = $invoicing->form_elements->get_form_elements($data['form_id']); |
|
| 736 | 736 | |
| 737 | 737 | // ... and form items. |
| 738 | - $items = $invoicing->form_elements->get_form_items( $data['form_id'] ); |
|
| 738 | + $items = $invoicing->form_elements->get_form_items($data['form_id']); |
|
| 739 | 739 | $prepared_items = array(); |
| 740 | 740 | $address_fields = array(); |
| 741 | 741 | |
| 742 | - if ( ! empty( $data['wpinv-items'] ) ) { |
|
| 742 | + if (!empty($data['wpinv-items'])) { |
|
| 743 | 743 | |
| 744 | - $selected_items = wpinv_clean( $data['wpinv-items'] ); |
|
| 744 | + $selected_items = wpinv_clean($data['wpinv-items']); |
|
| 745 | 745 | |
| 746 | - foreach ( $items as $item ) { |
|
| 746 | + foreach ($items as $item) { |
|
| 747 | 747 | |
| 748 | - if ( ! empty( $item['required'] ) && ! isset( $selected_items[ $item['id'] ] ) ) { |
|
| 749 | - wp_send_json_error( __( 'A required item is missing.', 'invoicing' ) ); |
|
| 748 | + if (!empty($item['required']) && !isset($selected_items[$item['id']])) { |
|
| 749 | + wp_send_json_error(__('A required item is missing.', 'invoicing')); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if ( ! isset( $selected_items[ $item['id'] ] ) ) { |
|
| 752 | + if (!isset($selected_items[$item['id']])) { |
|
| 753 | 753 | continue; |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | $quantity = 1; |
| 757 | 757 | |
| 758 | - if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) { |
|
| 758 | + if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) { |
|
| 759 | 759 | |
| 760 | - $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] ); |
|
| 760 | + $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]); |
|
| 761 | 761 | |
| 762 | - if ( empty( $quantity ) ) { |
|
| 762 | + if (empty($quantity)) { |
|
| 763 | 763 | $quantity = 1; |
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | // Custom pricing. |
| 768 | - if ( ! empty( $item['custom_price'] ) ) { |
|
| 768 | + if (!empty($item['custom_price'])) { |
|
| 769 | 769 | |
| 770 | - $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] ); |
|
| 771 | - $set_price = wpinv_sanitize_amount( $selected_items[ $item['id'] ] ); |
|
| 770 | + $minimum_price = wpinv_sanitize_amount($item['minimum_price']); |
|
| 771 | + $set_price = wpinv_sanitize_amount($selected_items[$item['id']]); |
|
| 772 | 772 | |
| 773 | - if ( $set_price < $minimum_price ) { |
|
| 774 | - wp_send_json_error( __( 'The provided amount is less than the minimum allowed value.', 'invoicing' ) ); |
|
| 773 | + if ($set_price < $minimum_price) { |
|
| 774 | + wp_send_json_error(__('The provided amount is less than the minimum allowed value.', 'invoicing')); |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | $prepared_items[] = array( |
| 778 | 778 | 'id' =>$item['id'], |
| 779 | - 'item_price' => wpinv_sanitize_amount( $item['price'] ), |
|
| 779 | + 'item_price' => wpinv_sanitize_amount($item['price']), |
|
| 780 | 780 | 'custom_price' => $set_price, |
| 781 | 781 | 'name' => $item['title'], |
| 782 | 782 | 'quantity' => $quantity, |
@@ -786,8 +786,8 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $prepared_items[] = array( |
| 788 | 788 | 'id' => $item['id'], |
| 789 | - 'item_price' => wpinv_sanitize_amount( $item['price'] ), |
|
| 790 | - 'custom_price' => wpinv_sanitize_amount( $item['price'] ), |
|
| 789 | + 'item_price' => wpinv_sanitize_amount($item['price']), |
|
| 790 | + 'custom_price' => wpinv_sanitize_amount($item['price']), |
|
| 791 | 791 | 'name' => $item['title'], |
| 792 | 792 | 'quantity' => $quantity, |
| 793 | 793 | ); |
@@ -798,64 +798,64 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | } else { |
| 800 | 800 | |
| 801 | - wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) ); |
|
| 801 | + wp_send_json_error(__('You have not selected any items.', 'invoicing')); |
|
| 802 | 802 | |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | // Are all required fields provided? |
| 806 | - foreach ( $fields as $field ) { |
|
| 806 | + foreach ($fields as $field) { |
|
| 807 | 807 | |
| 808 | - if ( ! empty( $field['premade'] ) ) { |
|
| 808 | + if (!empty($field['premade'])) { |
|
| 809 | 809 | continue; |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) { |
|
| 813 | - wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) ); |
|
| 812 | + if (!empty($field['required']) && empty($data[$field['id']])) { |
|
| 813 | + wp_send_json_error(__('Some required fields have not been filled.', 'invoicing')); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if ( $field['type'] == 'address' ) { |
|
| 816 | + if ($field['type'] == 'address') { |
|
| 817 | 817 | |
| 818 | - foreach ( $field['fields'] as $address_field ) { |
|
| 818 | + foreach ($field['fields'] as $address_field) { |
|
| 819 | 819 | |
| 820 | - if ( empty( $address_field['visible'] ) ) { |
|
| 820 | + if (empty($address_field['visible'])) { |
|
| 821 | 821 | continue; |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) { |
|
| 825 | - wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) ); |
|
| 824 | + if (!empty($address_field['required']) && empty($data[$address_field['name']])) { |
|
| 825 | + wp_send_json_error(__('Some required fields have not been filled.', 'invoicing')); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - if ( isset( $data[ $address_field['name'] ] ) ) { |
|
| 829 | - $label = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
| 830 | - $address_fields[ $label ] = wpinv_clean( $data[ $address_field['name'] ] ); |
|
| 828 | + if (isset($data[$address_field['name']])) { |
|
| 829 | + $label = str_replace('wpinv_', '', $address_field['name']); |
|
| 830 | + $address_fields[$label] = wpinv_clean($data[$address_field['name']]); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - } else if ( isset( $data[ $field['id'] ] ) ) { |
|
| 835 | + } else if (isset($data[$field['id']])) { |
|
| 836 | 836 | $label = $field['id']; |
| 837 | 837 | |
| 838 | - if ( isset( $field['label'] ) ) { |
|
| 838 | + if (isset($field['label'])) { |
|
| 839 | 839 | $label = $field['label']; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
|
| 842 | + $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $user = get_user_by( 'email', $prepared['billing_email'] ); |
|
| 847 | + $user = get_user_by('email', $prepared['billing_email']); |
|
| 848 | 848 | |
| 849 | - if ( empty( $user ) ) { |
|
| 850 | - $user = wpinv_create_user( $prepared['billing_email'] ); |
|
| 849 | + if (empty($user)) { |
|
| 850 | + $user = wpinv_create_user($prepared['billing_email']); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - if ( is_wp_error( $user ) ) { |
|
| 854 | - wp_send_json_error( $user->get_error_message() ); |
|
| 853 | + if (is_wp_error($user)) { |
|
| 854 | + wp_send_json_error($user->get_error_message()); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - if ( is_numeric( $user ) ) { |
|
| 858 | - $user = get_user_by( 'id', $user ); |
|
| 857 | + if (is_numeric($user)) { |
|
| 858 | + $user = get_user_by('id', $user); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | // Create the invoice. |
@@ -870,42 +870,42 @@ discard block |
||
| 870 | 870 | true |
| 871 | 871 | ); |
| 872 | 872 | |
| 873 | - if ( is_wp_error( $created ) ) { |
|
| 874 | - wp_send_json_error( $created->get_error_message() ); |
|
| 873 | + if (is_wp_error($created)) { |
|
| 874 | + wp_send_json_error($created->get_error_message()); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - if ( empty( $created ) ) { |
|
| 878 | - wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) ); |
|
| 877 | + if (empty($created)) { |
|
| 878 | + wp_send_json_error(__('Could not create your invoice.', 'invoicing')); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - unset( $prepared['billing_email'] ); |
|
| 882 | - update_post_meta( $created->ID, 'payment_form_data', $prepared ); |
|
| 881 | + unset($prepared['billing_email']); |
|
| 882 | + update_post_meta($created->ID, 'payment_form_data', $prepared); |
|
| 883 | 883 | |
| 884 | 884 | $wpi_checkout_id = $created->ID; |
| 885 | 885 | $cart_total = wpinv_price( |
| 886 | 886 | wpinv_format_amount( |
| 887 | - wpinv_get_cart_total( $created->get_cart_details(), NULL, $created ) ), |
|
| 887 | + wpinv_get_cart_total($created->get_cart_details(), NULL, $created) ), |
|
| 888 | 888 | $created->get_currency() |
| 889 | 889 | ); |
| 890 | 890 | |
| 891 | 891 | $data = array(); |
| 892 | 892 | $data['invoice_id'] = $created->ID; |
| 893 | - $data['cart_discounts'] = $created->get_discounts( true ); |
|
| 893 | + $data['cart_discounts'] = $created->get_discounts(true); |
|
| 894 | 894 | |
| 895 | - wpinv_set_checkout_session( $data ); |
|
| 895 | + wpinv_set_checkout_session($data); |
|
| 896 | 896 | ob_start(); |
| 897 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 897 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 898 | 898 | echo '<form id="wpinv_checkout_form" action="' . $form_action . '" method="POST" class="wpi-form wpi-payment-form-checkout-form mt-4">'; |
| 899 | 899 | |
| 900 | - echo wpinv_display_line_items( $created->ID ); |
|
| 900 | + echo wpinv_display_line_items($created->ID); |
|
| 901 | 901 | |
| 902 | 902 | echo "<div class='mt-4'>"; |
| 903 | - do_action( 'wpinv_payment_mode_select' ); |
|
| 904 | - do_action( 'wpinv_checkout_form_bottom' ); |
|
| 903 | + do_action('wpinv_payment_mode_select'); |
|
| 904 | + do_action('wpinv_checkout_form_bottom'); |
|
| 905 | 905 | echo "</div>"; |
| 906 | 906 | |
| 907 | 907 | echo "</form>"; |
| 908 | - wp_send_json_success( ob_get_clean() ); |
|
| 908 | + wp_send_json_success(ob_get_clean()); |
|
| 909 | 909 | |
| 910 | 910 | } |
| 911 | 911 | |
@@ -917,53 +917,53 @@ discard block |
||
| 917 | 917 | public static function buy_items() { |
| 918 | 918 | $user_id = get_current_user_id(); |
| 919 | 919 | |
| 920 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
| 921 | - wp_send_json( array( |
|
| 922 | - 'success' => wp_login_url( wp_get_referer() ) |
|
| 923 | - ) ); |
|
| 920 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
| 921 | + wp_send_json(array( |
|
| 922 | + 'success' => wp_login_url(wp_get_referer()) |
|
| 923 | + )); |
|
| 924 | 924 | } else { |
| 925 | 925 | // Only check nonce if logged in as it could be cached when logged out. |
| 926 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
| 927 | - wp_send_json( array( |
|
| 928 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
| 929 | - ) ); |
|
| 926 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
| 927 | + wp_send_json(array( |
|
| 928 | + 'error' => __('Security checks failed.', 'invoicing') |
|
| 929 | + )); |
|
| 930 | 930 | wp_die(); |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | // allow to set a custom price through post_id |
| 934 | 934 | $items = $_POST['items']; |
| 935 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
| 936 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
| 935 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
| 936 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
| 937 | 937 | |
| 938 | 938 | $cart_items = array(); |
| 939 | - if ( $items ) { |
|
| 940 | - $items = explode( ',', $items ); |
|
| 939 | + if ($items) { |
|
| 940 | + $items = explode(',', $items); |
|
| 941 | 941 | |
| 942 | - foreach( $items as $item ) { |
|
| 942 | + foreach ($items as $item) { |
|
| 943 | 943 | $item_id = $item; |
| 944 | 944 | $quantity = 1; |
| 945 | 945 | |
| 946 | - if ( strpos( $item, '|' ) !== false ) { |
|
| 947 | - $item_parts = explode( '|', $item ); |
|
| 946 | + if (strpos($item, '|') !== false) { |
|
| 947 | + $item_parts = explode('|', $item); |
|
| 948 | 948 | $item_id = $item_parts[0]; |
| 949 | 949 | $quantity = $item_parts[1]; |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - if ( $item_id && $quantity ) { |
|
| 952 | + if ($item_id && $quantity) { |
|
| 953 | 953 | $cart_items_arr = array( |
| 954 | - 'id' => (int)$item_id, |
|
| 955 | - 'quantity' => (int)$quantity |
|
| 954 | + 'id' => (int) $item_id, |
|
| 955 | + 'quantity' => (int) $quantity |
|
| 956 | 956 | ); |
| 957 | 957 | |
| 958 | 958 | // If there is a related post id then add it to meta |
| 959 | - if ( $related_post_id ) { |
|
| 959 | + if ($related_post_id) { |
|
| 960 | 960 | $cart_items_arr['meta'] = array( |
| 961 | 961 | 'post_id' => $related_post_id |
| 962 | 962 | ); |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | // If there is a custom price then set it. |
| 966 | - if ( $custom_item_price ) { |
|
| 966 | + if ($custom_item_price) { |
|
| 967 | 967 | $cart_items_arr['custom_price'] = $custom_item_price; |
| 968 | 968 | } |
| 969 | 969 | |
@@ -979,37 +979,37 @@ discard block |
||
| 979 | 979 | * @param int $related_post_id The related post id if any. |
| 980 | 980 | * @since 1.0.0 |
| 981 | 981 | */ |
| 982 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
| 982 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
| 983 | 983 | |
| 984 | 984 | // Make sure its not in the cart already, if it is then redirect to checkout. |
| 985 | 985 | $cart_invoice = wpinv_get_invoice_cart(); |
| 986 | 986 | |
| 987 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
| 988 | - wp_send_json( array( |
|
| 987 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
| 988 | + wp_send_json(array( |
|
| 989 | 989 | 'success' => $cart_invoice->get_checkout_payment_url() |
| 990 | - ) ); |
|
| 990 | + )); |
|
| 991 | 991 | wp_die(); |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | // Check if user has invoice with same items waiting to be paid. |
| 995 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
| 996 | - if ( !empty( $user_invoices ) ) { |
|
| 997 | - foreach( $user_invoices as $user_invoice ) { |
|
| 995 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
| 996 | + if (!empty($user_invoices)) { |
|
| 997 | + foreach ($user_invoices as $user_invoice) { |
|
| 998 | 998 | $user_cart_details = array(); |
| 999 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
| 999 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
| 1000 | 1000 | $cart_details = $invoice->get_cart_details(); |
| 1001 | 1001 | |
| 1002 | - if ( !empty( $cart_details ) ) { |
|
| 1003 | - foreach ( $cart_details as $invoice_item ) { |
|
| 1002 | + if (!empty($cart_details)) { |
|
| 1003 | + foreach ($cart_details as $invoice_item) { |
|
| 1004 | 1004 | $ii_arr = array(); |
| 1005 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
| 1006 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
| 1005 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
| 1006 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
| 1007 | 1007 | |
| 1008 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
| 1008 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
| 1009 | 1009 | $ii_arr['meta'] = $invoice_item['meta']; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
| 1012 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
| 1013 | 1013 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
@@ -1017,17 +1017,17 @@ discard block |
||
| 1017 | 1017 | } |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
| 1021 | - wp_send_json( array( |
|
| 1020 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
| 1021 | + wp_send_json(array( |
|
| 1022 | 1022 | 'success' => $invoice->get_checkout_payment_url() |
| 1023 | - ) ); |
|
| 1023 | + )); |
|
| 1024 | 1024 | wp_die(); |
| 1025 | 1025 | } |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | // Create invoice and send user to checkout |
| 1030 | - if ( !empty( $cart_items ) ) { |
|
| 1030 | + if (!empty($cart_items)) { |
|
| 1031 | 1031 | $invoice_data = array( |
| 1032 | 1032 | 'status' => 'wpi-pending', |
| 1033 | 1033 | 'created_via' => 'wpi', |
@@ -1035,21 +1035,21 @@ discard block |
||
| 1035 | 1035 | 'cart_details' => $cart_items, |
| 1036 | 1036 | ); |
| 1037 | 1037 | |
| 1038 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
| 1038 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
| 1039 | 1039 | |
| 1040 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
| 1041 | - wp_send_json( array( |
|
| 1040 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
| 1041 | + wp_send_json(array( |
|
| 1042 | 1042 | 'success' => $invoice->get_checkout_payment_url() |
| 1043 | - ) ); |
|
| 1043 | + )); |
|
| 1044 | 1044 | } else { |
| 1045 | - wp_send_json( array( |
|
| 1046 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
| 1047 | - ) ); |
|
| 1045 | + wp_send_json(array( |
|
| 1046 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
| 1047 | + )); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | } else { |
| 1050 | - wp_send_json( array( |
|
| 1051 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
| 1052 | - ) ); |
|
| 1050 | + wp_send_json(array( |
|
| 1051 | + 'error' => __('Items not valid.', 'invoicing') |
|
| 1052 | + )); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | } |
| 1055 | 1055 | |
@@ -7,91 +7,91 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if ( !is_admin() ) { |
|
| 15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
| 17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
| 18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
| 14 | +if (!is_admin()) { |
|
| 15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
| 17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
| 18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_template_path() { |
| 22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
| 26 | - if ( empty( $invoice ) ) { |
|
| 25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
| 26 | + if (empty($invoice)) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | ?> |
| 30 | 30 | <div class="row wpinv-top-bar no-print"> |
| 31 | 31 | <div class="container"> |
| 32 | 32 | <div class="col-xs-6"> |
| 33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
| 33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
| 34 | 34 | </div> |
| 35 | 35 | <div class="col-xs-6 text-right"> |
| 36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
| 36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
| 37 | 37 | </div> |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
| 44 | - if ( empty( $invoice ) ) { |
|
| 43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
| 44 | + if (empty($invoice)) { |
|
| 45 | 45 | return; // Exit if invoice is not set. |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
| 49 | - if ( $invoice->needs_payment() ) { |
|
| 50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
| 48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
| 49 | + if ($invoice->needs_payment()) { |
|
| 50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
| 57 | - if ( empty( $invoice ) ) { |
|
| 56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
| 57 | + if (empty($invoice)) { |
|
| 58 | 58 | return; // Exit if invoice is not set. |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
| 62 | - <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
| 63 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 64 | - <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
| 61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
| 62 | + <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
| 63 | + <?php if (is_user_logged_in()) { ?> |
|
| 64 | + <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
| 65 | 65 | <?php } |
| 66 | 66 | } |
| 67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function wpinv_before_invoice_content( $content ) { |
|
| 70 | +function wpinv_before_invoice_content($content) { |
|
| 71 | 71 | global $post; |
| 72 | 72 | |
| 73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 74 | 74 | ob_start(); |
| 75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
| 75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
| 76 | 76 | $content = ob_get_clean() . $content; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $content; |
| 80 | 80 | } |
| 81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
| 81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
| 82 | 82 | |
| 83 | -function wpinv_after_invoice_content( $content ) { |
|
| 83 | +function wpinv_after_invoice_content($content) { |
|
| 84 | 84 | global $post; |
| 85 | 85 | |
| 86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 87 | 87 | ob_start(); |
| 88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
| 88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
| 89 | 89 | $content .= ob_get_clean(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $content; |
| 93 | 93 | } |
| 94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
| 94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
| 95 | 95 | |
| 96 | 96 | function wpinv_get_templates_dir() { |
| 97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
| 101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 106 | - extract( $args ); |
|
| 104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 105 | + if (!empty($args) && is_array($args)) { |
|
| 106 | + extract($args); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
| 110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
| 111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 112 | 112 | |
| 113 | - if ( ! file_exists( $located ) ) { |
|
| 114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
| 113 | + if (!file_exists($located)) { |
|
| 114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
| 119 | 119 | |
| 120 | - include( $located ); |
|
| 120 | + include($located); |
|
| 121 | 121 | |
| 122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 126 | 126 | ob_start(); |
| 127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
| 128 | 128 | return ob_get_clean(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 132 | - if ( ! $template_path ) { |
|
| 131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 132 | + if (!$template_path) { |
|
| 133 | 133 | $template_path = wpinv_template_path(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( ! $default_path ) { |
|
| 136 | + if (!$default_path) { |
|
| 137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Look within passed path within the theme - this is priority. |
| 141 | 141 | $template = locate_template( |
| 142 | 142 | array( |
| 143 | - trailingslashit( $template_path ) . $template_name, |
|
| 143 | + trailingslashit($template_path) . $template_name, |
|
| 144 | 144 | $template_name |
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | // Get default templates/ |
| 149 | - if ( !$template && $default_path ) { |
|
| 150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
| 149 | + if (!$template && $default_path) { |
|
| 150 | + $template = trailingslashit($default_path) . $template_name; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Return what we found. |
| 154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
| 154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 159 | 159 | |
| 160 | 160 | // Setup possible parts |
| 161 | 161 | $templates = array(); |
| 162 | - if ( isset( $name ) ) |
|
| 162 | + if (isset($name)) |
|
| 163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
| 164 | 164 | $templates[] = $slug . '.php'; |
| 165 | 165 | |
| 166 | 166 | // Allow template parts to be filtered |
| 167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 168 | 168 | |
| 169 | 169 | // Return the part that is found |
| 170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 174 | 174 | // No file found yet |
| 175 | 175 | $located = false; |
| 176 | 176 | |
| 177 | 177 | // Try to find a template file |
| 178 | - foreach ( (array)$template_names as $template_name ) { |
|
| 178 | + foreach ((array) $template_names as $template_name) { |
|
| 179 | 179 | |
| 180 | 180 | // Continue if template is empty |
| 181 | - if ( empty( $template_name ) ) |
|
| 181 | + if (empty($template_name)) |
|
| 182 | 182 | continue; |
| 183 | 183 | |
| 184 | 184 | // Trim off any slashes from the template name |
| 185 | - $template_name = ltrim( $template_name, '/' ); |
|
| 185 | + $template_name = ltrim($template_name, '/'); |
|
| 186 | 186 | |
| 187 | 187 | // try locating this template file by looping through the template paths |
| 188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 189 | 189 | |
| 190 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 190 | + if (file_exists($template_path . $template_name)) { |
|
| 191 | 191 | $located = $template_path . $template_name; |
| 192 | 192 | break; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if( !empty( $located ) ) { |
|
| 196 | + if (!empty($located)) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 202 | - load_template( $located, $require_once ); |
|
| 201 | + if ((true == $load) && !empty($located)) |
|
| 202 | + load_template($located, $require_once); |
|
| 203 | 203 | |
| 204 | 204 | return $located; |
| 205 | 205 | } |
@@ -208,159 +208,159 @@ discard block |
||
| 208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 209 | 209 | |
| 210 | 210 | $file_paths = array( |
| 211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 213 | 213 | 100 => wpinv_get_templates_dir() |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 217 | 217 | |
| 218 | 218 | // sort the file paths based on priority |
| 219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 219 | + ksort($file_paths, SORT_NUMERIC); |
|
| 220 | 220 | |
| 221 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 221 | + return array_map('trailingslashit', $file_paths); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | function wpinv_get_theme_template_dir_name() { |
| 225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | function wpinv_checkout_meta_tags() { |
| 229 | 229 | |
| 230 | 230 | $pages = array(); |
| 231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 231 | + $pages[] = wpinv_get_option('success_page'); |
|
| 232 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 235 | 235 | |
| 236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 241 | 241 | } |
| 242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 243 | 243 | |
| 244 | -function wpinv_add_body_classes( $class ) { |
|
| 245 | - $classes = (array)$class; |
|
| 244 | +function wpinv_add_body_classes($class) { |
|
| 245 | + $classes = (array) $class; |
|
| 246 | 246 | |
| 247 | - if( wpinv_is_checkout() ) { |
|
| 247 | + if (wpinv_is_checkout()) { |
|
| 248 | 248 | $classes[] = 'wpinv-checkout'; |
| 249 | 249 | $classes[] = 'wpinv-page'; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if( wpinv_is_success_page() ) { |
|
| 252 | + if (wpinv_is_success_page()) { |
|
| 253 | 253 | $classes[] = 'wpinv-success'; |
| 254 | 254 | $classes[] = 'wpinv-page'; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 257 | + if (wpinv_is_failed_transaction_page()) { |
|
| 258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
| 259 | 259 | $classes[] = 'wpinv-page'; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if( wpinv_is_invoice_history_page() ) { |
|
| 262 | + if (wpinv_is_invoice_history_page()) { |
|
| 263 | 263 | $classes[] = 'wpinv-history'; |
| 264 | 264 | $classes[] = 'wpinv-page'; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 267 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 268 | 268 | $classes[] = 'wpinv-subscription'; |
| 269 | 269 | $classes[] = 'wpinv-page'; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if( wpinv_is_test_mode() ) { |
|
| 272 | + if (wpinv_is_test_mode()) { |
|
| 273 | 273 | $classes[] = 'wpinv-test-mode'; |
| 274 | 274 | $classes[] = 'wpinv-page'; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - return array_unique( $classes ); |
|
| 277 | + return array_unique($classes); |
|
| 278 | 278 | } |
| 279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 280 | 280 | |
| 281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 282 | - $args = array( 'nopaging' => true ); |
|
| 281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 282 | + $args = array('nopaging' => true); |
|
| 283 | 283 | |
| 284 | - if ( ! empty( $status ) ) |
|
| 284 | + if (!empty($status)) |
|
| 285 | 285 | $args['post_status'] = $status; |
| 286 | 286 | |
| 287 | - $discounts = wpinv_get_discounts( $args ); |
|
| 287 | + $discounts = wpinv_get_discounts($args); |
|
| 288 | 288 | $options = array(); |
| 289 | 289 | |
| 290 | - if ( $discounts ) { |
|
| 291 | - foreach ( $discounts as $discount ) { |
|
| 292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 290 | + if ($discounts) { |
|
| 291 | + foreach ($discounts as $discount) { |
|
| 292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 293 | 293 | } |
| 294 | 294 | } else { |
| 295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $output = wpinv_html_select( array( |
|
| 298 | + $output = wpinv_html_select(array( |
|
| 299 | 299 | 'name' => $name, |
| 300 | 300 | 'selected' => $selected, |
| 301 | 301 | 'options' => $options, |
| 302 | 302 | 'show_option_all' => false, |
| 303 | 303 | 'show_option_none' => false, |
| 304 | - ) ); |
|
| 304 | + )); |
|
| 305 | 305 | |
| 306 | 306 | return $output; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 310 | - $current = date( 'Y' ); |
|
| 311 | - $start_year = $current - absint( $years_before ); |
|
| 312 | - $end_year = $current + absint( $years_after ); |
|
| 313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 310 | + $current = date('Y'); |
|
| 311 | + $start_year = $current - absint($years_before); |
|
| 312 | + $end_year = $current + absint($years_after); |
|
| 313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 314 | 314 | $options = array(); |
| 315 | 315 | |
| 316 | - while ( $start_year <= $end_year ) { |
|
| 317 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 316 | + while ($start_year <= $end_year) { |
|
| 317 | + $options[absint($start_year)] = $start_year; |
|
| 318 | 318 | $start_year++; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $output = wpinv_html_select( array( |
|
| 321 | + $output = wpinv_html_select(array( |
|
| 322 | 322 | 'name' => $name, |
| 323 | 323 | 'selected' => $selected, |
| 324 | 324 | 'options' => $options, |
| 325 | 325 | 'show_option_all' => false, |
| 326 | 326 | 'show_option_none' => false |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | |
| 329 | 329 | return $output; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 333 | 333 | |
| 334 | 334 | $options = array( |
| 335 | - '1' => __( 'January', 'invoicing' ), |
|
| 336 | - '2' => __( 'February', 'invoicing' ), |
|
| 337 | - '3' => __( 'March', 'invoicing' ), |
|
| 338 | - '4' => __( 'April', 'invoicing' ), |
|
| 339 | - '5' => __( 'May', 'invoicing' ), |
|
| 340 | - '6' => __( 'June', 'invoicing' ), |
|
| 341 | - '7' => __( 'July', 'invoicing' ), |
|
| 342 | - '8' => __( 'August', 'invoicing' ), |
|
| 343 | - '9' => __( 'September', 'invoicing' ), |
|
| 344 | - '10' => __( 'October', 'invoicing' ), |
|
| 345 | - '11' => __( 'November', 'invoicing' ), |
|
| 346 | - '12' => __( 'December', 'invoicing' ), |
|
| 335 | + '1' => __('January', 'invoicing'), |
|
| 336 | + '2' => __('February', 'invoicing'), |
|
| 337 | + '3' => __('March', 'invoicing'), |
|
| 338 | + '4' => __('April', 'invoicing'), |
|
| 339 | + '5' => __('May', 'invoicing'), |
|
| 340 | + '6' => __('June', 'invoicing'), |
|
| 341 | + '7' => __('July', 'invoicing'), |
|
| 342 | + '8' => __('August', 'invoicing'), |
|
| 343 | + '9' => __('September', 'invoicing'), |
|
| 344 | + '10' => __('October', 'invoicing'), |
|
| 345 | + '11' => __('November', 'invoicing'), |
|
| 346 | + '12' => __('December', 'invoicing'), |
|
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | 349 | // If no month is selected, default to the current month |
| 350 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 350 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 351 | 351 | |
| 352 | - $output = wpinv_html_select( array( |
|
| 352 | + $output = wpinv_html_select(array( |
|
| 353 | 353 | 'name' => $name, |
| 354 | 354 | 'selected' => $selected, |
| 355 | 355 | 'options' => $options, |
| 356 | 356 | 'show_option_all' => false, |
| 357 | 357 | 'show_option_none' => false |
| 358 | - ) ); |
|
| 358 | + )); |
|
| 359 | 359 | |
| 360 | 360 | return $output; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | -function wpinv_html_select( $args = array() ) { |
|
| 363 | +function wpinv_html_select($args = array()) { |
|
| 364 | 364 | $defaults = array( |
| 365 | 365 | 'options' => array(), |
| 366 | 366 | 'name' => null, |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | 'selected' => 0, |
| 370 | 370 | 'placeholder' => null, |
| 371 | 371 | 'multiple' => false, |
| 372 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 373 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 372 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 373 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 374 | 374 | 'data' => array(), |
| 375 | 375 | 'onchange' => null, |
| 376 | 376 | 'required' => false, |
@@ -378,74 +378,74 @@ discard block |
||
| 378 | 378 | 'readonly' => false, |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | - $args = wp_parse_args( $args, $defaults ); |
|
| 381 | + $args = wp_parse_args($args, $defaults); |
|
| 382 | 382 | |
| 383 | 383 | $data_elements = ''; |
| 384 | - foreach ( $args['data'] as $key => $value ) { |
|
| 385 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 384 | + foreach ($args['data'] as $key => $value) { |
|
| 385 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if( $args['multiple'] ) { |
|
| 388 | + if ($args['multiple']) { |
|
| 389 | 389 | $multiple = ' MULTIPLE'; |
| 390 | 390 | } else { |
| 391 | 391 | $multiple = ''; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if( $args['placeholder'] ) { |
|
| 394 | + if ($args['placeholder']) { |
|
| 395 | 395 | $placeholder = $args['placeholder']; |
| 396 | 396 | } else { |
| 397 | 397 | $placeholder = ''; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $options = ''; |
| 401 | - if( !empty( $args['onchange'] ) ) { |
|
| 402 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 401 | + if (!empty($args['onchange'])) { |
|
| 402 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if( !empty( $args['required'] ) ) { |
|
| 405 | + if (!empty($args['required'])) { |
|
| 406 | 406 | $options .= ' required="required"'; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if( !empty( $args['disabled'] ) ) { |
|
| 409 | + if (!empty($args['disabled'])) { |
|
| 410 | 410 | $options .= ' disabled'; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if( !empty( $args['readonly'] ) ) { |
|
| 413 | + if (!empty($args['readonly'])) { |
|
| 414 | 414 | $options .= ' readonly'; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 418 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 417 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 418 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 419 | 419 | |
| 420 | - if ( $args['show_option_all'] ) { |
|
| 421 | - if( $args['multiple'] ) { |
|
| 422 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 420 | + if ($args['show_option_all']) { |
|
| 421 | + if ($args['multiple']) { |
|
| 422 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 423 | 423 | } else { |
| 424 | - $selected = selected( $args['selected'], 0, false ); |
|
| 424 | + $selected = selected($args['selected'], 0, false); |
|
| 425 | 425 | } |
| 426 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 426 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if ( !empty( $args['options'] ) ) { |
|
| 429 | + if (!empty($args['options'])) { |
|
| 430 | 430 | |
| 431 | - if ( $args['show_option_none'] ) { |
|
| 432 | - if( $args['multiple'] ) { |
|
| 433 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 431 | + if ($args['show_option_none']) { |
|
| 432 | + if ($args['multiple']) { |
|
| 433 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 434 | 434 | } else { |
| 435 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 435 | + $selected = selected($args['selected'] === "", true, false); |
|
| 436 | 436 | } |
| 437 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 437 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - foreach( $args['options'] as $key => $option ) { |
|
| 440 | + foreach ($args['options'] as $key => $option) { |
|
| 441 | 441 | |
| 442 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 443 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 442 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 443 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
| 444 | 444 | } else { |
| 445 | - $selected = selected( $args['selected'], $key, false ); |
|
| 445 | + $selected = selected($args['selected'], $key, false); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 448 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | return $output; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 457 | +function wpinv_item_dropdown($args = array()) { |
|
| 458 | 458 | $defaults = array( |
| 459 | 459 | 'name' => 'wpi_item', |
| 460 | 460 | 'id' => 'wpi_item', |
@@ -462,14 +462,14 @@ discard block |
||
| 462 | 462 | 'multiple' => false, |
| 463 | 463 | 'selected' => 0, |
| 464 | 464 | 'number' => 100, |
| 465 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 466 | - 'data' => array( 'search-type' => 'item' ), |
|
| 465 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 466 | + 'data' => array('search-type' => 'item'), |
|
| 467 | 467 | 'show_option_all' => false, |
| 468 | 468 | 'show_option_none' => false, |
| 469 | 469 | 'show_recurring' => false, |
| 470 | 470 | ); |
| 471 | 471 | |
| 472 | - $args = wp_parse_args( $args, $defaults ); |
|
| 472 | + $args = wp_parse_args($args, $defaults); |
|
| 473 | 473 | |
| 474 | 474 | $item_args = array( |
| 475 | 475 | 'post_type' => 'wpi_item', |
@@ -478,44 +478,44 @@ discard block |
||
| 478 | 478 | 'posts_per_page' => $args['number'] |
| 479 | 479 | ); |
| 480 | 480 | |
| 481 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 481 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 482 | 482 | |
| 483 | - $items = get_posts( $item_args ); |
|
| 483 | + $items = get_posts($item_args); |
|
| 484 | 484 | $options = array(); |
| 485 | - if ( $items ) { |
|
| 486 | - foreach ( $items as $item ) { |
|
| 487 | - $title = esc_html( $item->post_title ); |
|
| 485 | + if ($items) { |
|
| 486 | + foreach ($items as $item) { |
|
| 487 | + $title = esc_html($item->post_title); |
|
| 488 | 488 | |
| 489 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 490 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 489 | + if (!empty($args['show_recurring'])) { |
|
| 490 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $options[ absint( $item->ID ) ] = $title; |
|
| 493 | + $options[absint($item->ID)] = $title; |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // This ensures that any selected items are included in the drop down |
| 498 | - if( is_array( $args['selected'] ) ) { |
|
| 499 | - foreach( $args['selected'] as $item ) { |
|
| 500 | - if( ! in_array( $item, $options ) ) { |
|
| 501 | - $title = get_the_title( $item ); |
|
| 502 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 503 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 498 | + if (is_array($args['selected'])) { |
|
| 499 | + foreach ($args['selected'] as $item) { |
|
| 500 | + if (!in_array($item, $options)) { |
|
| 501 | + $title = get_the_title($item); |
|
| 502 | + if (!empty($args['show_recurring'])) { |
|
| 503 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 504 | 504 | } |
| 505 | 505 | $options[$item] = $title; |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 509 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 510 | - $title = get_the_title( $args['selected'] ); |
|
| 511 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 512 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 508 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 509 | + if (!in_array($args['selected'], $options)) { |
|
| 510 | + $title = get_the_title($args['selected']); |
|
| 511 | + if (!empty($args['show_recurring'])) { |
|
| 512 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 513 | 513 | } |
| 514 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 514 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $output = wpinv_html_select( array( |
|
| 518 | + $output = wpinv_html_select(array( |
|
| 519 | 519 | 'name' => $args['name'], |
| 520 | 520 | 'selected' => $args['selected'], |
| 521 | 521 | 'id' => $args['id'], |
@@ -526,12 +526,12 @@ discard block |
||
| 526 | 526 | 'show_option_all' => $args['show_option_all'], |
| 527 | 527 | 'show_option_none' => $args['show_option_none'], |
| 528 | 528 | 'data' => $args['data'], |
| 529 | - ) ); |
|
| 529 | + )); |
|
| 530 | 530 | |
| 531 | 531 | return $output; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 534 | +function wpinv_html_checkbox($args = array()) { |
|
| 535 | 535 | $defaults = array( |
| 536 | 536 | 'name' => null, |
| 537 | 537 | 'current' => null, |
@@ -542,38 +542,38 @@ discard block |
||
| 542 | 542 | ) |
| 543 | 543 | ); |
| 544 | 544 | |
| 545 | - $args = wp_parse_args( $args, $defaults ); |
|
| 545 | + $args = wp_parse_args($args, $defaults); |
|
| 546 | 546 | |
| 547 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 547 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 548 | 548 | $options = ''; |
| 549 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 549 | + if (!empty($args['options']['disabled'])) { |
|
| 550 | 550 | $options .= ' disabled="disabled"'; |
| 551 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 551 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 552 | 552 | $options .= ' readonly'; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 555 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 556 | 556 | |
| 557 | 557 | return $output; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | -function wpinv_html_text( $args = array() ) { |
|
| 560 | +function wpinv_html_text($args = array()) { |
|
| 561 | 561 | // Backwards compatibility |
| 562 | - if ( func_num_args() > 1 ) { |
|
| 562 | + if (func_num_args() > 1) { |
|
| 563 | 563 | $args = func_get_args(); |
| 564 | 564 | |
| 565 | 565 | $name = $args[0]; |
| 566 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 567 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 568 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 566 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 567 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 568 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | $defaults = array( |
| 572 | 572 | 'id' => '', |
| 573 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 574 | - 'value' => isset( $value ) ? $value : null, |
|
| 575 | - 'label' => isset( $label ) ? $label : null, |
|
| 576 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 573 | + 'name' => isset($name) ? $name : 'text', |
|
| 574 | + 'value' => isset($value) ? $value : null, |
|
| 575 | + 'label' => isset($label) ? $label : null, |
|
| 576 | + 'desc' => isset($desc) ? $desc : null, |
|
| 577 | 577 | 'placeholder' => '', |
| 578 | 578 | 'class' => 'regular-text', |
| 579 | 579 | 'disabled' => false, |
@@ -583,51 +583,51 @@ discard block |
||
| 583 | 583 | 'data' => false |
| 584 | 584 | ); |
| 585 | 585 | |
| 586 | - $args = wp_parse_args( $args, $defaults ); |
|
| 586 | + $args = wp_parse_args($args, $defaults); |
|
| 587 | 587 | |
| 588 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 588 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 589 | 589 | $options = ''; |
| 590 | - if( $args['required'] ) { |
|
| 590 | + if ($args['required']) { |
|
| 591 | 591 | $options .= ' required="required"'; |
| 592 | 592 | } |
| 593 | - if( $args['readonly'] ) { |
|
| 593 | + if ($args['readonly']) { |
|
| 594 | 594 | $options .= ' readonly'; |
| 595 | 595 | } |
| 596 | - if( $args['readonly'] ) { |
|
| 596 | + if ($args['readonly']) { |
|
| 597 | 597 | $options .= ' readonly'; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | $data = ''; |
| 601 | - if ( !empty( $args['data'] ) ) { |
|
| 602 | - foreach ( $args['data'] as $key => $value ) { |
|
| 603 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 601 | + if (!empty($args['data'])) { |
|
| 602 | + foreach ($args['data'] as $key => $value) { |
|
| 603 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 608 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 609 | - if ( ! empty( $args['desc'] ) ) { |
|
| 610 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 607 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 608 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 609 | + if (!empty($args['desc'])) { |
|
| 610 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 613 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 614 | 614 | |
| 615 | 615 | $output .= '</span>'; |
| 616 | 616 | |
| 617 | 617 | return $output; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | -function wpinv_html_date_field( $args = array() ) { |
|
| 621 | - if( empty( $args['class'] ) ) { |
|
| 620 | +function wpinv_html_date_field($args = array()) { |
|
| 621 | + if (empty($args['class'])) { |
|
| 622 | 622 | $args['class'] = 'wpiDatepicker'; |
| 623 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 623 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 624 | 624 | $args['class'] .= ' wpiDatepicker'; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - return wpinv_html_text( $args ); |
|
| 627 | + return wpinv_html_text($args); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | -function wpinv_html_textarea( $args = array() ) { |
|
| 630 | +function wpinv_html_textarea($args = array()) { |
|
| 631 | 631 | $defaults = array( |
| 632 | 632 | 'name' => 'textarea', |
| 633 | 633 | 'value' => null, |
@@ -638,31 +638,31 @@ discard block |
||
| 638 | 638 | 'placeholder' => '', |
| 639 | 639 | ); |
| 640 | 640 | |
| 641 | - $args = wp_parse_args( $args, $defaults ); |
|
| 641 | + $args = wp_parse_args($args, $defaults); |
|
| 642 | 642 | |
| 643 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 643 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 644 | 644 | $disabled = ''; |
| 645 | - if( $args['disabled'] ) { |
|
| 645 | + if ($args['disabled']) { |
|
| 646 | 646 | $disabled = ' disabled="disabled"'; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 650 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 651 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 649 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 650 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 651 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 652 | 652 | |
| 653 | - if ( ! empty( $args['desc'] ) ) { |
|
| 654 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 653 | + if (!empty($args['desc'])) { |
|
| 654 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 655 | 655 | } |
| 656 | 656 | $output .= '</span>'; |
| 657 | 657 | |
| 658 | 658 | return $output; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 661 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 662 | 662 | $defaults = array( |
| 663 | 663 | 'name' => 'user_id', |
| 664 | 664 | 'value' => null, |
| 665 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 665 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 666 | 666 | 'label' => null, |
| 667 | 667 | 'desc' => null, |
| 668 | 668 | 'class' => '', |
@@ -671,13 +671,13 @@ discard block |
||
| 671 | 671 | 'data' => false |
| 672 | 672 | ); |
| 673 | 673 | |
| 674 | - $args = wp_parse_args( $args, $defaults ); |
|
| 674 | + $args = wp_parse_args($args, $defaults); |
|
| 675 | 675 | |
| 676 | 676 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 677 | 677 | |
| 678 | 678 | $output = '<span class="wpinv_user_search_wrap">'; |
| 679 | - $output .= wpinv_html_text( $args ); |
|
| 680 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 679 | + $output .= wpinv_html_text($args); |
|
| 680 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 681 | 681 | $output .= '</span>'; |
| 682 | 682 | |
| 683 | 683 | return $output; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | function wpinv_ip_geolocation() { |
| 687 | 687 | global $wpinv_euvat; |
| 688 | 688 | |
| 689 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
| 689 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
| 690 | 690 | $content = ''; |
| 691 | 691 | $iso = ''; |
| 692 | 692 | $country = ''; |
@@ -697,69 +697,69 @@ discard block |
||
| 697 | 697 | $credit = ''; |
| 698 | 698 | $address = ''; |
| 699 | 699 | |
| 700 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
| 700 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
| 701 | 701 | try { |
| 702 | 702 | $iso = $geoip2_city->country->isoCode; |
| 703 | 703 | $country = $geoip2_city->country->name; |
| 704 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 704 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 705 | 705 | $city = $geoip2_city->city->name; |
| 706 | 706 | $longitude = $geoip2_city->location->longitude; |
| 707 | 707 | $latitude = $geoip2_city->location->latitude; |
| 708 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 709 | - } catch( Exception $e ) { } |
|
| 708 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 709 | + } catch (Exception $e) { } |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 712 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
| 713 | 713 | try { |
| 714 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 714 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 715 | 715 | |
| 716 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
| 716 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 717 | 717 | $iso = $load_xml->geoplugin_countryCode; |
| 718 | 718 | $country = $load_xml->geoplugin_countryName; |
| 719 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 720 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 719 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 720 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 721 | 721 | $longitude = $load_xml->geoplugin_longitude; |
| 722 | 722 | $latitude = $load_xml->geoplugin_latitude; |
| 723 | 723 | $credit = $load_xml->geoplugin_credit; |
| 724 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
| 724 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
| 725 | 725 | } |
| 726 | - } catch( Exception $e ) { } |
|
| 726 | + } catch (Exception $e) { } |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( $iso && $longitude && $latitude ) { |
|
| 730 | - if ( $city ) { |
|
| 729 | + if ($iso && $longitude && $latitude) { |
|
| 730 | + if ($city) { |
|
| 731 | 731 | $address .= $city . ', '; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - if ( $region ) { |
|
| 734 | + if ($region) { |
|
| 735 | 735 | $address .= $region . ', '; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | $address .= $country . ' (' . $iso . ')'; |
| 739 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
| 740 | - $content .= '<p>'. $credit . '</p>'; |
|
| 739 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
| 740 | + $content .= '<p>' . $credit . '</p>'; |
|
| 741 | 741 | } else { |
| 742 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
| 742 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
| 743 | 743 | } |
| 744 | 744 | ?> |
| 745 | 745 | <!DOCTYPE html> |
| 746 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 746 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 747 | 747 | <body> |
| 748 | - <?php if ( $latitude && $latitude ) { ?> |
|
| 748 | + <?php if ($latitude && $latitude) { ?> |
|
| 749 | 749 | <div id="map"></div> |
| 750 | 750 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
| 751 | 751 | <script type="text/javascript"> |
| 752 | 752 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 753 | 753 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 754 | 754 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
| 755 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
| 755 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
| 756 | 756 | |
| 757 | 757 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
| 758 | 758 | |
| 759 | 759 | var marker = new L.Marker(latlng); |
| 760 | 760 | map.addLayer(marker); |
| 761 | 761 | |
| 762 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
| 762 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
| 763 | 763 | </script> |
| 764 | 764 | <?php } ?> |
| 765 | 765 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -767,18 +767,18 @@ discard block |
||
| 767 | 767 | <?php |
| 768 | 768 | exit; |
| 769 | 769 | } |
| 770 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 771 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 770 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 771 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 772 | 772 | |
| 773 | 773 | // Set up the template for the invoice. |
| 774 | -function wpinv_template( $template ) { |
|
| 774 | +function wpinv_template($template) { |
|
| 775 | 775 | global $post, $wp_query; |
| 776 | 776 | |
| 777 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
| 778 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 779 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 777 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
| 778 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 779 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 780 | 780 | } else { |
| 781 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 781 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | function wpinv_get_business_address() { |
| 789 | 789 | $business_address = wpinv_store_address(); |
| 790 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 790 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 791 | 791 | |
| 792 | 792 | /* |
| 793 | 793 | $default_country = wpinv_get_default_country(); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 813 | 813 | |
| 814 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 814 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | function wpinv_display_from_address() { |
@@ -821,107 +821,107 @@ discard block |
||
| 821 | 821 | if (empty($from_name)) { |
| 822 | 822 | $from_name = wpinv_get_business_name(); |
| 823 | 823 | } |
| 824 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
| 824 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
| 825 | 825 | <div class="wrapper col-xs-10"> |
| 826 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
| 827 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
| 828 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
| 826 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
| 827 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
| 828 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
| 829 | 829 | <?php } ?> |
| 830 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
| 831 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
| 830 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
| 831 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
| 832 | 832 | <?php } ?> |
| 833 | 833 | </div> |
| 834 | 834 | <?php |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | -function wpinv_watermark( $id = 0 ) { |
|
| 838 | - $output = wpinv_get_watermark( $id ); |
|
| 837 | +function wpinv_watermark($id = 0) { |
|
| 838 | + $output = wpinv_get_watermark($id); |
|
| 839 | 839 | |
| 840 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 840 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | -function wpinv_get_watermark( $id ) { |
|
| 844 | - if ( !$id > 0 ) { |
|
| 843 | +function wpinv_get_watermark($id) { |
|
| 844 | + if (!$id > 0) { |
|
| 845 | 845 | return NULL; |
| 846 | 846 | } |
| 847 | - $invoice = wpinv_get_invoice( $id ); |
|
| 847 | + $invoice = wpinv_get_invoice($id); |
|
| 848 | 848 | |
| 849 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 850 | - if ( $invoice->is_paid() ) { |
|
| 851 | - return __( 'Paid', 'invoicing' ); |
|
| 849 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 850 | + if ($invoice->is_paid()) { |
|
| 851 | + return __('Paid', 'invoicing'); |
|
| 852 | 852 | } |
| 853 | - if ( $invoice->is_refunded() ) { |
|
| 854 | - return __( 'Refunded', 'invoicing' ); |
|
| 853 | + if ($invoice->is_refunded()) { |
|
| 854 | + return __('Refunded', 'invoicing'); |
|
| 855 | 855 | } |
| 856 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 857 | - return __( 'Cancelled', 'invoicing' ); |
|
| 856 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 857 | + return __('Cancelled', 'invoicing'); |
|
| 858 | 858 | } |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | return NULL; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 864 | +function wpinv_display_invoice_details($invoice) { |
|
| 865 | 865 | global $wpinv_euvat; |
| 866 | 866 | |
| 867 | 867 | $invoice_id = $invoice->ID; |
| 868 | 868 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 869 | 869 | $use_taxes = wpinv_use_taxes(); |
| 870 | 870 | |
| 871 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
| 871 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
| 872 | 872 | ?> |
| 873 | 873 | <table class="table table-bordered table-sm"> |
| 874 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
| 874 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
| 875 | 875 | <tr class="wpi-row-number"> |
| 876 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
| 877 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
| 876 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
| 877 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
| 878 | 878 | </tr> |
| 879 | 879 | <?php } ?> |
| 880 | 880 | <tr class="wpi-row-status"> |
| 881 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
| 882 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
| 881 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
| 882 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
| 883 | 883 | </tr> |
| 884 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 884 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 885 | 885 | <tr class="wpi-row-parent"> |
| 886 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
| 887 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 886 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
| 887 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 888 | 888 | </tr> |
| 889 | 889 | <?php } ?> |
| 890 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 890 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 891 | 891 | <tr class="wpi-row-gateway"> |
| 892 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
| 892 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
| 893 | 893 | <td><?php echo $gateway_name; ?></td> |
| 894 | 894 | </tr> |
| 895 | 895 | <?php } ?> |
| 896 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
| 896 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
| 897 | 897 | <tr class="wpi-row-date"> |
| 898 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
| 898 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
| 899 | 899 | <td><?php echo $invoice_date; ?></td> |
| 900 | 900 | </tr> |
| 901 | 901 | <?php } ?> |
| 902 | - <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?> |
|
| 903 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
| 902 | + <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?> |
|
| 903 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
| 904 | 904 | <tr class="wpi-row-date"> |
| 905 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
| 905 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
| 906 | 906 | <td><?php echo $due_date; ?></td> |
| 907 | 907 | </tr> |
| 908 | 908 | <?php } ?> |
| 909 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
| 910 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
| 909 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
| 910 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
| 911 | 911 | <tr class="wpi-row-ovatno"> |
| 912 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 912 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 913 | 913 | <td><?php echo $owner_vat_number; ?></td> |
| 914 | 914 | </tr> |
| 915 | 915 | <?php } ?> |
| 916 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
| 916 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
| 917 | 917 | <tr class="wpi-row-uvatno"> |
| 918 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 918 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 919 | 919 | <td><?php echo $user_vat_number; ?></td> |
| 920 | 920 | </tr> |
| 921 | 921 | <?php } ?> |
| 922 | 922 | <tr class="table-active tr-total wpi-row-total"> |
| 923 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
| 924 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
| 923 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
| 924 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
| 925 | 925 | </tr> |
| 926 | 926 | </table> |
| 927 | 927 | <?php |
@@ -937,84 +937,84 @@ discard block |
||
| 937 | 937 | * @param string $separator How to separate address lines. |
| 938 | 938 | * @return string |
| 939 | 939 | */ |
| 940 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 940 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 941 | 941 | |
| 942 | 942 | // Retrieve the address markup... |
| 943 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 944 | - $format = wpinv_get_full_address_format( $country ); |
|
| 943 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 944 | + $format = wpinv_get_full_address_format($country); |
|
| 945 | 945 | |
| 946 | 946 | // ... and the replacements. |
| 947 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 947 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 948 | 948 | |
| 949 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 949 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 950 | 950 | |
| 951 | 951 | // Remove unavailable tags. |
| 952 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 952 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 953 | 953 | |
| 954 | 954 | // Clean up white space. |
| 955 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 956 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 955 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 956 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 957 | 957 | |
| 958 | 958 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 959 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 959 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 960 | 960 | |
| 961 | 961 | // Add html breaks. |
| 962 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 962 | + $formatted_address = implode($separator, $formatted_address); |
|
| 963 | 963 | |
| 964 | 964 | // We're done! |
| 965 | 965 | return $formatted_address; |
| 966 | 966 | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
| 970 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 969 | +function wpinv_display_to_address($invoice_id = 0) { |
|
| 970 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 971 | 971 | |
| 972 | - if ( empty( $invoice ) ) { |
|
| 972 | + if (empty($invoice)) { |
|
| 973 | 973 | return NULL; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | $billing_details = $invoice->get_user_info(); |
| 977 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
| 977 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
| 978 | 978 | $output .= '<div class="wrapper col-xs-10">'; |
| 979 | 979 | |
| 980 | 980 | ob_start(); |
| 981 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
| 981 | + do_action('wpinv_display_to_address_top', $invoice); |
|
| 982 | 982 | $output .= ob_get_clean(); |
| 983 | 983 | |
| 984 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 984 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 985 | 985 | |
| 986 | - if ( $address_row ) { |
|
| 986 | + if ($address_row) { |
|
| 987 | 987 | $output .= '<div class="address">' . $address_row . '</div>'; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | - if ( $phone = $invoice->get_phone() ) { |
|
| 991 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
| 990 | + if ($phone = $invoice->get_phone()) { |
|
| 991 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
| 992 | 992 | } |
| 993 | - if ( $email = $invoice->get_email() ) { |
|
| 994 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
| 993 | + if ($email = $invoice->get_email()) { |
|
| 994 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | ob_start(); |
| 998 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
| 998 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
| 999 | 999 | $output .= ob_get_clean(); |
| 1000 | 1000 | |
| 1001 | 1001 | $output .= '</div>'; |
| 1002 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
| 1002 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
| 1003 | 1003 | |
| 1004 | 1004 | echo $output; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 1007 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 1008 | 1008 | global $wpinv_euvat, $ajax_cart_details; |
| 1009 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1009 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1010 | 1010 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 1011 | 1011 | $use_taxes = wpinv_use_taxes(); |
| 1012 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
| 1012 | + if (!$use_taxes && (float) $invoice->get_tax() > 0) { |
|
| 1013 | 1013 | $use_taxes = true; |
| 1014 | 1014 | } |
| 1015 | - $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
|
| 1016 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 1017 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 1015 | + $zero_tax = !(float) $invoice->get_tax() > 0 ? true : false; |
|
| 1016 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 1017 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 1018 | 1018 | |
| 1019 | 1019 | $cart_details = $invoice->get_cart_details(); |
| 1020 | 1020 | $ajax_cart_details = $cart_details; |
@@ -1023,67 +1023,67 @@ discard block |
||
| 1023 | 1023 | <table class="table table-sm table-bordered"> |
| 1024 | 1024 | <thead> |
| 1025 | 1025 | <tr> |
| 1026 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
| 1027 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
| 1026 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
| 1027 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
| 1028 | 1028 | <?php if ($quantities_enabled) { ?> |
| 1029 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
| 1029 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
| 1030 | 1030 | <?php } ?> |
| 1031 | 1031 | <?php if ($use_taxes && !$zero_tax) { ?> |
| 1032 | 1032 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
| 1033 | 1033 | <?php } ?> |
| 1034 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
| 1034 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
| 1035 | 1035 | </tr> |
| 1036 | 1036 | </thead> |
| 1037 | 1037 | <tbody> |
| 1038 | 1038 | <?php |
| 1039 | - if ( !empty( $cart_details ) ) { |
|
| 1040 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
| 1039 | + if (!empty($cart_details)) { |
|
| 1040 | + do_action('wpinv_display_line_items_start', $invoice); |
|
| 1041 | 1041 | |
| 1042 | 1042 | $count = 0; |
| 1043 | 1043 | $cols = 3; |
| 1044 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 1045 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
| 1046 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
| 1047 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
| 1048 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
| 1044 | + foreach ($cart_details as $key => $cart_item) { |
|
| 1045 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
| 1046 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
| 1047 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
| 1048 | + $quantity = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
| 1049 | 1049 | |
| 1050 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
| 1050 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
| 1051 | 1051 | $summary = ''; |
| 1052 | - $item_name = ''; |
|
| 1052 | + $item_name = ''; |
|
| 1053 | 1053 | $cols = 3; |
| 1054 | - if ( !empty($item) ) { |
|
| 1054 | + if (!empty($item)) { |
|
| 1055 | 1055 | $item_name = $item->get_name(); |
| 1056 | 1056 | $summary = $item->get_summary(); |
| 1057 | 1057 | } |
| 1058 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1058 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1059 | 1059 | |
| 1060 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
| 1060 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
| 1061 | 1061 | |
| 1062 | 1062 | $item_tax = ''; |
| 1063 | 1063 | $tax_rate = ''; |
| 1064 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1065 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1066 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1067 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1064 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1065 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1066 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1067 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1068 | 1068 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | $line_item_tax = $item_tax . $tax_rate; |
| 1072 | 1072 | |
| 1073 | - if ( $line_item_tax === '' ) { |
|
| 1073 | + if ($line_item_tax === '') { |
|
| 1074 | 1074 | $line_item_tax = 0; // Zero tax |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | - $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols ); |
|
| 1077 | + $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols); |
|
| 1078 | 1078 | |
| 1079 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
| 1080 | - $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
| 1081 | - if ( $summary !== '' ) { |
|
| 1082 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
| 1079 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
| 1080 | + $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
| 1081 | + if ($summary !== '') { |
|
| 1082 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | $line_item .= '</td>'; |
| 1085 | 1085 | |
| 1086 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1086 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
| 1087 | 1087 | if ($quantities_enabled) { |
| 1088 | 1088 | $cols++; |
| 1089 | 1089 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1092,55 +1092,55 @@ discard block |
||
| 1092 | 1092 | $cols++; |
| 1093 | 1093 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1094 | 1094 | } |
| 1095 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1095 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
| 1096 | 1096 | $line_item .= '</tr>'; |
| 1097 | 1097 | |
| 1098 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
| 1098 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
| 1099 | 1099 | |
| 1100 | 1100 | $count++; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
| 1103 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
| 1104 | 1104 | ?> |
| 1105 | 1105 | <tr class="row-sub-total row_odd"> |
| 1106 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1107 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1106 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1107 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1108 | 1108 | </tr> |
| 1109 | 1109 | <?php |
| 1110 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
| 1110 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
| 1111 | 1111 | |
| 1112 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
| 1113 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
| 1112 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
| 1113 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
| 1114 | 1114 | ?> |
| 1115 | 1115 | <tr class="row-discount"> |
| 1116 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
| 1117 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1116 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
| 1117 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1118 | 1118 | </tr> |
| 1119 | 1119 | <?php |
| 1120 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
| 1120 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - if ( $use_taxes ) { |
|
| 1124 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
| 1123 | + if ($use_taxes) { |
|
| 1124 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
| 1125 | 1125 | ?> |
| 1126 | 1126 | <tr class="row-tax"> |
| 1127 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
| 1128 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1127 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
| 1128 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1129 | 1129 | </tr> |
| 1130 | 1130 | <?php |
| 1131 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
| 1131 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
| 1134 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
| 1135 | 1135 | ?> |
| 1136 | 1136 | <tr class="table-active row-total"> |
| 1137 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1138 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1137 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1138 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1139 | 1139 | </tr> |
| 1140 | 1140 | <?php |
| 1141 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
| 1141 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
| 1142 | 1142 | |
| 1143 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
| 1143 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | ?> |
| 1146 | 1146 | </tbody> |
@@ -1152,56 +1152,56 @@ discard block |
||
| 1152 | 1152 | /** |
| 1153 | 1153 | * @param WPInv_Invoice $invoice |
| 1154 | 1154 | */ |
| 1155 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 1155 | +function wpinv_display_invoice_notes($invoice) { |
|
| 1156 | 1156 | |
| 1157 | - $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' ); |
|
| 1157 | + $notes = wpinv_get_invoice_notes($invoice->ID, 'customer'); |
|
| 1158 | 1158 | |
| 1159 | - if ( empty( $notes ) ) { |
|
| 1159 | + if (empty($notes)) { |
|
| 1160 | 1160 | return; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | echo '<div class="wpi_invoice_notes_container">'; |
| 1164 | - echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>'; |
|
| 1164 | + echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>'; |
|
| 1165 | 1165 | echo '<ul class="wpi_invoice_notes">'; |
| 1166 | 1166 | |
| 1167 | - foreach( $notes as $note ) { |
|
| 1168 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 1167 | + foreach ($notes as $note) { |
|
| 1168 | + wpinv_get_invoice_note_line_item($note); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | echo '</ul>'; |
| 1172 | 1172 | echo '</div>'; |
| 1173 | 1173 | } |
| 1174 | -add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' ); |
|
| 1174 | +add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes'); |
|
| 1175 | 1175 | |
| 1176 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
| 1176 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
| 1177 | 1177 | $use_taxes = wpinv_use_taxes(); |
| 1178 | 1178 | |
| 1179 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
| 1179 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
| 1180 | 1180 | ?> |
| 1181 | 1181 | <table class="table table-sm table-bordered table-responsive"> |
| 1182 | 1182 | <tbody> |
| 1183 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
| 1183 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
| 1184 | 1184 | <tr class="row-sub-total"> |
| 1185 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
| 1186 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1185 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
| 1186 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1187 | 1187 | </tr> |
| 1188 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
| 1189 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 1188 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
| 1189 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 1190 | 1190 | <tr class="row-discount"> |
| 1191 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
| 1192 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1191 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
| 1192 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1193 | 1193 | </tr> |
| 1194 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
| 1194 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
| 1195 | 1195 | <?php } ?> |
| 1196 | - <?php if ( $use_taxes ) { ?> |
|
| 1196 | + <?php if ($use_taxes) { ?> |
|
| 1197 | 1197 | <tr class="row-tax"> |
| 1198 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
| 1199 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1198 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
| 1199 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1200 | 1200 | </tr> |
| 1201 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
| 1201 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
| 1202 | 1202 | <?php } ?> |
| 1203 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
| 1204 | - <?php foreach ( $fees as $fee ) { ?> |
|
| 1203 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
| 1204 | + <?php foreach ($fees as $fee) { ?> |
|
| 1205 | 1205 | <tr class="row-fee"> |
| 1206 | 1206 | <td class="rate"><?php echo $fee['label']; ?></td> |
| 1207 | 1207 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1209,82 +1209,82 @@ discard block |
||
| 1209 | 1209 | <?php } ?> |
| 1210 | 1210 | <?php } ?> |
| 1211 | 1211 | <tr class="table-active row-total"> |
| 1212 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
| 1213 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1212 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
| 1213 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1214 | 1214 | </tr> |
| 1215 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
| 1215 | + <?php do_action('wpinv_after_totals'); ?> |
|
| 1216 | 1216 | </tbody> |
| 1217 | 1217 | |
| 1218 | 1218 | </table> |
| 1219 | 1219 | |
| 1220 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
| 1220 | + <?php do_action('wpinv_after_totals_table'); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
| 1224 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1223 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
| 1224 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1225 | 1225 | |
| 1226 | 1226 | ob_start(); |
| 1227 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
| 1228 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 1227 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
| 1228 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 1229 | 1229 | ?> |
| 1230 | 1230 | <div class="wpi-payment-info"> |
| 1231 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
| 1232 | - <?php if ( $gateway_title ) { ?> |
|
| 1233 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
| 1231 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
| 1232 | + <?php if ($gateway_title) { ?> |
|
| 1233 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
| 1234 | 1234 | <?php } ?> |
| 1235 | 1235 | </div> |
| 1236 | 1236 | <?php |
| 1237 | 1237 | } |
| 1238 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
| 1238 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
| 1239 | 1239 | $outout = ob_get_clean(); |
| 1240 | 1240 | |
| 1241 | - if ( $echo ) { |
|
| 1241 | + if ($echo) { |
|
| 1242 | 1242 | echo $outout; |
| 1243 | 1243 | } else { |
| 1244 | 1244 | return $outout; |
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | -function wpinv_display_style( $invoice ) { |
|
| 1249 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
| 1248 | +function wpinv_display_style($invoice) { |
|
| 1249 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
| 1250 | 1250 | |
| 1251 | - wp_print_styles( 'open-sans' ); |
|
| 1252 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1251 | + wp_print_styles('open-sans'); |
|
| 1252 | + wp_print_styles('wpinv-single-style'); |
|
| 1253 | 1253 | |
| 1254 | 1254 | $custom_css = wpinv_get_option('template_custom_css'); |
| 1255 | - if(isset($custom_css) && !empty($custom_css)){ |
|
| 1256 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 1257 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 1255 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 1256 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 1257 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 1258 | 1258 | echo '<style type="text/css">'; |
| 1259 | 1259 | echo $custom_css; |
| 1260 | 1260 | echo '</style>'; |
| 1261 | 1261 | } |
| 1262 | 1262 | } |
| 1263 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1264 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 1263 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1264 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1265 | 1265 | |
| 1266 | 1266 | function wpinv_checkout_billing_details() { |
| 1267 | - $invoice_id = (int)wpinv_get_invoice_cart_id(); |
|
| 1267 | + $invoice_id = (int) wpinv_get_invoice_cart_id(); |
|
| 1268 | 1268 | if (empty($invoice_id)) { |
| 1269 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1269 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
| 1270 | 1270 | return null; |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1273 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1274 | 1274 | if (empty($invoice)) { |
| 1275 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1275 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
| 1276 | 1276 | return null; |
| 1277 | 1277 | } |
| 1278 | 1278 | $user_id = $invoice->get_user_id(); |
| 1279 | 1279 | $user_info = $invoice->get_user_info(); |
| 1280 | - $address_info = wpinv_get_user_address( $user_id ); |
|
| 1280 | + $address_info = wpinv_get_user_address($user_id); |
|
| 1281 | 1281 | |
| 1282 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
| 1282 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
| 1283 | 1283 | $user_info['first_name'] = $user_info['first_name']; |
| 1284 | 1284 | $user_info['last_name'] = $user_info['last_name']; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
| 1287 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
| 1288 | 1288 | $user_info['country'] = $address_info['country']; |
| 1289 | 1289 | $user_info['state'] = $address_info['state']; |
| 1290 | 1290 | $user_info['city'] = $address_info['city']; |
@@ -1300,99 +1300,99 @@ discard block |
||
| 1300 | 1300 | 'address' |
| 1301 | 1301 | ); |
| 1302 | 1302 | |
| 1303 | - foreach ( $address_fields as $field ) { |
|
| 1304 | - if ( empty( $user_info[$field] ) ) { |
|
| 1303 | + foreach ($address_fields as $field) { |
|
| 1304 | + if (empty($user_info[$field])) { |
|
| 1305 | 1305 | $user_info[$field] = $address_info[$field]; |
| 1306 | 1306 | } |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
| 1309 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | function wpinv_admin_get_line_items($invoice = array()) { |
| 1313 | 1313 | $item_quantities = wpinv_item_quantities_enabled(); |
| 1314 | 1314 | $use_taxes = wpinv_use_taxes(); |
| 1315 | 1315 | |
| 1316 | - if ( empty( $invoice ) ) { |
|
| 1316 | + if (empty($invoice)) { |
|
| 1317 | 1317 | return NULL; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | $cart_items = $invoice->get_cart_details(); |
| 1321 | - if ( empty( $cart_items ) ) { |
|
| 1321 | + if (empty($cart_items)) { |
|
| 1322 | 1322 | return NULL; |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | ob_start(); |
| 1326 | 1326 | |
| 1327 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
| 1327 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
| 1328 | 1328 | |
| 1329 | 1329 | $count = 0; |
| 1330 | - foreach ( $cart_items as $key => $cart_item ) { |
|
| 1330 | + foreach ($cart_items as $key => $cart_item) { |
|
| 1331 | 1331 | $item_id = $cart_item['id']; |
| 1332 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
| 1332 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
| 1333 | 1333 | |
| 1334 | 1334 | if (empty($wpi_item)) { |
| 1335 | 1335 | continue; |
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
| 1339 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1340 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
| 1338 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
| 1339 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1340 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
| 1341 | 1341 | $can_remove = true; |
| 1342 | 1342 | |
| 1343 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
| 1343 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
| 1344 | 1344 | |
| 1345 | 1345 | $item_tax = ''; |
| 1346 | 1346 | $tax_rate = ''; |
| 1347 | - if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1348 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1349 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1350 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1347 | + if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1348 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1349 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1350 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1351 | 1351 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
| 1352 | 1352 | } |
| 1353 | 1353 | $line_item_tax = $item_tax . $tax_rate; |
| 1354 | 1354 | |
| 1355 | - if ( $line_item_tax === '' ) { |
|
| 1355 | + if ($line_item_tax === '') { |
|
| 1356 | 1356 | $line_item_tax = 0; // Zero tax |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
| 1359 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
| 1360 | 1360 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
| 1361 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
| 1362 | - if ( $summary !== '' ) { |
|
| 1363 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 1361 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
| 1362 | + if ($summary !== '') { |
|
| 1363 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 1364 | 1364 | } |
| 1365 | 1365 | $line_item .= '</td>'; |
| 1366 | 1366 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
| 1367 | 1367 | |
| 1368 | - if ( $item_quantities ) { |
|
| 1369 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
| 1368 | + if ($item_quantities) { |
|
| 1369 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
| 1370 | 1370 | $can_remove = false; |
| 1371 | 1371 | } |
| 1372 | 1372 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 1373 | 1373 | } else { |
| 1374 | - if ( count( $cart_items ) == 1 ) { |
|
| 1374 | + if (count($cart_items) == 1) { |
|
| 1375 | 1375 | $can_remove = false; |
| 1376 | 1376 | } |
| 1377 | 1377 | } |
| 1378 | 1378 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 1379 | 1379 | |
| 1380 | - if ( $use_taxes ) { |
|
| 1380 | + if ($use_taxes) { |
|
| 1381 | 1381 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1382 | 1382 | } |
| 1383 | 1383 | $line_item .= '<td class="action">'; |
| 1384 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
| 1384 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 1385 | 1385 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 1386 | 1386 | } |
| 1387 | 1387 | $line_item .= '</td>'; |
| 1388 | 1388 | $line_item .= '</tr>'; |
| 1389 | 1389 | |
| 1390 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
| 1390 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
| 1391 | 1391 | |
| 1392 | 1392 | $count++; |
| 1393 | 1393 | } |
| 1394 | 1394 | |
| 1395 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
| 1395 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
| 1396 | 1396 | |
| 1397 | 1397 | return ob_get_clean(); |
| 1398 | 1398 | } |
@@ -1404,32 +1404,32 @@ discard block |
||
| 1404 | 1404 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
| 1405 | 1405 | |
| 1406 | 1406 | //Maybe update the prices |
| 1407 | - if(! empty( $_GET['wpi_dynamic_item'] ) && ! empty( $_GET['wpi_dynamic_price'] ) ) { |
|
| 1407 | + if (!empty($_GET['wpi_dynamic_item']) && !empty($_GET['wpi_dynamic_price'])) { |
|
| 1408 | 1408 | |
| 1409 | 1409 | //If the invoice exists, update it with new pricing details |
| 1410 | - if (! empty( $wpi_checkout_id ) ) { |
|
| 1410 | + if (!empty($wpi_checkout_id)) { |
|
| 1411 | 1411 | |
| 1412 | 1412 | $_invoice = wpinv_get_invoice_cart(); |
| 1413 | 1413 | $_cart_details = $_invoice->get_cart_details(); |
| 1414 | - $_dynamic_item = sanitize_text_field( $_GET['wpi_dynamic_item'] ); |
|
| 1414 | + $_dynamic_item = sanitize_text_field($_GET['wpi_dynamic_item']); |
|
| 1415 | 1415 | |
| 1416 | 1416 | //First, fetch the item |
| 1417 | - $item = new WPInv_Item( $_dynamic_item ); |
|
| 1417 | + $item = new WPInv_Item($_dynamic_item); |
|
| 1418 | 1418 | |
| 1419 | 1419 | //Next, ensure it supports dynamic pricing... |
| 1420 | - if( $item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing() ) { |
|
| 1420 | + if ($item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing()) { |
|
| 1421 | 1421 | |
| 1422 | 1422 | //... and that the new price is not lower than the minimum price |
| 1423 | - $_dynamic_price = (float) wpinv_sanitize_amount( sanitize_text_field( $_GET['wpi_dynamic_price'] ) ); |
|
| 1424 | - if( $_dynamic_price < $item->get_minimum_price() ) { |
|
| 1423 | + $_dynamic_price = (float) wpinv_sanitize_amount(sanitize_text_field($_GET['wpi_dynamic_price'])); |
|
| 1424 | + if ($_dynamic_price < $item->get_minimum_price()) { |
|
| 1425 | 1425 | $_dynamic_price = $item->get_minimum_price(); |
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | 1428 | //Finally, update our invoice with the new price |
| 1429 | - if ( !empty( $_cart_details ) ) { |
|
| 1429 | + if (!empty($_cart_details)) { |
|
| 1430 | 1430 | |
| 1431 | - foreach ( $_cart_details as $key => $item ) { |
|
| 1432 | - if ( !empty( $item['id'] ) && $_dynamic_item == $item['id'] ) { |
|
| 1431 | + foreach ($_cart_details as $key => $item) { |
|
| 1432 | + if (!empty($item['id']) && $_dynamic_item == $item['id']) { |
|
| 1433 | 1433 | $_cart_details[$key]['custom_price'] = $_dynamic_price; |
| 1434 | 1434 | $_cart_details[$key]['item_price'] = $_dynamic_price; |
| 1435 | 1435 | } |
@@ -1437,8 +1437,8 @@ discard block |
||
| 1437 | 1437 | |
| 1438 | 1438 | $_meta = $_invoice->get_meta(); |
| 1439 | 1439 | $_meta['cart_details'] = $_cart_details; |
| 1440 | - $_invoice->set( 'payment_meta', $_meta ); |
|
| 1441 | - $_invoice->set( 'cart_details', $_cart_details ); |
|
| 1440 | + $_invoice->set('payment_meta', $_meta); |
|
| 1441 | + $_invoice->set('cart_details', $_cart_details); |
|
| 1442 | 1442 | $_invoice->recalculate_totals(); |
| 1443 | 1443 | |
| 1444 | 1444 | } |
@@ -1449,60 +1449,60 @@ discard block |
||
| 1449 | 1449 | |
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 1452 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 1453 | 1453 | |
| 1454 | 1454 | ob_start(); |
| 1455 | - do_action( 'wpinv_checkout_content_before' ); |
|
| 1455 | + do_action('wpinv_checkout_content_before'); |
|
| 1456 | 1456 | echo '<div id="wpinv_checkout_wrap">'; |
| 1457 | 1457 | |
| 1458 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
| 1458 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
| 1459 | 1459 | ?> |
| 1460 | 1460 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
| 1461 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
| 1461 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
| 1462 | 1462 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
| 1463 | 1463 | <?php |
| 1464 | - do_action( 'wpinv_checkout_form_top' ); |
|
| 1465 | - do_action( 'wpinv_checkout_billing_info' ); |
|
| 1466 | - do_action( 'wpinv_checkout_cart' ); |
|
| 1467 | - do_action( 'wpinv_payment_mode_select' ); |
|
| 1468 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
| 1464 | + do_action('wpinv_checkout_form_top'); |
|
| 1465 | + do_action('wpinv_checkout_billing_info'); |
|
| 1466 | + do_action('wpinv_checkout_cart'); |
|
| 1467 | + do_action('wpinv_payment_mode_select'); |
|
| 1468 | + do_action('wpinv_checkout_form_bottom') |
|
| 1469 | 1469 | ?> |
| 1470 | 1470 | </form> |
| 1471 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
| 1471 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
| 1472 | 1472 | </div><!--end #wpinv_checkout_form_wrap--> |
| 1473 | 1473 | <?php |
| 1474 | 1474 | } else { |
| 1475 | - do_action( 'wpinv_cart_empty' ); |
|
| 1475 | + do_action('wpinv_cart_empty'); |
|
| 1476 | 1476 | } |
| 1477 | 1477 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
| 1478 | - do_action( 'wpinv_checkout_content_after' ); |
|
| 1478 | + do_action('wpinv_checkout_content_after'); |
|
| 1479 | 1479 | return ob_get_clean(); |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
| 1482 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
| 1483 | 1483 | global $ajax_cart_details; |
| 1484 | 1484 | $ajax_cart_details = $cart_details; |
| 1485 | 1485 | |
| 1486 | 1486 | ob_start(); |
| 1487 | - do_action( 'wpinv_before_checkout_cart' ); |
|
| 1487 | + do_action('wpinv_before_checkout_cart'); |
|
| 1488 | 1488 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
| 1489 | 1489 | echo '<div id="wpinv_checkout_cart_wrap">'; |
| 1490 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
| 1490 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
| 1491 | 1491 | echo '</div>'; |
| 1492 | 1492 | echo '</div>'; |
| 1493 | - do_action( 'wpinv_after_checkout_cart' ); |
|
| 1493 | + do_action('wpinv_after_checkout_cart'); |
|
| 1494 | 1494 | $content = ob_get_clean(); |
| 1495 | 1495 | |
| 1496 | - if ( $echo ) { |
|
| 1496 | + if ($echo) { |
|
| 1497 | 1497 | echo $content; |
| 1498 | 1498 | } else { |
| 1499 | 1499 | return $content; |
| 1500 | 1500 | } |
| 1501 | 1501 | } |
| 1502 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
| 1502 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
| 1503 | 1503 | |
| 1504 | 1504 | function wpinv_empty_cart_message() { |
| 1505 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1505 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | /** |
@@ -1514,83 +1514,83 @@ discard block |
||
| 1514 | 1514 | function wpinv_empty_checkout_cart() { |
| 1515 | 1515 | echo wpinv_empty_cart_message(); |
| 1516 | 1516 | } |
| 1517 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1517 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1518 | 1518 | |
| 1519 | 1519 | function wpinv_update_cart_button() { |
| 1520 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1520 | + if (!wpinv_item_quantities_enabled()) |
|
| 1521 | 1521 | return; |
| 1522 | 1522 | ?> |
| 1523 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
| 1523 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
| 1524 | 1524 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1525 | 1525 | <?php |
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | 1528 | function wpinv_checkout_cart_columns() { |
| 1529 | 1529 | $default = 3; |
| 1530 | - if ( wpinv_item_quantities_enabled() ) { |
|
| 1530 | + if (wpinv_item_quantities_enabled()) { |
|
| 1531 | 1531 | $default++; |
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | - if ( wpinv_use_taxes() ) { |
|
| 1534 | + if (wpinv_use_taxes()) { |
|
| 1535 | 1535 | $default++; |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
| 1538 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | function wpinv_display_cart_messages() { |
| 1542 | 1542 | global $wpi_session; |
| 1543 | 1543 | |
| 1544 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
| 1544 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
| 1545 | 1545 | |
| 1546 | - if ( $messages ) { |
|
| 1547 | - foreach ( $messages as $message_id => $message ) { |
|
| 1546 | + if ($messages) { |
|
| 1547 | + foreach ($messages as $message_id => $message) { |
|
| 1548 | 1548 | // Try and detect what type of message this is |
| 1549 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
| 1549 | + if (strpos(strtolower($message), 'error')) { |
|
| 1550 | 1550 | $type = 'error'; |
| 1551 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
| 1551 | + } elseif (strpos(strtolower($message), 'success')) { |
|
| 1552 | 1552 | $type = 'success'; |
| 1553 | 1553 | } else { |
| 1554 | 1554 | $type = 'info'; |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
| 1557 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
| 1558 | 1558 | |
| 1559 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 1559 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 1560 | 1560 | // Loop message codes and display messages |
| 1561 | 1561 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
| 1562 | 1562 | echo '</div>'; |
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | 1565 | // Remove all of the cart saving messages |
| 1566 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
| 1566 | + $wpi_session->set('wpinv_cart_messages', null); |
|
| 1567 | 1567 | } |
| 1568 | 1568 | } |
| 1569 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
| 1569 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
| 1570 | 1570 | |
| 1571 | 1571 | function wpinv_discount_field() { |
| 1572 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
| 1572 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
| 1573 | 1573 | return; // Only show before a payment method has been selected if ajax is disabled |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | - if ( !wpinv_is_checkout() ) { |
|
| 1576 | + if (!wpinv_is_checkout()) { |
|
| 1577 | 1577 | return; |
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
| 1580 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
| 1581 | 1581 | ?> |
| 1582 | 1582 | <div id="wpinv-discount-field" class="panel panel-default"> |
| 1583 | 1583 | <div class="panel-body"> |
| 1584 | 1584 | <p> |
| 1585 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
| 1586 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
| 1585 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
| 1586 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
| 1587 | 1587 | </p> |
| 1588 | 1588 | <div class="form-group row"> |
| 1589 | 1589 | <div class="col-sm-4"> |
| 1590 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
| 1590 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
| 1591 | 1591 | </div> |
| 1592 | 1592 | <div class="col-sm-3"> |
| 1593 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
| 1593 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
| 1594 | 1594 | </div> |
| 1595 | 1595 | <div style="clear:both"></div> |
| 1596 | 1596 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1603,10 +1603,10 @@ discard block |
||
| 1603 | 1603 | <?php |
| 1604 | 1604 | } |
| 1605 | 1605 | } |
| 1606 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
| 1606 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
| 1607 | 1607 | |
| 1608 | 1608 | function wpinv_agree_to_terms_js() { |
| 1609 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 1609 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 1610 | 1610 | ?> |
| 1611 | 1611 | <script type="text/javascript"> |
| 1612 | 1612 | jQuery(document).ready(function($){ |
@@ -1621,125 +1621,125 @@ discard block |
||
| 1621 | 1621 | <?php |
| 1622 | 1622 | } |
| 1623 | 1623 | } |
| 1624 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
| 1624 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
| 1625 | 1625 | |
| 1626 | 1626 | function wpinv_payment_mode_select() { |
| 1627 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 1628 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
| 1629 | - $invoice = wpinv_get_invoice( 0, true ); |
|
| 1627 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 1628 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
| 1629 | + $invoice = wpinv_get_invoice(0, true); |
|
| 1630 | 1630 | |
| 1631 | 1631 | do_action('wpinv_payment_mode_top'); |
| 1632 | - $invoice_id = (int)$invoice->ID; |
|
| 1633 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
| 1632 | + $invoice_id = (int) $invoice->ID; |
|
| 1633 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
| 1634 | 1634 | ?> |
| 1635 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
| 1636 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
| 1635 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
| 1636 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
| 1637 | 1637 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
| 1638 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
| 1638 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
| 1639 | 1639 | <div class="panel-body list-group wpi-payment_methods"> |
| 1640 | 1640 | <?php |
| 1641 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
| 1642 | - |
|
| 1643 | - if ( !empty( $gateways ) ) { |
|
| 1644 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1645 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1646 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1647 | - $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id ); |
|
| 1648 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1641 | + do_action('wpinv_payment_mode_before_gateways'); |
|
| 1642 | + |
|
| 1643 | + if (!empty($gateways)) { |
|
| 1644 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 1645 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
| 1646 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
| 1647 | + $gateway_label = wpinv_get_gateway_checkout_label($gateway_id); |
|
| 1648 | + $description = wpinv_get_gateway_description($gateway_id); |
|
| 1649 | 1649 | ?> |
| 1650 | 1650 | <div class="list-group-item"> |
| 1651 | 1651 | <div class="radio"> |
| 1652 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label> |
|
| 1652 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label> |
|
| 1653 | 1653 | </div> |
| 1654 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
| 1655 | - <?php if ( !empty( $description ) ) { ?> |
|
| 1656 | - <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div> |
|
| 1654 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
| 1655 | + <?php if (!empty($description)) { ?> |
|
| 1656 | + <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div> |
|
| 1657 | 1657 | <?php } ?> |
| 1658 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
| 1658 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
| 1659 | 1659 | </div> |
| 1660 | 1660 | </div> |
| 1661 | 1661 | <?php |
| 1662 | 1662 | } |
| 1663 | 1663 | } else { |
| 1664 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
| 1664 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
| 1667 | + do_action('wpinv_payment_mode_after_gateways'); |
|
| 1668 | 1668 | ?> |
| 1669 | 1669 | </div> |
| 1670 | 1670 | </div> |
| 1671 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
| 1671 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
| 1672 | 1672 | </div> |
| 1673 | 1673 | <?php |
| 1674 | 1674 | do_action('wpinv_payment_mode_bottom'); |
| 1675 | 1675 | } |
| 1676 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
| 1676 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
| 1677 | 1677 | |
| 1678 | 1678 | function wpinv_checkout_billing_info() { |
| 1679 | - if ( wpinv_is_checkout() ) { |
|
| 1679 | + if (wpinv_is_checkout()) { |
|
| 1680 | 1680 | $billing_details = wpinv_checkout_billing_details(); |
| 1681 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1681 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1682 | 1682 | ?> |
| 1683 | 1683 | <div id="wpinv-fields" class="clearfix"> |
| 1684 | 1684 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
| 1685 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
| 1685 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
| 1686 | 1686 | <div id="wpinv-fields-box" class="panel-body"> |
| 1687 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
| 1687 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
| 1688 | 1688 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1689 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1689 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1690 | 1690 | <?php |
| 1691 | - echo wpinv_html_text( array( |
|
| 1691 | + echo wpinv_html_text(array( |
|
| 1692 | 1692 | 'id' => 'wpinv_first_name', |
| 1693 | 1693 | 'name' => 'wpinv_first_name', |
| 1694 | 1694 | 'value' => $billing_details['first_name'], |
| 1695 | 1695 | 'class' => 'wpi-input form-control', |
| 1696 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
| 1697 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
| 1698 | - ) ); |
|
| 1696 | + 'placeholder' => __('First name', 'invoicing'), |
|
| 1697 | + 'required' => (bool) wpinv_get_option('fname_mandatory'), |
|
| 1698 | + )); |
|
| 1699 | 1699 | ?> |
| 1700 | 1700 | </p> |
| 1701 | 1701 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1702 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1702 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1703 | 1703 | <?php |
| 1704 | - echo wpinv_html_text( array( |
|
| 1704 | + echo wpinv_html_text(array( |
|
| 1705 | 1705 | 'id' => 'wpinv_last_name', |
| 1706 | 1706 | 'name' => 'wpinv_last_name', |
| 1707 | 1707 | 'value' => $billing_details['last_name'], |
| 1708 | 1708 | 'class' => 'wpi-input form-control', |
| 1709 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
| 1710 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
| 1711 | - ) ); |
|
| 1709 | + 'placeholder' => __('Last name', 'invoicing'), |
|
| 1710 | + 'required' => (bool) wpinv_get_option('lname_mandatory'), |
|
| 1711 | + )); |
|
| 1712 | 1712 | ?> |
| 1713 | 1713 | </p> |
| 1714 | 1714 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1715 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1715 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1716 | 1716 | <?php |
| 1717 | - echo wpinv_html_text( array( |
|
| 1717 | + echo wpinv_html_text(array( |
|
| 1718 | 1718 | 'id' => 'wpinv_address', |
| 1719 | 1719 | 'name' => 'wpinv_address', |
| 1720 | 1720 | 'value' => $billing_details['address'], |
| 1721 | 1721 | 'class' => 'wpi-input form-control', |
| 1722 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
| 1723 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
| 1724 | - ) ); |
|
| 1722 | + 'placeholder' => __('Address', 'invoicing'), |
|
| 1723 | + 'required' => (bool) wpinv_get_option('address_mandatory'), |
|
| 1724 | + )); |
|
| 1725 | 1725 | ?> |
| 1726 | 1726 | </p> |
| 1727 | 1727 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1728 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1728 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1729 | 1729 | <?php |
| 1730 | - echo wpinv_html_text( array( |
|
| 1730 | + echo wpinv_html_text(array( |
|
| 1731 | 1731 | 'id' => 'wpinv_city', |
| 1732 | 1732 | 'name' => 'wpinv_city', |
| 1733 | 1733 | 'value' => $billing_details['city'], |
| 1734 | 1734 | 'class' => 'wpi-input form-control', |
| 1735 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
| 1736 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
| 1737 | - ) ); |
|
| 1735 | + 'placeholder' => __('City', 'invoicing'), |
|
| 1736 | + 'required' => (bool) wpinv_get_option('city_mandatory'), |
|
| 1737 | + )); |
|
| 1738 | 1738 | ?> |
| 1739 | 1739 | </p> |
| 1740 | 1740 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1741 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1742 | - <?php echo wpinv_html_select( array( |
|
| 1741 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1742 | + <?php echo wpinv_html_select(array( |
|
| 1743 | 1743 | 'options' => wpinv_get_country_list(), |
| 1744 | 1744 | 'name' => 'wpinv_country', |
| 1745 | 1745 | 'id' => 'wpinv_country', |
@@ -1747,16 +1747,16 @@ discard block |
||
| 1747 | 1747 | 'show_option_all' => false, |
| 1748 | 1748 | 'show_option_none' => false, |
| 1749 | 1749 | 'class' => 'wpi-input form-control wpi_select2', |
| 1750 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 1751 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
| 1752 | - ) ); ?> |
|
| 1750 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 1751 | + 'required' => (bool) wpinv_get_option('country_mandatory'), |
|
| 1752 | + )); ?> |
|
| 1753 | 1753 | </p> |
| 1754 | 1754 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1755 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1755 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1756 | 1756 | <?php |
| 1757 | - $states = wpinv_get_country_states( $selected_country ); |
|
| 1758 | - if( !empty( $states ) ) { |
|
| 1759 | - echo wpinv_html_select( array( |
|
| 1757 | + $states = wpinv_get_country_states($selected_country); |
|
| 1758 | + if (!empty($states)) { |
|
| 1759 | + echo wpinv_html_select(array( |
|
| 1760 | 1760 | 'options' => $states, |
| 1761 | 1761 | 'name' => 'wpinv_state', |
| 1762 | 1762 | 'id' => 'wpinv_state', |
@@ -1764,61 +1764,61 @@ discard block |
||
| 1764 | 1764 | 'show_option_all' => false, |
| 1765 | 1765 | 'show_option_none' => false, |
| 1766 | 1766 | 'class' => 'wpi-input form-control wpi_select2', |
| 1767 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 1768 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1769 | - ) ); |
|
| 1767 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 1768 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
| 1769 | + )); |
|
| 1770 | 1770 | } else { |
| 1771 | - echo wpinv_html_text( array( |
|
| 1771 | + echo wpinv_html_text(array( |
|
| 1772 | 1772 | 'name' => 'wpinv_state', |
| 1773 | 1773 | 'value' => $billing_details['state'], |
| 1774 | 1774 | 'id' => 'wpinv_state', |
| 1775 | 1775 | 'class' => 'wpi-input form-control', |
| 1776 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
| 1777 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1778 | - ) ); |
|
| 1776 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
| 1777 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
| 1778 | + )); |
|
| 1779 | 1779 | } |
| 1780 | 1780 | ?> |
| 1781 | 1781 | </p> |
| 1782 | 1782 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1783 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1783 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1784 | 1784 | <?php |
| 1785 | - echo wpinv_html_text( array( |
|
| 1785 | + echo wpinv_html_text(array( |
|
| 1786 | 1786 | 'name' => 'wpinv_zip', |
| 1787 | 1787 | 'value' => $billing_details['zip'], |
| 1788 | 1788 | 'id' => 'wpinv_zip', |
| 1789 | 1789 | 'class' => 'wpi-input form-control', |
| 1790 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 1791 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
| 1792 | - ) ); |
|
| 1790 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
| 1791 | + 'required' => (bool) wpinv_get_option('zip_mandatory'), |
|
| 1792 | + )); |
|
| 1793 | 1793 | ?> |
| 1794 | 1794 | </p> |
| 1795 | 1795 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1796 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1796 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1797 | 1797 | <?php |
| 1798 | - echo wpinv_html_text( array( |
|
| 1798 | + echo wpinv_html_text(array( |
|
| 1799 | 1799 | 'id' => 'wpinv_phone', |
| 1800 | 1800 | 'name' => 'wpinv_phone', |
| 1801 | 1801 | 'value' => $billing_details['phone'], |
| 1802 | 1802 | 'class' => 'wpi-input form-control', |
| 1803 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
| 1804 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
| 1805 | - ) ); |
|
| 1803 | + 'placeholder' => __('Phone', 'invoicing'), |
|
| 1804 | + 'required' => (bool) wpinv_get_option('phone_mandatory'), |
|
| 1805 | + )); |
|
| 1806 | 1806 | ?> |
| 1807 | 1807 | </p> |
| 1808 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
| 1808 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
| 1809 | 1809 | <div class="clearfix"></div> |
| 1810 | 1810 | </div> |
| 1811 | 1811 | </div> |
| 1812 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
| 1812 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
| 1813 | 1813 | </div> |
| 1814 | 1814 | <?php |
| 1815 | 1815 | } |
| 1816 | 1816 | } |
| 1817 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
| 1817 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
| 1818 | 1818 | |
| 1819 | 1819 | function wpinv_checkout_hidden_fields() { |
| 1820 | 1820 | ?> |
| 1821 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 1821 | + <?php if (is_user_logged_in()) { ?> |
|
| 1822 | 1822 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
| 1823 | 1823 | <?php } ?> |
| 1824 | 1824 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1828,9 +1828,9 @@ discard block |
||
| 1828 | 1828 | function wpinv_checkout_button_purchase() { |
| 1829 | 1829 | ob_start(); |
| 1830 | 1830 | ?> |
| 1831 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
| 1831 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
| 1832 | 1832 | <?php |
| 1833 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
| 1833 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | function wpinv_checkout_total() { |
@@ -1839,84 +1839,84 @@ discard block |
||
| 1839 | 1839 | <div id="wpinv_checkout_total" class="panel panel-info"> |
| 1840 | 1840 | <div class="panel-body"> |
| 1841 | 1841 | <?php |
| 1842 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
| 1842 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
| 1843 | 1843 | ?> |
| 1844 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
| 1844 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
| 1845 | 1845 | <?php |
| 1846 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
| 1846 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
| 1847 | 1847 | ?> |
| 1848 | 1848 | </div> |
| 1849 | 1849 | </div> |
| 1850 | 1850 | <?php |
| 1851 | 1851 | } |
| 1852 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
| 1852 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
| 1853 | 1853 | |
| 1854 | 1854 | function wpinv_checkout_accept_tandc() { |
| 1855 | - $page = wpinv_get_option( 'tandc_page' ); |
|
| 1855 | + $page = wpinv_get_option('tandc_page'); |
|
| 1856 | 1856 | ?> |
| 1857 | 1857 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
| 1858 | 1858 | <div class="panel-body"> |
| 1859 | 1859 | <?php echo wpinv_get_policy_text(); ?> |
| 1860 | 1860 | <?php |
| 1861 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
| 1862 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
| 1861 | + if (isset($page) && (int) $page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
| 1862 | + $terms_link = esc_url(get_permalink($page)); |
|
| 1863 | 1863 | ?> |
| 1864 | 1864 | <label class=""> |
| 1865 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
| 1865 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
| 1866 | 1866 | </label> |
| 1867 | 1867 | <?php } ?> |
| 1868 | 1868 | </div> |
| 1869 | 1869 | </div> |
| 1870 | 1870 | <?php |
| 1871 | 1871 | } |
| 1872 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
| 1872 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
| 1873 | 1873 | |
| 1874 | 1874 | function wpinv_checkout_submit() { |
| 1875 | 1875 | ?> |
| 1876 | 1876 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
| 1877 | 1877 | <div class="panel-body text-center"> |
| 1878 | 1878 | <?php |
| 1879 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
| 1879 | + do_action('wpinv_purchase_form_before_submit'); |
|
| 1880 | 1880 | wpinv_checkout_hidden_fields(); |
| 1881 | 1881 | echo wpinv_checkout_button_purchase(); |
| 1882 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
| 1882 | + do_action('wpinv_purchase_form_after_submit'); |
|
| 1883 | 1883 | ?> |
| 1884 | 1884 | </div> |
| 1885 | 1885 | </div> |
| 1886 | 1886 | <?php |
| 1887 | 1887 | } |
| 1888 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
| 1888 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
| 1889 | 1889 | |
| 1890 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1891 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1890 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1891 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1892 | 1892 | |
| 1893 | - if ( empty( $invoice ) ) { |
|
| 1893 | + if (empty($invoice)) { |
|
| 1894 | 1894 | return NULL; |
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | $billing_details = $invoice->get_user_info(); |
| 1898 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 1898 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 1899 | 1899 | |
| 1900 | 1900 | ob_start(); |
| 1901 | 1901 | ?> |
| 1902 | 1902 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1903 | 1903 | <tbody> |
| 1904 | 1904 | <tr class="wpi-receipt-name"> |
| 1905 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1906 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1905 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1906 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1907 | 1907 | </tr> |
| 1908 | 1908 | <tr class="wpi-receipt-email"> |
| 1909 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1910 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1909 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1910 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1911 | 1911 | </tr> |
| 1912 | 1912 | <tr class="wpi-receipt-address"> |
| 1913 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1914 | - <td><?php echo $address_row ;?></td> |
|
| 1913 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1914 | + <td><?php echo $address_row; ?></td> |
|
| 1915 | 1915 | </tr> |
| 1916 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1916 | + <?php if ($billing_details['phone']) { ?> |
|
| 1917 | 1917 | <tr class="wpi-receipt-phone"> |
| 1918 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1919 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1918 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1919 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1920 | 1920 | </tr> |
| 1921 | 1921 | <?php } ?> |
| 1922 | 1922 | </tbody> |
@@ -1924,74 +1924,74 @@ discard block |
||
| 1924 | 1924 | <?php |
| 1925 | 1925 | $output = ob_get_clean(); |
| 1926 | 1926 | |
| 1927 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1927 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1928 | 1928 | |
| 1929 | 1929 | echo $output; |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1933 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1934 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
| 1935 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
| 1932 | +function wpinv_filter_success_page_content($content) { |
|
| 1933 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1934 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
| 1935 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
| 1936 | 1936 | } |
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | return $content; |
| 1940 | 1940 | } |
| 1941 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1941 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1942 | 1942 | |
| 1943 | -function wpinv_receipt_actions( $invoice ) { |
|
| 1944 | - if ( !empty( $invoice ) ) { |
|
| 1943 | +function wpinv_receipt_actions($invoice) { |
|
| 1944 | + if (!empty($invoice)) { |
|
| 1945 | 1945 | $actions = array(); |
| 1946 | 1946 | |
| 1947 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
| 1948 | - $actions['print'] = array( |
|
| 1949 | - 'url' => $invoice->get_view_url( true ), |
|
| 1950 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
| 1947 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
| 1948 | + $actions['print'] = array( |
|
| 1949 | + 'url' => $invoice->get_view_url(true), |
|
| 1950 | + 'name' => __('Print Invoice', 'invoicing'), |
|
| 1951 | 1951 | 'class' => 'btn-primary', |
| 1952 | 1952 | ); |
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | - if ( is_user_logged_in() ) { |
|
| 1955 | + if (is_user_logged_in()) { |
|
| 1956 | 1956 | $actions['history'] = array( |
| 1957 | 1957 | 'url' => wpinv_get_history_page_uri(), |
| 1958 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 1958 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 1959 | 1959 | 'class' => 'btn-warning', |
| 1960 | 1960 | ); |
| 1961 | 1961 | } |
| 1962 | 1962 | |
| 1963 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
| 1963 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
| 1964 | 1964 | |
| 1965 | - if ( !empty( $actions ) ) { |
|
| 1965 | + if (!empty($actions)) { |
|
| 1966 | 1966 | ?> |
| 1967 | 1967 | <div class="wpinv-receipt-actions text-right"> |
| 1968 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
| 1969 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
| 1968 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
| 1969 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
| 1970 | 1970 | <?php } ?> |
| 1971 | 1971 | </div> |
| 1972 | 1972 | <?php |
| 1973 | 1973 | } |
| 1974 | 1974 | } |
| 1975 | 1975 | } |
| 1976 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
| 1976 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
| 1977 | 1977 | |
| 1978 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1979 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1978 | +function wpinv_invoice_link($invoice_id) { |
|
| 1979 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1980 | 1980 | |
| 1981 | - if ( empty( $invoice ) ) { |
|
| 1981 | + if (empty($invoice)) { |
|
| 1982 | 1982 | return NULL; |
| 1983 | 1983 | } |
| 1984 | 1984 | |
| 1985 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1985 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1986 | 1986 | |
| 1987 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1987 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1988 | 1988 | } |
| 1989 | 1989 | |
| 1990 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
| 1991 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
| 1992 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
| 1990 | +function wpinv_invoice_subscription_details($invoice) { |
|
| 1991 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
| 1992 | + $subscription = wpinv_get_subscription($invoice, true); |
|
| 1993 | 1993 | |
| 1994 | - if ( empty( $subscription ) ) { |
|
| 1994 | + if (empty($subscription)) { |
|
| 1995 | 1995 | return; |
| 1996 | 1996 | } |
| 1997 | 1997 | |
@@ -2002,15 +2002,15 @@ discard block |
||
| 2002 | 2002 | $payments = $subscription->get_child_payments(); |
| 2003 | 2003 | ?> |
| 2004 | 2004 | <div class="wpinv-subscriptions-details"> |
| 2005 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
| 2005 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
| 2006 | 2006 | <table class="table"> |
| 2007 | 2007 | <thead> |
| 2008 | 2008 | <tr> |
| 2009 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
| 2010 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
| 2011 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
| 2012 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
| 2013 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
| 2009 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
| 2010 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
| 2011 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
| 2012 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
| 2013 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
| 2014 | 2014 | </tr> |
| 2015 | 2015 | </thead> |
| 2016 | 2016 | <tbody> |
@@ -2024,29 +2024,29 @@ discard block |
||
| 2024 | 2024 | </tbody> |
| 2025 | 2025 | </table> |
| 2026 | 2026 | </div> |
| 2027 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 2027 | + <?php if (!empty($payments)) { ?> |
|
| 2028 | 2028 | <div class="wpinv-renewal-payments"> |
| 2029 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
| 2029 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
| 2030 | 2030 | <table class="table"> |
| 2031 | 2031 | <thead> |
| 2032 | 2032 | <tr> |
| 2033 | 2033 | <th>#</th> |
| 2034 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
| 2035 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
| 2036 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
| 2034 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 2035 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 2036 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
| 2037 | 2037 | </tr> |
| 2038 | 2038 | </thead> |
| 2039 | 2039 | <tbody> |
| 2040 | 2040 | <?php |
| 2041 | 2041 | $i = 1; |
| 2042 | - foreach ( $payments as $payment ) { |
|
| 2042 | + foreach ($payments as $payment) { |
|
| 2043 | 2043 | $invoice_id = $payment->ID; |
| 2044 | 2044 | ?> |
| 2045 | 2045 | <tr> |
| 2046 | - <th scope="row"><?php echo $i;?></th> |
|
| 2047 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
| 2048 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
| 2049 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
| 2046 | + <th scope="row"><?php echo $i; ?></th> |
|
| 2047 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
| 2048 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
| 2049 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
| 2050 | 2050 | </tr> |
| 2051 | 2051 | <?php $i++; } ?> |
| 2052 | 2052 | </tbody> |
@@ -2057,52 +2057,52 @@ discard block |
||
| 2057 | 2057 | } |
| 2058 | 2058 | } |
| 2059 | 2059 | |
| 2060 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 2061 | - if ( empty( $invoice ) ) { |
|
| 2060 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 2061 | + if (empty($invoice)) { |
|
| 2062 | 2062 | return $label; |
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | 2065 | $prefix_label = ''; |
| 2066 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 2067 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 2068 | - } else if ( $invoice->is_renewal() ) { |
|
| 2069 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 2066 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 2067 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 2068 | + } else if ($invoice->is_renewal()) { |
|
| 2069 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | - if ( $prefix_label != '' ) { |
|
| 2073 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2072 | + if ($prefix_label != '') { |
|
| 2073 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | return $label; |
| 2077 | 2077 | } |
| 2078 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2079 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2080 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2078 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2079 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2080 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2081 | 2081 | |
| 2082 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
| 2082 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
| 2083 | 2083 | |
| 2084 | -function wpinv_invoice_print_description( $invoice ) { |
|
| 2085 | - if ( empty( $invoice ) ) { |
|
| 2084 | +function wpinv_invoice_print_description($invoice) { |
|
| 2085 | + if (empty($invoice)) { |
|
| 2086 | 2086 | return NULL; |
| 2087 | 2087 | } |
| 2088 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
| 2088 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
| 2089 | 2089 | ?> |
| 2090 | 2090 | <div class="row wpinv-lower"> |
| 2091 | 2091 | <div class="col-sm-12 wpinv-description"> |
| 2092 | - <?php echo wpautop( $description ); ?> |
|
| 2092 | + <?php echo wpautop($description); ?> |
|
| 2093 | 2093 | </div> |
| 2094 | 2094 | </div> |
| 2095 | 2095 | <?php |
| 2096 | 2096 | } |
| 2097 | 2097 | } |
| 2098 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
| 2098 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
| 2099 | 2099 | |
| 2100 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
| 2101 | - if ( empty( $invoice ) ) { |
|
| 2100 | +function wpinv_invoice_print_payment_info($invoice) { |
|
| 2101 | + if (empty($invoice)) { |
|
| 2102 | 2102 | return NULL; |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
| 2105 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
| 2106 | 2106 | ?> |
| 2107 | 2107 | <div class="row wpinv-payments"> |
| 2108 | 2108 | <div class="col-sm-12"> |
@@ -2114,43 +2114,43 @@ discard block |
||
| 2114 | 2114 | } |
| 2115 | 2115 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
| 2116 | 2116 | |
| 2117 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 2118 | - if ( empty( $note ) ) { |
|
| 2117 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 2118 | + if (empty($note)) { |
|
| 2119 | 2119 | return NULL; |
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | - if ( is_int( $note ) ) { |
|
| 2123 | - $note = get_comment( $note ); |
|
| 2122 | + if (is_int($note)) { |
|
| 2123 | + $note = get_comment($note); |
|
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 2126 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 2127 | 2127 | return NULL; |
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - $note_classes = array( 'note' ); |
|
| 2131 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 2130 | + $note_classes = array('note'); |
|
| 2131 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 2132 | 2132 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 2133 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 2134 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 2133 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 2134 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 2135 | 2135 | |
| 2136 | 2136 | ob_start(); |
| 2137 | 2137 | ?> |
| 2138 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
| 2138 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
| 2139 | 2139 | <div class="note_content"> |
| 2140 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 2140 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 2141 | 2141 | </div> |
| 2142 | 2142 | <p class="meta"> |
| 2143 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
| 2144 | - <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?> |
|
| 2145 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 2143 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
| 2144 | + <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?> |
|
| 2145 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 2146 | 2146 | <?php } ?> |
| 2147 | 2147 | </p> |
| 2148 | 2148 | </li> |
| 2149 | 2149 | <?php |
| 2150 | 2150 | $note_content = ob_get_clean(); |
| 2151 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 2151 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 2152 | 2152 | |
| 2153 | - if ( $echo ) { |
|
| 2153 | + if ($echo) { |
|
| 2154 | 2154 | echo $note_content; |
| 2155 | 2155 | } else { |
| 2156 | 2156 | return $note_content; |
@@ -2160,43 +2160,43 @@ discard block |
||
| 2160 | 2160 | function wpinv_invalid_invoice_content() { |
| 2161 | 2161 | global $post; |
| 2162 | 2162 | |
| 2163 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 2163 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 2164 | 2164 | |
| 2165 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 2166 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 2167 | - if ( is_user_logged_in() ) { |
|
| 2168 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2169 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2170 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 2165 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 2166 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 2167 | + if (is_user_logged_in()) { |
|
| 2168 | + if (wpinv_require_login_to_checkout()) { |
|
| 2169 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2170 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | } |
| 2173 | 2173 | } else { |
| 2174 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2175 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2176 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 2174 | + if (wpinv_require_login_to_checkout()) { |
|
| 2175 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2176 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 2177 | 2177 | } |
| 2178 | 2178 | } |
| 2179 | 2179 | } |
| 2180 | 2180 | } else { |
| 2181 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 2181 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 2182 | 2182 | } |
| 2183 | 2183 | ?> |
| 2184 | 2184 | <div class="row wpinv-row-invalid"> |
| 2185 | 2185 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 2186 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 2186 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 2187 | 2187 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 2188 | 2188 | </div> |
| 2189 | 2189 | </div> |
| 2190 | 2190 | <?php |
| 2191 | 2191 | } |
| 2192 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 2192 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 2193 | 2193 | |
| 2194 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2195 | -function wpinv_force_company_name_field(){ |
|
| 2194 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2195 | +function wpinv_force_company_name_field() { |
|
| 2196 | 2196 | $invoice = wpinv_get_invoice_cart(); |
| 2197 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
| 2198 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 2199 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
| 2197 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
| 2198 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 2199 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
| 2200 | 2200 | ?> |
| 2201 | 2201 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 2202 | 2202 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2222,21 +2222,21 @@ discard block |
||
| 2222 | 2222 | * @return string |
| 2223 | 2223 | */ |
| 2224 | 2224 | function wpinv_get_policy_text() { |
| 2225 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 2225 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 2226 | 2226 | |
| 2227 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 2227 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 2228 | 2228 | |
| 2229 | - if(!$privacy_page_id){ |
|
| 2230 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 2229 | + if (!$privacy_page_id) { |
|
| 2230 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 2233 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 2234 | 2234 | |
| 2235 | 2235 | $find_replace = array( |
| 2236 | 2236 | '[wpinv_privacy_policy]' => $privacy_link, |
| 2237 | 2237 | ); |
| 2238 | 2238 | |
| 2239 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 2239 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 2240 | 2240 | |
| 2241 | 2241 | return wp_kses_post(wpautop($privacy_text)); |
| 2242 | 2242 | } |
@@ -2245,25 +2245,25 @@ discard block |
||
| 2245 | 2245 | /** |
| 2246 | 2246 | * Allows the user to set their own price for an invoice item |
| 2247 | 2247 | */ |
| 2248 | -function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) { |
|
| 2248 | +function wpinv_checkout_cart_item_name_your_price($cart_item, $key) { |
|
| 2249 | 2249 | |
| 2250 | 2250 | //Ensure we have an item id |
| 2251 | - if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) { |
|
| 2251 | + if (!is_array($cart_item) || empty($cart_item['id'])) { |
|
| 2252 | 2252 | return; |
| 2253 | 2253 | } |
| 2254 | 2254 | |
| 2255 | 2255 | //Fetch the item |
| 2256 | 2256 | $item_id = $cart_item['id']; |
| 2257 | - $item = new WPInv_Item( $item_id ); |
|
| 2257 | + $item = new WPInv_Item($item_id); |
|
| 2258 | 2258 | |
| 2259 | - if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) { |
|
| 2259 | + if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) { |
|
| 2260 | 2260 | return; |
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | //Fetch the dynamic pricing "strings" |
| 2264 | - $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) ); |
|
| 2265 | - $minimum_price_text = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) ); |
|
| 2266 | - $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) ); |
|
| 2264 | + $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing'))); |
|
| 2265 | + $minimum_price_text = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing'))); |
|
| 2266 | + $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing'))); |
|
| 2267 | 2267 | |
| 2268 | 2268 | //Display a "name_your_price" button |
| 2269 | 2269 | echo " — <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>"; |
@@ -2272,7 +2272,7 @@ discard block |
||
| 2272 | 2272 | echo '<div class="name-your-price-miniform">'; |
| 2273 | 2273 | |
| 2274 | 2274 | //Maybe display the recommended price |
| 2275 | - if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) { |
|
| 2275 | + if ($item->get_price() > 0 && !empty($suggested_price_text)) { |
|
| 2276 | 2276 | $suggested_price = $item->get_the_price(); |
| 2277 | 2277 | echo "<div>$suggested_price_text — $suggested_price</div>"; |
| 2278 | 2278 | } |
@@ -2280,50 +2280,50 @@ discard block |
||
| 2280 | 2280 | //Display the update price form |
| 2281 | 2281 | $symbol = wpinv_currency_symbol(); |
| 2282 | 2282 | $position = wpinv_currency_position(); |
| 2283 | - $minimum = esc_attr( $item->get_minimum_price() ); |
|
| 2284 | - $price = esc_attr( $cart_item['item_price'] ); |
|
| 2285 | - $update = esc_attr__( "Update", 'invoicing' ); |
|
| 2283 | + $minimum = esc_attr($item->get_minimum_price()); |
|
| 2284 | + $price = esc_attr($cart_item['item_price']); |
|
| 2285 | + $update = esc_attr__("Update", 'invoicing'); |
|
| 2286 | 2286 | |
| 2287 | 2287 | //Ensure it supports dynamic prici |
| 2288 | - if( $price < $minimum ) { |
|
| 2288 | + if ($price < $minimum) { |
|
| 2289 | 2289 | $price = $minimum; |
| 2290 | 2290 | } |
| 2291 | 2291 | |
| 2292 | 2292 | echo '<label>'; |
| 2293 | 2293 | echo $position != 'right' ? $symbol . ' ' : ''; |
| 2294 | 2294 | echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />"; |
| 2295 | - echo $position == 'right' ? ' ' . $symbol : '' ; |
|
| 2295 | + echo $position == 'right' ? ' ' . $symbol : ''; |
|
| 2296 | 2296 | echo "</label>"; |
| 2297 | 2297 | echo "<input type='hidden' value='$item_id' class='wpi-field-item' />"; |
| 2298 | 2298 | echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>"; |
| 2299 | 2299 | |
| 2300 | 2300 | //Maybe display the minimum price |
| 2301 | - if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) { |
|
| 2302 | - $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) ); |
|
| 2301 | + if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) { |
|
| 2302 | + $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price())); |
|
| 2303 | 2303 | echo "<div>$minimum_price_text — $minimum_price</div>"; |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | echo "</div>"; |
| 2307 | 2307 | |
| 2308 | 2308 | } |
| 2309 | -add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 ); |
|
| 2309 | +add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2); |
|
| 2310 | 2310 | |
| 2311 | 2311 | function wpinv_oxygen_fix_conflict() { |
| 2312 | 2312 | global $ct_ignore_post_types; |
| 2313 | 2313 | |
| 2314 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 2314 | + if (!is_array($ct_ignore_post_types)) { |
|
| 2315 | 2315 | $ct_ignore_post_types = array(); |
| 2316 | 2316 | } |
| 2317 | 2317 | |
| 2318 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
| 2318 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
| 2319 | 2319 | |
| 2320 | - foreach ( $post_types as $post_type ) { |
|
| 2320 | + foreach ($post_types as $post_type) { |
|
| 2321 | 2321 | $ct_ignore_post_types[] = $post_type; |
| 2322 | 2322 | |
| 2323 | 2323 | // Ignore post type |
| 2324 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 2324 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 2325 | 2325 | } |
| 2326 | 2326 | |
| 2327 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 2328 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 2327 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 2328 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 2329 | 2329 | } |
| 2330 | 2330 | \ No newline at end of file |