@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | * @param int the item ID to retrieve. |
| 15 | 15 | * @return WPInv_Item|false |
| 16 | 16 | */ |
| 17 | -function wpinv_get_item_by_id( $id ) { |
|
| 18 | - $item = wpinv_get_item( $id ); |
|
| 19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
| 17 | +function wpinv_get_item_by_id($id) { |
|
| 18 | + $item = wpinv_get_item($id); |
|
| 19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return WPInv_Item|false |
| 26 | 26 | */ |
| 27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
| 27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
| 28 | 28 | |
| 29 | - if ( 'id' == strtolower( $field ) ) { |
|
| 30 | - return wpinv_get_item_by_id( $field ); |
|
| 29 | + if ('id' == strtolower($field)) { |
|
| 30 | + return wpinv_get_item_by_id($field); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
| 34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
| 33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
| 34 | + return empty($id) ? false : wpinv_get_item($id); |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
@@ -41,24 +41,24 @@ discard block |
||
| 41 | 41 | * @param int|WPInv_Item the item to retrieve. |
| 42 | 42 | * @return WPInv_Item|false |
| 43 | 43 | */ |
| 44 | -function wpinv_get_item( $item = 0 ) { |
|
| 44 | +function wpinv_get_item($item = 0) { |
|
| 45 | 45 | |
| 46 | - if ( empty( $item ) ) { |
|
| 46 | + if (empty($item)) { |
|
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $item = new WPInv_Item( $item ); |
|
| 50 | + $item = new WPInv_Item($item); |
|
| 51 | 51 | return $item->exists() ? $item : false; |
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -function wpinv_get_all_items( $args = array() ) { |
|
| 55 | +function wpinv_get_all_items($args = array()) { |
|
| 56 | 56 | |
| 57 | 57 | $args = wp_parse_args( |
| 58 | 58 | $args, |
| 59 | 59 | array( |
| 60 | - 'status' => array( 'publish' ), |
|
| 61 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 60 | + 'status' => array('publish'), |
|
| 61 | + 'limit' => get_option('posts_per_page'), |
|
| 62 | 62 | 'page' => 1, |
| 63 | 63 | 'exclude' => array(), |
| 64 | 64 | 'orderby' => 'date', |
@@ -78,44 +78,44 @@ discard block |
||
| 78 | 78 | 'fields' => 'ids', |
| 79 | 79 | 'orderby' => $args['orderby'], |
| 80 | 80 | 'order' => $args['order'], |
| 81 | - 'paged' => absint( $args['page'] ), |
|
| 81 | + 'paged' => absint($args['page']), |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - if ( ! empty( $args['exclude'] ) ) { |
|
| 85 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
| 84 | + if (!empty($args['exclude'])) { |
|
| 85 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( ! $args['paginate'] ) { |
|
| 88 | + if (!$args['paginate']) { |
|
| 89 | 89 | $wp_query_args['no_found_rows'] = true; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if ( ! empty( $args['search'] ) ) { |
|
| 92 | + if (!empty($args['search'])) { |
|
| 93 | 93 | $wp_query_args['s'] = $args['search']; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
| 97 | - $types = wpinv_parse_list( $args['type'] ); |
|
| 96 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
| 97 | + $types = wpinv_parse_list($args['type']); |
|
| 98 | 98 | $wp_query_args['meta_query'][] = array( |
| 99 | 99 | 'key' => '_wpinv_type', |
| 100 | - 'value' => implode( ',', $types ), |
|
| 100 | + 'value' => implode(',', $types), |
|
| 101 | 101 | 'compare' => 'IN', |
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args ); |
|
| 105 | + $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
|
| 106 | 106 | |
| 107 | 107 | // Get results. |
| 108 | - $items = new WP_Query( $wp_query_args ); |
|
| 108 | + $items = new WP_Query($wp_query_args); |
|
| 109 | 109 | |
| 110 | - if ( 'objects' === $args['return'] ) { |
|
| 111 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
| 112 | - } elseif ( 'self' === $args['return'] ) { |
|
| 110 | + if ('objects' === $args['return']) { |
|
| 111 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
| 112 | + } elseif ('self' === $args['return']) { |
|
| 113 | 113 | return $items; |
| 114 | 114 | } else { |
| 115 | 115 | $return = $items->posts; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( $args['paginate'] ) { |
|
| 118 | + if ($args['paginate']) { |
|
| 119 | 119 | return (object) array( |
| 120 | 120 | 'items' => $return, |
| 121 | 121 | 'total' => $items->found_posts, |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
| 131 | - if ( empty( $item_id ) ) { |
|
| 130 | +function wpinv_is_free_item($item_id = 0) { |
|
| 131 | + if (empty($item_id)) { |
|
| 132 | 132 | return false; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $item = new WPInv_Item( $item_id ); |
|
| 135 | + $item = new WPInv_Item($item_id); |
|
| 136 | 136 | |
| 137 | 137 | return $item->is_free(); |
| 138 | 138 | } |
@@ -142,21 +142,21 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
| 144 | 144 | */ |
| 145 | -function wpinv_item_is_editable( $item = 0 ) { |
|
| 145 | +function wpinv_item_is_editable($item = 0) { |
|
| 146 | 146 | |
| 147 | 147 | // Fetch the item. |
| 148 | - $item = new WPInv_Item( $item ); |
|
| 148 | + $item = new WPInv_Item($item); |
|
| 149 | 149 | |
| 150 | 150 | // Check if it is editable. |
| 151 | 151 | return $item->is_editable(); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
| 155 | - if ( empty( $item_id ) ) { |
|
| 154 | +function wpinv_get_item_price($item_id = 0) { |
|
| 155 | + if (empty($item_id)) { |
|
| 156 | 156 | return false; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $item = new WPInv_Item( $item_id ); |
|
| 159 | + $item = new WPInv_Item($item_id); |
|
| 160 | 160 | |
| 161 | 161 | return $item->get_price(); |
| 162 | 162 | } |
@@ -166,88 +166,88 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @param WPInv_Item|int $item |
| 168 | 168 | */ |
| 169 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
| 170 | - $item = new WPInv_Item( $item ); |
|
| 169 | +function wpinv_is_recurring_item($item = 0) { |
|
| 170 | + $item = new WPInv_Item($item); |
|
| 171 | 171 | return $item->is_recurring(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | -function wpinv_item_price( $item_id = 0 ) { |
|
| 175 | - if ( empty( $item_id ) ) { |
|
| 174 | +function wpinv_item_price($item_id = 0) { |
|
| 175 | + if (empty($item_id)) { |
|
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $price = wpinv_get_item_price( $item_id ); |
|
| 180 | - $price = wpinv_price( $price ); |
|
| 179 | + $price = wpinv_get_item_price($item_id); |
|
| 180 | + $price = wpinv_price($price); |
|
| 181 | 181 | |
| 182 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
| 182 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
| 186 | - if ( is_null( $amount_override ) ) { |
|
| 187 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
| 185 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
| 186 | + if (is_null($amount_override)) { |
|
| 187 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
| 188 | 188 | } else { |
| 189 | 189 | $original_price = $amount_override; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $price = $original_price; |
| 193 | 193 | |
| 194 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
| 194 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
| 198 | - if ( empty( $item_id ) ) { |
|
| 197 | +function wpinv_item_custom_singular_name($item_id) { |
|
| 198 | + if (empty($item_id)) { |
|
| 199 | 199 | return false; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $item = new WPInv_Item( $item_id ); |
|
| 202 | + $item = new WPInv_Item($item_id); |
|
| 203 | 203 | |
| 204 | 204 | return $item->get_custom_singular_name(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | function wpinv_get_item_types() { |
| 208 | 208 | $item_types = array( |
| 209 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
| 210 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
| 209 | + 'custom' => __('Standard', 'invoicing'), |
|
| 210 | + 'fee' => __('Fee', 'invoicing'), |
|
| 211 | 211 | ); |
| 212 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
| 212 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | function wpinv_item_types() { |
| 216 | 216 | $item_types = wpinv_get_item_types(); |
| 217 | 217 | |
| 218 | - return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
| 218 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | -function wpinv_get_item_type( $item_id ) { |
|
| 222 | - if ( empty( $item_id ) ) { |
|
| 221 | +function wpinv_get_item_type($item_id) { |
|
| 222 | + if (empty($item_id)) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - $item = new WPInv_Item( $item_id ); |
|
| 226 | + $item = new WPInv_Item($item_id); |
|
| 227 | 227 | |
| 228 | 228 | return $item->get_type(); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | -function wpinv_item_type( $item_id ) { |
|
| 231 | +function wpinv_item_type($item_id) { |
|
| 232 | 232 | $item_types = wpinv_get_item_types(); |
| 233 | 233 | |
| 234 | - $item_type = wpinv_get_item_type( $item_id ); |
|
| 234 | + $item_type = wpinv_get_item_type($item_id); |
|
| 235 | 235 | |
| 236 | - if ( empty( $item_type ) ) { |
|
| 236 | + if (empty($item_type)) { |
|
| 237 | 237 | $item_type = '-'; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' ); |
|
| 240 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
| 241 | 241 | |
| 242 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
| 242 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | -function wpinv_get_random_item( $post_ids = true ) { |
|
| 246 | - wpinv_get_random_items( 1, $post_ids ); |
|
| 245 | +function wpinv_get_random_item($post_ids = true) { |
|
| 246 | + wpinv_get_random_items(1, $post_ids); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
| 250 | - if ( $post_ids ) { |
|
| 249 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
| 250 | + if ($post_ids) { |
|
| 251 | 251 | $args = array( |
| 252 | 252 | 'post_type' => 'wpi_item', |
| 253 | 253 | 'orderby' => 'rand', |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
| 265 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
| 266 | 266 | |
| 267 | - return get_posts( $args ); |
|
| 267 | + return get_posts($args); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | * @param WPInv_Item|int $item |
| 274 | 274 | * @param bool $html |
| 275 | 275 | */ |
| 276 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
| 276 | +function wpinv_get_item_suffix($item, $html = true) { |
|
| 277 | 277 | |
| 278 | - $item = new WPInv_Item( $item ); |
|
| 279 | - $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : ''; |
|
| 280 | - $suffix = $html ? $suffix : wp_strip_all_tags( $suffix ); |
|
| 278 | + $item = new WPInv_Item($item); |
|
| 279 | + $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : ''; |
|
| 280 | + $suffix = $html ? $suffix : wp_strip_all_tags($suffix); |
|
| 281 | 281 | |
| 282 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
| 282 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | * @param WPInv_Item|int $item |
| 289 | 289 | * @param bool $force_delete |
| 290 | 290 | */ |
| 291 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
| 292 | - $item = new WPInv_Item( $item ); |
|
| 293 | - $item->delete( $force_delete ); |
|
| 291 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
| 292 | + $item = new WPInv_Item($item); |
|
| 293 | + $item->delete($force_delete); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -329,44 +329,44 @@ discard block |
||
| 329 | 329 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
| 330 | 330 | * @return bool|WP_Error|WPInv_Item |
| 331 | 331 | */ |
| 332 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
| 332 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
| 333 | 333 | |
| 334 | 334 | // Prepare the item. |
| 335 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
| 336 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
| 337 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
| 335 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
| 336 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
| 337 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
| 338 | 338 | |
| 339 | - if ( ! empty( $item ) ) { |
|
| 339 | + if (!empty($item)) { |
|
| 340 | 340 | $args['ID'] = $item->get_id(); |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Do we have an item? |
| 345 | - if ( ! empty( $args['ID'] ) ) { |
|
| 346 | - $item = new WPInv_Item( $args['ID'] ); |
|
| 345 | + if (!empty($args['ID'])) { |
|
| 346 | + $item = new WPInv_Item($args['ID']); |
|
| 347 | 347 | } else { |
| 348 | 348 | $item = new WPInv_Item(); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Do we have an error? |
| 352 | - if ( ! empty( $item->last_error ) ) { |
|
| 353 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
| 352 | + if (!empty($item->last_error)) { |
|
| 353 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Update item props. |
| 357 | - $item->set_props( $args ); |
|
| 357 | + $item->set_props($args); |
|
| 358 | 358 | |
| 359 | 359 | // Save the item. |
| 360 | 360 | $item->save(); |
| 361 | 361 | |
| 362 | 362 | // Do we have an error? |
| 363 | - if ( ! empty( $item->last_error ) ) { |
|
| 364 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
| 363 | + if (!empty($item->last_error)) { |
|
| 364 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // Was the item saved? |
| 368 | - if ( ! $item->get_id() ) { |
|
| 369 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
| 368 | + if (!$item->get_id()) { |
|
| 369 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | return $item; |
@@ -378,14 +378,14 @@ discard block |
||
| 378 | 378 | * |
| 379 | 379 | * @see wpinv_create_item() |
| 380 | 380 | */ |
| 381 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
| 382 | - return wpinv_create_item( $args, $wp_error ); |
|
| 381 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
| 382 | + return wpinv_create_item($args, $wp_error); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * Sanitizes a recurring period |
| 387 | 387 | */ |
| 388 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
| 388 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
| 389 | 389 | |
| 390 | 390 | $periods = array( |
| 391 | 391 | 'D' => 'day', |
@@ -394,16 +394,16 @@ discard block |
||
| 394 | 394 | 'Y' => 'year', |
| 395 | 395 | ); |
| 396 | 396 | |
| 397 | - if ( ! isset( $periods[ $period ] ) ) { |
|
| 397 | + if (!isset($periods[$period])) { |
|
| 398 | 398 | $period = 'D'; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - return $full ? $periods[ $period ] : $period; |
|
| 401 | + return $full ? $periods[$period] : $period; |
|
| 402 | 402 | |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | -function wpinv_item_max_buyable_quantity( $item_id ) { |
|
| 406 | - return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id ); |
|
| 405 | +function wpinv_item_max_buyable_quantity($item_id) { |
|
| 406 | + return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -411,45 +411,45 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @param WPInv_Item|GetPaid_Form_Item $item |
| 413 | 413 | */ |
| 414 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
| 414 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
| 415 | 415 | |
| 416 | 416 | // Abort if it is not recurring. |
| 417 | - if ( ! $item->is_recurring() ) { |
|
| 417 | + if (!$item->is_recurring()) { |
|
| 418 | 418 | return ''; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
| 422 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
| 423 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
| 421 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
| 422 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
| 423 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
| 424 | 424 | $initial_class = 'getpaid-item-initial-price'; |
| 425 | 425 | $recurring_class = 'getpaid-item-recurring-price'; |
| 426 | 426 | $bill_times = $item->get_recurring_limit(); |
| 427 | 427 | |
| 428 | - if ( ! empty( $bill_times ) ) { |
|
| 428 | + if (!empty($bill_times)) { |
|
| 429 | 429 | $bill_times = $item->get_recurring_interval() * $bill_times; |
| 430 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
| 430 | + $bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
| 434 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
| 435 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
| 433 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
| 434 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
| 435 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
| 439 | - return __( 'Free forever', 'invoicing' ); |
|
| 438 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
| 439 | + return __('Free forever', 'invoicing'); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // For free trial items. |
| 443 | - if ( $item->has_free_trial() ) { |
|
| 444 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
| 443 | + if ($item->has_free_trial()) { |
|
| 444 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
| 445 | 445 | |
| 446 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
| 446 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
| 447 | 447 | |
| 448 | - if ( empty( $bill_times ) ) { |
|
| 448 | + if (empty($bill_times)) { |
|
| 449 | 449 | |
| 450 | 450 | return sprintf( |
| 451 | 451 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
| 452 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
| 452 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
| 453 | 453 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
| 454 | 454 | "<span class='$recurring_class'>$recurring_price</span>", |
| 455 | 455 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | return sprintf( |
| 461 | 461 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times |
| 462 | - _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
| 462 | + _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
| 463 | 463 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
| 464 | 464 | "<span class='$recurring_class'>$recurring_price</span>", |
| 465 | 465 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if ( empty( $bill_times ) ) { |
|
| 471 | + if (empty($bill_times)) { |
|
| 472 | 472 | |
| 473 | 473 | return sprintf( |
| 474 | 474 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
| 475 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
| 475 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
| 476 | 476 | "<span class='$initial_class'>$initial_price</span>", |
| 477 | 477 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
| 478 | 478 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | return sprintf( |
| 485 | 485 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times |
| 486 | - _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ), |
|
| 486 | + _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'), |
|
| 487 | 487 | "<span class='$initial_class'>$initial_price</span>", |
| 488 | 488 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
| 489 | 489 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -493,13 +493,13 @@ discard block |
||
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if ( $initial_price == $recurring_price ) { |
|
| 496 | + if ($initial_price == $recurring_price) { |
|
| 497 | 497 | |
| 498 | - if ( empty( $bill_times ) ) { |
|
| 498 | + if (empty($bill_times)) { |
|
| 499 | 499 | |
| 500 | 500 | return sprintf( |
| 501 | 501 | // translators: $1: is the recurring price, $2: is the susbcription period |
| 502 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
| 502 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
| 503 | 503 | "<span class='$recurring_class'>$recurring_price</span>", |
| 504 | 504 | "<span class='getpaid-item-recurring-period'>$period</span>" |
| 505 | 505 | ); |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | return sprintf( |
| 510 | 510 | // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times |
| 511 | - _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
| 511 | + _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
| 512 | 512 | "<span class='$recurring_class'>$recurring_price</span>", |
| 513 | 513 | "<span class='getpaid-item-recurring-period'>$period</span>", |
| 514 | 514 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -516,13 +516,13 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
| 519 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
| 520 | 520 | |
| 521 | - if ( empty( $bill_times ) ) { |
|
| 521 | + if (empty($bill_times)) { |
|
| 522 | 522 | |
| 523 | 523 | return sprintf( |
| 524 | 524 | // translators: $1: is the recurring period, $2: is the recurring price |
| 525 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
| 525 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
| 526 | 526 | "<span class='getpaid-item-recurring-period'>$period</span>", |
| 527 | 527 | "<span class='$recurring_class'>$recurring_price</span>" |
| 528 | 528 | ); |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | return sprintf( |
| 533 | 533 | // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times |
| 534 | - _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ), |
|
| 534 | + _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'), |
|
| 535 | 535 | "<span class='getpaid-item-recurring-period'>$period</span>", |
| 536 | 536 | "<span class='$recurring_class'>$recurring_price</span>", |
| 537 | 537 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -539,11 +539,11 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - if ( empty( $bill_times ) ) { |
|
| 542 | + if (empty($bill_times)) { |
|
| 543 | 543 | |
| 544 | 544 | return sprintf( |
| 545 | 545 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
| 546 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
| 546 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
| 547 | 547 | "<span class='$initial_class'>$initial_price</span>", |
| 548 | 548 | "<span class='$recurring_class'>$recurring_price</span>", |
| 549 | 549 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | return sprintf( |
| 555 | 555 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times |
| 556 | - _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ), |
|
| 556 | + _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'), |
|
| 557 | 557 | "<span class='$initial_class'>$initial_price</span>", |
| 558 | 558 | "<span class='$recurring_class'>$recurring_price</span>", |
| 559 | 559 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -26,71 +26,71 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | |
| 29 | - // Fires before printing a line item column. |
|
| 30 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
| 29 | + // Fires before printing a line item column. |
|
| 30 | + do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
| 31 | 31 | |
| 32 | - // Item name. |
|
| 33 | - if ( 'name' === $key ) { |
|
| 32 | + // Item name. |
|
| 33 | + if ( 'name' === $key ) { |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - ob_start(); |
|
| 36 | + ob_start(); |
|
| 37 | 37 | |
| 38 | - // Add an optional description. |
|
| 39 | - $description = $item->get_description(); |
|
| 38 | + // Add an optional description. |
|
| 39 | + $description = $item->get_description(); |
|
| 40 | 40 | |
| 41 | - if ( ! empty( $description ) ) { |
|
| 42 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 43 | - } |
|
| 41 | + if ( ! empty( $description ) ) { |
|
| 42 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // Price help text. |
|
| 46 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
| 47 | - if ( $description ) { |
|
| 48 | - echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 49 | - } |
|
| 45 | + // Price help text. |
|
| 46 | + $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
| 47 | + if ( $description ) { |
|
| 48 | + echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
| 51 | + do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
| 52 | 52 | |
| 53 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
| 53 | + if ( wpinv_current_user_can_manage_invoicing() ) { |
|
| 54 | 54 | |
| 55 | - edit_post_link( |
|
| 56 | - __( 'Edit this item.', 'invoicing' ), |
|
| 57 | - '<small class="form-text text-muted">', |
|
| 58 | - '</small>', |
|
| 59 | - $item->get_id(), |
|
| 60 | - 'text-danger' |
|
| 61 | - ); |
|
| 55 | + edit_post_link( |
|
| 56 | + __( 'Edit this item.', 'invoicing' ), |
|
| 57 | + '<small class="form-text text-muted">', |
|
| 58 | + '</small>', |
|
| 59 | + $item->get_id(), |
|
| 60 | + 'text-danger' |
|
| 61 | + ); |
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $description = ob_get_clean(); |
|
| 65 | + $description = ob_get_clean(); |
|
| 66 | 66 | |
| 67 | - // Display the name. |
|
| 68 | - $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
| 67 | + // Display the name. |
|
| 68 | + $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
| 69 | 69 | |
| 70 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 70 | + $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 71 | 71 | |
| 72 | - if ( $has_featured_image ) { |
|
| 73 | - echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
|
| 74 | - echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
| 75 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 76 | - echo '</div>'; |
|
| 77 | - echo '<div class="getpaid-form-item-name-container">'; |
|
| 78 | - } |
|
| 72 | + if ( $has_featured_image ) { |
|
| 73 | + echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
|
| 74 | + echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
| 75 | + echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 76 | + echo '</div>'; |
|
| 77 | + echo '<div class="getpaid-form-item-name-container">'; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
| 80 | + echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
| 81 | 81 | |
| 82 | - if ( ! empty( $description ) ) { |
|
| 83 | - printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
| 84 | - } |
|
| 82 | + if ( ! empty( $description ) ) { |
|
| 83 | + printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - if ( $item->allows_quantities() ) { |
|
| 87 | - printf( |
|
| 88 | - '<small class="d-sm-none text-muted form-text">%s</small>', |
|
| 89 | - sprintf( |
|
| 90 | - // translators: %s is the item quantity. |
|
| 91 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
| 92 | - sprintf( |
|
| 93 | - '<input |
|
| 86 | + if ( $item->allows_quantities() ) { |
|
| 87 | + printf( |
|
| 88 | + '<small class="d-sm-none text-muted form-text">%s</small>', |
|
| 89 | + sprintf( |
|
| 90 | + // translators: %s is the item quantity. |
|
| 91 | + esc_html__( 'Qty %s', 'invoicing' ), |
|
| 92 | + sprintf( |
|
| 93 | + '<input |
|
| 94 | 94 | type="number" |
| 95 | 95 | step="0.01" |
| 96 | 96 | style="width: 48px;" |
@@ -99,62 +99,62 @@ discard block |
||
| 99 | 99 | min="1" |
| 100 | 100 | max="%s" |
| 101 | 101 | >', |
| 102 | - (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
|
| 103 | - floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
| 104 | - ) |
|
| 105 | - ) |
|
| 106 | - ); |
|
| 107 | - } else { |
|
| 108 | - printf( |
|
| 109 | - '<small class="d-sm-none text-muted form-text">%s</small>', |
|
| 110 | - sprintf( |
|
| 111 | - // translators: %s is the item quantity. |
|
| 112 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
| 113 | - (float) $item->get_quantity() |
|
| 114 | - ) |
|
| 115 | - ); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if ( $has_featured_image ) { |
|
| 119 | - echo '</div>'; |
|
| 120 | - echo '</div>'; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // Item price. |
|
| 125 | - if ( 'price' === $key ) { |
|
| 126 | - |
|
| 127 | - // Set the currency position. |
|
| 128 | - $position = wpinv_currency_position(); |
|
| 129 | - |
|
| 130 | - if ( 'left_space' === $position ) { |
|
| 131 | - $position = 'left'; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if ( 'right_space' === $position ) { |
|
| 135 | - $position = 'right'; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ( $item->user_can_set_their_price() ) { |
|
| 139 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
| 140 | - $minimum = (float) $item->get_minimum_price(); |
|
| 141 | - $validate_minimum = ''; |
|
| 142 | - $class = ''; |
|
| 143 | - $data_minimum = ''; |
|
| 144 | - |
|
| 145 | - if ( $minimum > 0 ) { |
|
| 146 | - $validate_minimum = sprintf( |
|
| 147 | - // translators: %s is the minimum price. |
|
| 148 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
| 149 | - wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
| 150 | - ); |
|
| 151 | - |
|
| 152 | - $class = 'getpaid-validate-minimum-amount'; |
|
| 153 | - |
|
| 154 | - $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - ?> |
|
| 102 | + (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
|
| 103 | + floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
| 104 | + ) |
|
| 105 | + ) |
|
| 106 | + ); |
|
| 107 | + } else { |
|
| 108 | + printf( |
|
| 109 | + '<small class="d-sm-none text-muted form-text">%s</small>', |
|
| 110 | + sprintf( |
|
| 111 | + // translators: %s is the item quantity. |
|
| 112 | + esc_html__( 'Qty %s', 'invoicing' ), |
|
| 113 | + (float) $item->get_quantity() |
|
| 114 | + ) |
|
| 115 | + ); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + if ( $has_featured_image ) { |
|
| 119 | + echo '</div>'; |
|
| 120 | + echo '</div>'; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // Item price. |
|
| 125 | + if ( 'price' === $key ) { |
|
| 126 | + |
|
| 127 | + // Set the currency position. |
|
| 128 | + $position = wpinv_currency_position(); |
|
| 129 | + |
|
| 130 | + if ( 'left_space' === $position ) { |
|
| 131 | + $position = 'left'; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if ( 'right_space' === $position ) { |
|
| 135 | + $position = 'right'; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ( $item->user_can_set_their_price() ) { |
|
| 139 | + $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
| 140 | + $minimum = (float) $item->get_minimum_price(); |
|
| 141 | + $validate_minimum = ''; |
|
| 142 | + $class = ''; |
|
| 143 | + $data_minimum = ''; |
|
| 144 | + |
|
| 145 | + if ( $minimum > 0 ) { |
|
| 146 | + $validate_minimum = sprintf( |
|
| 147 | + // translators: %s is the minimum price. |
|
| 148 | + esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
| 149 | + wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
| 150 | + ); |
|
| 151 | + |
|
| 152 | + $class = 'getpaid-validate-minimum-amount'; |
|
| 153 | + |
|
| 154 | + $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + ?> |
|
| 158 | 158 | <div class="input-group input-group-sm"> |
| 159 | 159 | <?php if ( 'left' === $position ) : ?> |
| 160 | 160 | <div class="input-group-prepend"> |
@@ -179,44 +179,44 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | <?php |
| 181 | 181 | |
| 182 | - } else { |
|
| 183 | - echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) ); |
|
| 182 | + } else { |
|
| 183 | + echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) ); |
|
| 184 | 184 | |
| 185 | - ?> |
|
| 185 | + ?> |
|
| 186 | 186 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
| 187 | 187 | <?php |
| 188 | - } |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - printf( |
|
| 190 | + printf( |
|
| 191 | 191 | '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>', |
| 192 | - // translators: %s is the item subtotal. |
|
| 192 | + // translators: %s is the item subtotal. |
|
| 193 | 193 | sprintf( esc_html__( 'Subtotal: %s', 'invoicing' ), wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ) ) |
| 194 | 194 | ); |
| 195 | - } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - // Item quantity. |
|
| 198 | - if ( 'quantity' === $key ) { |
|
| 197 | + // Item quantity. |
|
| 198 | + if ( 'quantity' === $key ) { |
|
| 199 | 199 | |
| 200 | - if ( $item->allows_quantities() ) { |
|
| 201 | - ?> |
|
| 200 | + if ( $item->allows_quantities() ) { |
|
| 201 | + ?> |
|
| 202 | 202 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type="number" step="any" style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' <?php echo null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''; ?> required> |
| 203 | 203 | <?php |
| 204 | - } else { |
|
| 205 | - echo (float) $item->get_quantity(); |
|
| 206 | - echo ' '; |
|
| 207 | - ?> |
|
| 204 | + } else { |
|
| 205 | + echo (float) $item->get_quantity(); |
|
| 206 | + echo ' '; |
|
| 207 | + ?> |
|
| 208 | 208 | <input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'> |
| 209 | 209 | <?php |
| 210 | - } |
|
| 210 | + } |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - // Item sub total. |
|
| 214 | - if ( 'subtotal' === $key ) { |
|
| 215 | - echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
| 216 | - } |
|
| 213 | + // Item sub total. |
|
| 214 | + if ( 'subtotal' === $key ) { |
|
| 215 | + echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
| 219 | - ?> |
|
| 218 | + do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
| 219 | + ?> |
|
| 220 | 220 | |
| 221 | 221 | </div> |
| 222 | 222 | |
@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | * @var GetPaid_Form_Item $item |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
| 14 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
| 15 | 15 | |
| 16 | 16 | $currency = $form->get_currency(); |
| 17 | -$max_qty = wpinv_item_max_buyable_quantity( $item->get_id() ); |
|
| 17 | +$max_qty = wpinv_item_max_buyable_quantity($item->get_id()); |
|
| 18 | 18 | ?> |
| 19 | 19 | <div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo (int) $item->get_id(); ?> border-bottom py-2 px-3'> |
| 20 | 20 | |
| 21 | 21 | <div class="form-row align-items-center needs-validation"> |
| 22 | 22 | |
| 23 | - <?php foreach ( array_keys( $columns ) as $key ) : ?> |
|
| 23 | + <?php foreach (array_keys($columns) as $key) : ?> |
|
| 24 | 24 | |
| 25 | - <div class="<?php echo 'name' === $key ? 'col-6' : 'col'; ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ), true ) ) ? 'd-none d-sm-block' : ''; ?> position-relative getpaid-form-cart-item-<?php echo esc_attr( $key ); ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>-<?php echo (int) $item->get_id(); ?>"> |
|
| 25 | + <div class="<?php echo 'name' === $key ? 'col-6' : 'col'; ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'), true)) ? 'd-none d-sm-block' : ''; ?> position-relative getpaid-form-cart-item-<?php echo esc_attr($key); ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>-<?php echo (int) $item->get_id(); ?>"> |
|
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | |
| 29 | 29 | // Fires before printing a line item column. |
| 30 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
| 30 | + do_action("getpaid_form_cart_item_before_$key", $item, $form); |
|
| 31 | 31 | |
| 32 | 32 | // Item name. |
| 33 | - if ( 'name' === $key ) { |
|
| 33 | + if ('name' === $key) { |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | ob_start(); |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | // Add an optional description. |
| 39 | 39 | $description = $item->get_description(); |
| 40 | 40 | |
| 41 | - if ( ! empty( $description ) ) { |
|
| 42 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 41 | + if (!empty($description)) { |
|
| 42 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post($description) . '</small>'; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Price help text. |
| 46 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
| 47 | - if ( $description ) { |
|
| 48 | - echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 46 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
| 47 | + if ($description) { |
|
| 48 | + echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post($description) . '</small>'; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
| 51 | + do_action('getpaid_payment_form_cart_item_description', $item, $form); |
|
| 52 | 52 | |
| 53 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
| 53 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
| 54 | 54 | |
| 55 | 55 | edit_post_link( |
| 56 | - __( 'Edit this item.', 'invoicing' ), |
|
| 56 | + __('Edit this item.', 'invoicing'), |
|
| 57 | 57 | '<small class="form-text text-muted">', |
| 58 | 58 | '</small>', |
| 59 | 59 | $item->get_id(), |
@@ -65,30 +65,30 @@ discard block |
||
| 65 | 65 | $description = ob_get_clean(); |
| 66 | 66 | |
| 67 | 67 | // Display the name. |
| 68 | - $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
| 68 | + $tootip = empty($description) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
| 69 | 69 | |
| 70 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 70 | + $has_featured_image = has_post_thumbnail($item->get_id()); |
|
| 71 | 71 | |
| 72 | - if ( $has_featured_image ) { |
|
| 72 | + if ($has_featured_image) { |
|
| 73 | 73 | echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
| 74 | 74 | echo '<div class="getpaid-form-item-image-container mr-2">'; |
| 75 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 75 | + echo get_the_post_thumbnail($item->get_id(), 'thumbnail', array('class' => 'getpaid-form-item-image mb-0')); |
|
| 76 | 76 | echo '</div>'; |
| 77 | 77 | echo '<div class="getpaid-form-item-name-container">'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
| 80 | + echo '<div class="mb-1 font-weight-bold">' . esc_html($item->get_name()) . wp_kses_post($tootip) . '</div>'; |
|
| 81 | 81 | |
| 82 | - if ( ! empty( $description ) ) { |
|
| 83 | - printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
| 82 | + if (!empty($description)) { |
|
| 83 | + printf('<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post($description)); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( $item->allows_quantities() ) { |
|
| 86 | + if ($item->allows_quantities()) { |
|
| 87 | 87 | printf( |
| 88 | 88 | '<small class="d-sm-none text-muted form-text">%s</small>', |
| 89 | 89 | sprintf( |
| 90 | 90 | // translators: %s is the item quantity. |
| 91 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
| 91 | + esc_html__('Qty %s', 'invoicing'), |
|
| 92 | 92 | sprintf( |
| 93 | 93 | '<input |
| 94 | 94 | type="number" |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | max="%s" |
| 101 | 101 | >', |
| 102 | 102 | (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
| 103 | - floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
| 103 | + floatval(null !== $max_qty ? $max_qty : 1000000000000) |
|
| 104 | 104 | ) |
| 105 | 105 | ) |
| 106 | 106 | ); |
@@ -109,70 +109,70 @@ discard block |
||
| 109 | 109 | '<small class="d-sm-none text-muted form-text">%s</small>', |
| 110 | 110 | sprintf( |
| 111 | 111 | // translators: %s is the item quantity. |
| 112 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
| 112 | + esc_html__('Qty %s', 'invoicing'), |
|
| 113 | 113 | (float) $item->get_quantity() |
| 114 | 114 | ) |
| 115 | 115 | ); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( $has_featured_image ) { |
|
| 118 | + if ($has_featured_image) { |
|
| 119 | 119 | echo '</div>'; |
| 120 | 120 | echo '</div>'; |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Item price. |
| 125 | - if ( 'price' === $key ) { |
|
| 125 | + if ('price' === $key) { |
|
| 126 | 126 | |
| 127 | 127 | // Set the currency position. |
| 128 | 128 | $position = wpinv_currency_position(); |
| 129 | 129 | |
| 130 | - if ( 'left_space' === $position ) { |
|
| 130 | + if ('left_space' === $position) { |
|
| 131 | 131 | $position = 'left'; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( 'right_space' === $position ) { |
|
| 134 | + if ('right_space' === $position) { |
|
| 135 | 135 | $position = 'right'; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ( $item->user_can_set_their_price() ) { |
|
| 139 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
| 138 | + if ($item->user_can_set_their_price()) { |
|
| 139 | + $price = max((float) $item->get_price(), (float) $item->get_minimum_price()); |
|
| 140 | 140 | $minimum = (float) $item->get_minimum_price(); |
| 141 | 141 | $validate_minimum = ''; |
| 142 | 142 | $class = ''; |
| 143 | 143 | $data_minimum = ''; |
| 144 | 144 | |
| 145 | - if ( $minimum > 0 ) { |
|
| 145 | + if ($minimum > 0) { |
|
| 146 | 146 | $validate_minimum = sprintf( |
| 147 | 147 | // translators: %s is the minimum price. |
| 148 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
| 149 | - wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
| 148 | + esc_attr__('The minimum allowed amount is %s', 'invoicing'), |
|
| 149 | + wp_strip_all_tags(wpinv_price($minimum, $currency)) |
|
| 150 | 150 | ); |
| 151 | 151 | |
| 152 | 152 | $class = 'getpaid-validate-minimum-amount'; |
| 153 | 153 | |
| 154 | - $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
| 154 | + $data_minimum = "data-minimum-amount='" . esc_attr(getpaid_unstandardize_amount($minimum)) . "'"; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | ?> |
| 158 | 158 | <div class="input-group input-group-sm"> |
| 159 | - <?php if ( 'left' === $position ) : ?> |
|
| 159 | + <?php if ('left' === $position) : ?> |
|
| 160 | 160 | <div class="input-group-prepend"> |
| 161 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol( $currency ) ); ?></span> |
|
| 161 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol($currency)); ?></span> |
|
| 162 | 162 | </div> |
| 163 | 163 | <?php endif; ?> |
| 164 | 164 | |
| 165 | - <input type="text" <?php echo wp_kses_post( $data_minimum ); ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $price ) ); ?>" placeholder="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price() ) ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo esc_attr( $class ); ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
| 165 | + <input type="text" <?php echo wp_kses_post($data_minimum); ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr(getpaid_unstandardize_amount($price)); ?>" placeholder="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price())); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo esc_attr($class); ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
| 166 | 166 | |
| 167 | - <?php if ( ! empty( $validate_minimum ) ) : ?> |
|
| 167 | + <?php if (!empty($validate_minimum)) : ?> |
|
| 168 | 168 | <div class="invalid-tooltip"> |
| 169 | - <?php echo wp_kses_post( $validate_minimum ); ?> |
|
| 169 | + <?php echo wp_kses_post($validate_minimum); ?> |
|
| 170 | 170 | </div> |
| 171 | 171 | <?php endif; ?> |
| 172 | 172 | |
| 173 | - <?php if ( 'left' !== $position ) : ?> |
|
| 173 | + <?php if ('left' !== $position) : ?> |
|
| 174 | 174 | <div class="input-group-append"> |
| 175 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol( $currency ) ); ?></span> |
|
| 175 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol($currency)); ?></span> |
|
| 176 | 176 | </div> |
| 177 | 177 | <?php endif; ?> |
| 178 | 178 | </div> |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | <?php |
| 181 | 181 | |
| 182 | 182 | } else { |
| 183 | - echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) ); |
|
| 183 | + echo wp_kses_post(wpinv_price($item->get_price(), $currency)); |
|
| 184 | 184 | |
| 185 | 185 | ?> |
| 186 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
| 186 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
| 187 | 187 | <?php |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | printf( |
| 191 | 191 | '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>', |
| 192 | 192 | // translators: %s is the item subtotal. |
| 193 | - sprintf( esc_html__( 'Subtotal: %s', 'invoicing' ), wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ) ) |
|
| 193 | + sprintf(esc_html__('Subtotal: %s', 'invoicing'), wp_kses_post(wpinv_price($item->get_sub_total(), $currency))) |
|
| 194 | 194 | ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Item quantity. |
| 198 | - if ( 'quantity' === $key ) { |
|
| 198 | + if ('quantity' === $key) { |
|
| 199 | 199 | |
| 200 | - if ( $item->allows_quantities() ) { |
|
| 200 | + if ($item->allows_quantities()) { |
|
| 201 | 201 | ?> |
| 202 | 202 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type="number" step="any" style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' <?php echo null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''; ?> required> |
| 203 | 203 | <?php |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Item sub total. |
| 214 | - if ( 'subtotal' === $key ) { |
|
| 215 | - echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
| 214 | + if ('subtotal' === $key) { |
|
| 215 | + echo wp_kses_post(wpinv_price($item->get_sub_total(), $currency)); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
| 218 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
| 219 | 219 | ?> |
| 220 | 220 | |
| 221 | 221 | </div> |
@@ -226,4 +226,4 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | </div> |
| 228 | 228 | <?php |
| 229 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
| 229 | +do_action('getpaid_payment_form_cart_item', $form, $item); |
|