@@ -6,26 +6,26 @@ discard block |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
11 | 11 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
12 | 12 | ); |
13 | 13 | |
14 | - public static $prefixLengthsPsr4 = array ( |
|
14 | + public static $prefixLengthsPsr4 = array( |
|
15 | 15 | 'C' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'Composer\\Installers\\' => 20, |
18 | 18 | ), |
19 | 19 | ); |
20 | 20 | |
21 | - public static $prefixDirsPsr4 = array ( |
|
21 | + public static $prefixDirsPsr4 = array( |
|
22 | 22 | 'Composer\\Installers\\' => |
23 | - array ( |
|
23 | + array( |
|
24 | 24 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
25 | 25 | ), |
26 | 26 | ); |
27 | 27 | |
28 | - public static $classMap = array ( |
|
28 | + public static $classMap = array( |
|
29 | 29 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
30 | 30 | 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
31 | 31 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public static function getInitializer(ClassLoader $loader) |
35 | 35 | { |
36 | - return \Closure::bind(function () use ($loader) { |
|
36 | + return \Closure::bind(function() use ($loader) { |
|
37 | 37 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
38 | 38 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
39 | 39 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | ?> |
25 | 25 | <div id="wpinv-form-builder" class="bsui"> |
26 | 26 | <div class="row"> |
27 | 27 | <div class="col-sm-4"> |
28 | 28 | |
29 | 29 | <!-- Builder tabs --> |
30 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button> |
|
30 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button> |
|
31 | 31 | |
32 | 32 | <!-- Builder tab content --> |
33 | 33 | <div class="mt-4"> |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | <!-- Available builder elements --> |
36 | 36 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
37 | 37 | <div class="wpinv-form-builder-add-field-types"> |
38 | - <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
38 | + <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
39 | 39 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
40 | 40 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
41 | 41 | <button class="button btn"> |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | <!-- Edit an element --> |
51 | 51 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;"> |
52 | 52 | <div class="wpinv-form-builder-edit-field-wrapper"> |
53 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
54 | - <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?> |
|
53 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
54 | + <?php do_action('getpaid_payment_form_edit_element_template', $post); ?> |
|
55 | 55 | <div class='form-group'> |
56 | - <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ) ?></label> |
|
56 | + <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing') ?></label> |
|
57 | 57 | <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'> |
58 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
59 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
60 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
58 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
59 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
60 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
61 | 61 | </select> |
62 | 62 | </div> |
63 | 63 | <div> |
64 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button> |
|
64 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button> |
|
65 | 65 | </div> |
66 | 66 | </div> |
67 | 67 | </div> |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | |
71 | 71 | </div> |
72 | 72 | <div class="col-sm-8 border-left"> |
73 | - <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
74 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
73 | + <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
74 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
75 | 75 | |
76 | 76 | <div class="container-fluid"> |
77 | 77 | <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;"> |
78 | 78 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element && active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
79 | 79 | <div class="wpinv-form-builder-element-preview-inner"> |
80 | 80 | <div class="wpinv-payment-form-field-preview-overlay"></div> |
81 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
81 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
82 | 82 | </div> |
83 | 83 | </div> |
84 | 84 | </draggable> |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | </div> |
93 | 93 | <?php |
94 | 94 | |
95 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
95 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,33 +100,33 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @param int $post_id |
102 | 102 | */ |
103 | - public static function save( $post_id ) { |
|
103 | + public static function save($post_id) { |
|
104 | 104 | |
105 | 105 | // Prepare the form. |
106 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
106 | + $form = new GetPaid_Payment_Form($post_id); |
|
107 | 107 | |
108 | 108 | // Fetch form items. |
109 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
109 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
110 | 110 | |
111 | 111 | // Ensure that we have an array... |
112 | - if ( empty( $form_items ) ) { |
|
112 | + if (empty($form_items)) { |
|
113 | 113 | $form_items = array(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Add it to the form. |
117 | - $form->set_items( self::item_to_objects( $form_items ) ); |
|
117 | + $form->set_items(self::item_to_objects($form_items)); |
|
118 | 118 | |
119 | 119 | // Save form elements. |
120 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
121 | - if ( empty( $form_elements ) ) { |
|
120 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
121 | + if (empty($form_elements)) { |
|
122 | 122 | $form_elements = array(); |
123 | 123 | } |
124 | 124 | |
125 | - $form->set_elements( $form_elements ); |
|
125 | + $form->set_elements($form_elements); |
|
126 | 126 | |
127 | 127 | // Persist data to the datastore. |
128 | 128 | $form->save(); |
129 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
129 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $items |
137 | 137 | */ |
138 | - public static function item_to_objects( $items ) { |
|
138 | + public static function item_to_objects($items) { |
|
139 | 139 | |
140 | 140 | $objects = array(); |
141 | 141 | |
142 | - foreach ( $items as $item ) { |
|
143 | - $_item = new GetPaid_Form_Item( $item['id'] ); |
|
144 | - $_item->set_allow_quantities( (bool) $item['allow_quantities'] ); |
|
145 | - $_item->set_is_required( (bool) $item['required'] ); |
|
142 | + foreach ($items as $item) { |
|
143 | + $_item = new GetPaid_Form_Item($item['id']); |
|
144 | + $_item->set_allow_quantities((bool) $item['allow_quantities']); |
|
145 | + $_item->set_is_required((bool) $item['required']); |
|
146 | 146 | $objects[] = $_item; |
147 | 147 | } |
148 | 148 |
@@ -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 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -102,36 +102,36 @@ discard block |
||
102 | 102 | 'ip_geolocation' => true, |
103 | 103 | ); |
104 | 104 | |
105 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
106 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
107 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
105 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
106 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
107 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
108 | 108 | |
109 | - if ( $nopriv ) { |
|
110 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
112 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
109 | + if ($nopriv) { |
|
110 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
111 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | public static function add_note() { |
118 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
118 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
119 | 119 | |
120 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
120 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
121 | 121 | die(-1); |
122 | 122 | } |
123 | 123 | |
124 | - $post_id = absint( $_POST['post_id'] ); |
|
125 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
126 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
124 | + $post_id = absint($_POST['post_id']); |
|
125 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
126 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
127 | 127 | |
128 | 128 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
129 | 129 | |
130 | - if ( $post_id > 0 ) { |
|
131 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
130 | + if ($post_id > 0) { |
|
131 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
132 | 132 | |
133 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
134 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
133 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
134 | + wpinv_get_invoice_note_line_item($note_id); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | public static function delete_note() { |
142 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
142 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
143 | 143 | |
144 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
144 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
145 | 145 | die(-1); |
146 | 146 | } |
147 | 147 | |
148 | - $note_id = (int)$_POST['note_id']; |
|
148 | + $note_id = (int) $_POST['note_id']; |
|
149 | 149 | |
150 | - if ( $note_id > 0 ) { |
|
151 | - wp_delete_comment( $note_id, true ); |
|
150 | + if ($note_id > 0) { |
|
151 | + wp_delete_comment($note_id, true); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | die(); |
@@ -166,34 +166,34 @@ discard block |
||
166 | 166 | public static function get_billing_details() { |
167 | 167 | |
168 | 168 | // Verify nonce. |
169 | - check_ajax_referer( 'wpinv-nonce' ); |
|
169 | + check_ajax_referer('wpinv-nonce'); |
|
170 | 170 | |
171 | 171 | // Can the user manage the plugin? |
172 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
172 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
173 | 173 | die(-1); |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Do we have a user id? |
177 | 177 | $user_id = $_GET['user_id']; |
178 | 178 | |
179 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
179 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
180 | 180 | die(-1); |
181 | 181 | } |
182 | 182 | |
183 | 183 | // Fetch the billing details. |
184 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
185 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
184 | + $billing_details = wpinv_get_user_address($user_id); |
|
185 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
186 | 186 | |
187 | 187 | // unset the user id and email. |
188 | - $to_ignore = array( 'user_id', 'email' ); |
|
188 | + $to_ignore = array('user_id', 'email'); |
|
189 | 189 | |
190 | - foreach ( $to_ignore as $key ) { |
|
191 | - if ( isset( $billing_details[ $key ] ) ) { |
|
192 | - unset( $billing_details[ $key ] ); |
|
190 | + foreach ($to_ignore as $key) { |
|
191 | + if (isset($billing_details[$key])) { |
|
192 | + unset($billing_details[$key]); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - wp_send_json_success( $billing_details ); |
|
196 | + wp_send_json_success($billing_details); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
@@ -203,47 +203,47 @@ discard block |
||
203 | 203 | public static function check_new_user_email() { |
204 | 204 | |
205 | 205 | // Verify nonce. |
206 | - check_ajax_referer( 'wpinv-nonce' ); |
|
206 | + check_ajax_referer('wpinv-nonce'); |
|
207 | 207 | |
208 | 208 | // Can the user manage the plugin? |
209 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
209 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
210 | 210 | die(-1); |
211 | 211 | } |
212 | 212 | |
213 | 213 | // We need an email address. |
214 | - if ( empty( $_GET['email'] ) ) { |
|
215 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
214 | + if (empty($_GET['email'])) { |
|
215 | + _e("Provide the new user's email address", 'invoicing'); |
|
216 | 216 | exit; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Ensure the email is valid. |
220 | - $email = sanitize_text_field( $_GET['email'] ); |
|
221 | - if ( ! is_email( $email ) ) { |
|
222 | - _e( 'Invalid email address', 'invoicing' ); |
|
220 | + $email = sanitize_text_field($_GET['email']); |
|
221 | + if (!is_email($email)) { |
|
222 | + _e('Invalid email address', 'invoicing'); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // And it does not exist. |
227 | - if ( email_exists( $email ) ) { |
|
228 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
227 | + if (email_exists($email)) { |
|
228 | + _e('A user with this email address already exists', 'invoicing'); |
|
229 | 229 | exit; |
230 | 230 | } |
231 | 231 | |
232 | - wp_send_json_success( true ); |
|
232 | + wp_send_json_success(true); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | public static function run_tool() { |
236 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
237 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
236 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
237 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
238 | 238 | die(-1); |
239 | 239 | } |
240 | 240 | |
241 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
241 | + $tool = sanitize_text_field($_POST['tool']); |
|
242 | 242 | |
243 | - do_action( 'wpinv_run_tool' ); |
|
243 | + do_action('wpinv_run_tool'); |
|
244 | 244 | |
245 | - if ( !empty( $tool ) ) { |
|
246 | - do_action( 'wpinv_tool_' . $tool ); |
|
245 | + if (!empty($tool)) { |
|
246 | + do_action('wpinv_tool_' . $tool); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -253,27 +253,27 @@ discard block |
||
253 | 253 | public static function get_payment_form() { |
254 | 254 | |
255 | 255 | // Check nonce. |
256 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
256 | + check_ajax_referer('getpaid_form_nonce'); |
|
257 | 257 | |
258 | 258 | // Is the request set up correctly? |
259 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
259 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
260 | 260 | echo aui()->alert( |
261 | 261 | array( |
262 | 262 | 'type' => 'warning', |
263 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
263 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | exit; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // Payment form or button? |
270 | - if ( ! empty( $_GET['form'] ) ) { |
|
271 | - getpaid_display_payment_form( $_GET['form'] ); |
|
272 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
273 | - getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
270 | + if (!empty($_GET['form'])) { |
|
271 | + getpaid_display_payment_form($_GET['form']); |
|
272 | + } else if (!empty($_GET['invoice'])) { |
|
273 | + getpaid_display_invoice_payment_form($_GET['invoice']); |
|
274 | 274 | } else { |
275 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
276 | - getpaid_display_item_payment_form( $items ); |
|
275 | + $items = getpaid_convert_items_to_array($_GET['item']); |
|
276 | + getpaid_display_item_payment_form($items); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | exit; |
@@ -288,17 +288,17 @@ discard block |
||
288 | 288 | public static function payment_form() { |
289 | 289 | |
290 | 290 | // Check nonce. |
291 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
291 | + check_ajax_referer('getpaid_form_nonce'); |
|
292 | 292 | |
293 | 293 | // ... form fields... |
294 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
295 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
294 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
295 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
296 | 296 | exit; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Process the payment form. |
300 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
301 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
300 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
301 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
302 | 302 | $checkout->process_checkout(); |
303 | 303 | |
304 | 304 | exit; |
@@ -311,54 +311,54 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public static function get_payment_form_states_field() { |
313 | 313 | |
314 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
314 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
315 | 315 | exit; |
316 | 316 | } |
317 | 317 | |
318 | - $elements = getpaid_get_payment_form_elements( $_GET['form'] ); |
|
318 | + $elements = getpaid_get_payment_form_elements($_GET['form']); |
|
319 | 319 | |
320 | - if ( empty( $elements ) ) { |
|
320 | + if (empty($elements)) { |
|
321 | 321 | exit; |
322 | 322 | } |
323 | 323 | |
324 | 324 | $address_fields = array(); |
325 | - foreach ( $elements as $element ) { |
|
326 | - if ( 'address' === $element['type'] ) { |
|
325 | + foreach ($elements as $element) { |
|
326 | + if ('address' === $element['type']) { |
|
327 | 327 | $address_fields = $element; |
328 | 328 | break; |
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if ( empty( $address_fields ) ) { |
|
332 | + if (empty($address_fields)) { |
|
333 | 333 | exit; |
334 | 334 | } |
335 | 335 | |
336 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
336 | + foreach ($address_fields['fields'] as $address_field) { |
|
337 | 337 | |
338 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
338 | + if ('wpinv_state' == $address_field['name']) { |
|
339 | 339 | |
340 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
341 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
342 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
343 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
344 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
345 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
340 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
341 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
342 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
343 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
344 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
345 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
346 | 346 | |
347 | - if ( ! empty( $address_field['required'] ) ) { |
|
347 | + if (!empty($address_field['required'])) { |
|
348 | 348 | $label .= "<span class='text-danger'> *</span>"; |
349 | 349 | } |
350 | 350 | |
351 | - $html = getpaid_get_states_select_markup ( |
|
352 | - sanitize_text_field( $_GET['country'] ), |
|
351 | + $html = getpaid_get_states_select_markup( |
|
352 | + sanitize_text_field($_GET['country']), |
|
353 | 353 | $value, |
354 | 354 | $placeholder, |
355 | 355 | $label, |
356 | 356 | $description, |
357 | - ! empty( $address_field['required'] ), |
|
357 | + !empty($address_field['required']), |
|
358 | 358 | $wrap_class |
359 | 359 | ); |
360 | 360 | |
361 | - wp_send_json_success( $html ); |
|
361 | + wp_send_json_success($html); |
|
362 | 362 | exit; |
363 | 363 | |
364 | 364 | } |
@@ -374,56 +374,56 @@ discard block |
||
374 | 374 | public static function recalculate_invoice_totals() { |
375 | 375 | |
376 | 376 | // Verify nonce. |
377 | - check_ajax_referer( 'wpinv-nonce' ); |
|
377 | + check_ajax_referer('wpinv-nonce'); |
|
378 | 378 | |
379 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
379 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
380 | 380 | exit; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // We need an invoice. |
384 | - if ( empty( $_POST['post_id'] ) ) { |
|
384 | + if (empty($_POST['post_id'])) { |
|
385 | 385 | exit; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Fetch the invoice. |
389 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
389 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
390 | 390 | |
391 | 391 | // Ensure it exists. |
392 | - if ( ! $invoice->get_id() ) { |
|
392 | + if (!$invoice->get_id()) { |
|
393 | 393 | exit; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Maybe set the country, state, currency. |
397 | - foreach ( array( 'country', 'state', 'currency' ) as $key ) { |
|
398 | - if ( isset( $_POST[ $key ] ) ) { |
|
397 | + foreach (array('country', 'state', 'currency') as $key) { |
|
398 | + if (isset($_POST[$key])) { |
|
399 | 399 | $method = "set_$key"; |
400 | - $invoice->$method( $_POST[ $key ] ); |
|
400 | + $invoice->$method($_POST[$key]); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | // Maybe disable taxes. |
405 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
405 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
406 | 406 | |
407 | 407 | // Recalculate totals. |
408 | 408 | $invoice->recalculate_total(); |
409 | 409 | |
410 | - $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
410 | + $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
411 | 411 | |
412 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
413 | - $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() ); |
|
414 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
412 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
413 | + $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency()); |
|
414 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | $totals = array( |
418 | - 'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ), |
|
419 | - 'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ), |
|
420 | - 'tax' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ), |
|
418 | + 'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()), |
|
419 | + 'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()), |
|
420 | + 'tax' => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()), |
|
421 | 421 | 'total' => $total, |
422 | 422 | ); |
423 | 423 | |
424 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
424 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
425 | 425 | |
426 | - wp_send_json_success( compact( 'totals' ) ); |
|
426 | + wp_send_json_success(compact('totals')); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -432,33 +432,33 @@ discard block |
||
432 | 432 | public static function get_invoice_items() { |
433 | 433 | |
434 | 434 | // Verify nonce. |
435 | - check_ajax_referer( 'wpinv-nonce' ); |
|
435 | + check_ajax_referer('wpinv-nonce'); |
|
436 | 436 | |
437 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
437 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
438 | 438 | exit; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // We need an invoice and items. |
442 | - if ( empty( $_POST['post_id'] ) ) { |
|
442 | + if (empty($_POST['post_id'])) { |
|
443 | 443 | exit; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Fetch the invoice. |
447 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
447 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
448 | 448 | |
449 | 449 | // Ensure it exists. |
450 | - if ( ! $invoice->get_id() ) { |
|
450 | + if (!$invoice->get_id()) { |
|
451 | 451 | exit; |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Return an array of invoice items. |
455 | 455 | $items = array(); |
456 | 456 | |
457 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
458 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
457 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
458 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
459 | 459 | } |
460 | 460 | |
461 | - wp_send_json_success( compact( 'items' ) ); |
|
461 | + wp_send_json_success(compact('items')); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -467,50 +467,50 @@ discard block |
||
467 | 467 | public static function edit_invoice_item() { |
468 | 468 | |
469 | 469 | // Verify nonce. |
470 | - check_ajax_referer( 'wpinv-nonce' ); |
|
470 | + check_ajax_referer('wpinv-nonce'); |
|
471 | 471 | |
472 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
472 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
473 | 473 | exit; |
474 | 474 | } |
475 | 475 | |
476 | 476 | // We need an invoice and item details. |
477 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
477 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
478 | 478 | exit; |
479 | 479 | } |
480 | 480 | |
481 | 481 | // Fetch the invoice. |
482 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
482 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
483 | 483 | |
484 | 484 | // Ensure it exists and its not been paid for. |
485 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
485 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
486 | 486 | exit; |
487 | 487 | } |
488 | 488 | |
489 | 489 | // Format the data. |
490 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
490 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
491 | 491 | |
492 | 492 | // Ensure that we have an item id. |
493 | - if ( empty( $data['id'] ) ) { |
|
493 | + if (empty($data['id'])) { |
|
494 | 494 | exit; |
495 | 495 | } |
496 | 496 | |
497 | 497 | // Abort if the invoice does not have the specified item. |
498 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
498 | + $item = $invoice->get_item((int) $data['id']); |
|
499 | 499 | |
500 | - if ( empty( $item ) ) { |
|
500 | + if (empty($item)) { |
|
501 | 501 | exit; |
502 | 502 | } |
503 | 503 | |
504 | 504 | // Update the item. |
505 | - $item->set_price( $data['price'] ); |
|
506 | - $item->set_name( $data['name'] ); |
|
507 | - $item->set_description( $data['description'] ); |
|
508 | - $item->set_quantity( $data['quantity'] ); |
|
505 | + $item->set_price($data['price']); |
|
506 | + $item->set_name($data['name']); |
|
507 | + $item->set_description($data['description']); |
|
508 | + $item->set_quantity($data['quantity']); |
|
509 | 509 | |
510 | 510 | // Add it to the invoice. |
511 | - $error = $invoice->add_item( $item ); |
|
511 | + $error = $invoice->add_item($item); |
|
512 | 512 | $alert = false; |
513 | - if ( is_wp_error( $error ) ) { |
|
513 | + if (is_wp_error($error)) { |
|
514 | 514 | $alert = $error->get_error_message(); |
515 | 515 | } |
516 | 516 | |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | // Return an array of invoice items. |
524 | 524 | $items = array(); |
525 | 525 | |
526 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
527 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
526 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
527 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
528 | 528 | } |
529 | 529 | |
530 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
530 | + wp_send_json_success(compact('items', 'alert')); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -536,33 +536,33 @@ discard block |
||
536 | 536 | public static function remove_invoice_item() { |
537 | 537 | |
538 | 538 | // Verify nonce. |
539 | - check_ajax_referer( 'wpinv-nonce' ); |
|
539 | + check_ajax_referer('wpinv-nonce'); |
|
540 | 540 | |
541 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
541 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
542 | 542 | exit; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // We need an invoice and an item. |
546 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
546 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
547 | 547 | exit; |
548 | 548 | } |
549 | 549 | |
550 | 550 | // Fetch the invoice. |
551 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
551 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
552 | 552 | |
553 | 553 | // Ensure it exists and its not been paid for. |
554 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
554 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
555 | 555 | exit; |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Abort if the invoice does not have the specified item. |
559 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
559 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
560 | 560 | |
561 | - if ( empty( $item ) ) { |
|
561 | + if (empty($item)) { |
|
562 | 562 | exit; |
563 | 563 | } |
564 | 564 | |
565 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
565 | + $invoice->remove_item((int) $_POST['item_id']); |
|
566 | 566 | |
567 | 567 | // Update totals. |
568 | 568 | $invoice->recalculate_total(); |
@@ -573,11 +573,11 @@ discard block |
||
573 | 573 | // Return an array of invoice items. |
574 | 574 | $items = array(); |
575 | 575 | |
576 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
577 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
576 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
577 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
578 | 578 | } |
579 | 579 | |
580 | - wp_send_json_success( compact( 'items' ) ); |
|
580 | + wp_send_json_success(compact('items')); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -586,39 +586,39 @@ discard block |
||
586 | 586 | public static function add_invoice_items() { |
587 | 587 | |
588 | 588 | // Verify nonce. |
589 | - check_ajax_referer( 'wpinv-nonce' ); |
|
589 | + check_ajax_referer('wpinv-nonce'); |
|
590 | 590 | |
591 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
591 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
592 | 592 | exit; |
593 | 593 | } |
594 | 594 | |
595 | 595 | // We need an invoice and items. |
596 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
596 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
597 | 597 | exit; |
598 | 598 | } |
599 | 599 | |
600 | 600 | // Fetch the invoice. |
601 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
601 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
602 | 602 | $alert = false; |
603 | 603 | |
604 | 604 | // Ensure it exists and its not been paid for. |
605 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
605 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
606 | 606 | exit; |
607 | 607 | } |
608 | 608 | |
609 | 609 | // Add the items. |
610 | - foreach ( $_POST['items'] as $data ) { |
|
610 | + foreach ($_POST['items'] as $data) { |
|
611 | 611 | |
612 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
612 | + $item = new GetPaid_Form_Item($data['id']); |
|
613 | 613 | |
614 | - if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) { |
|
615 | - $item->set_quantity( $data[ 'qty' ] ); |
|
614 | + if (is_numeric($data['qty']) && (int) $data['qty'] > 0) { |
|
615 | + $item->set_quantity($data['qty']); |
|
616 | 616 | } |
617 | 617 | |
618 | - if ( $item->get_id() > 0 ) { |
|
619 | - $error = $invoice->add_item( $item ); |
|
618 | + if ($item->get_id() > 0) { |
|
619 | + $error = $invoice->add_item($item); |
|
620 | 620 | |
621 | - if ( is_wp_error( $error ) ) { |
|
621 | + if (is_wp_error($error)) { |
|
622 | 622 | $alert = $error->get_error_message(); |
623 | 623 | } |
624 | 624 | |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | // Return an array of invoice items. |
634 | 634 | $items = array(); |
635 | 635 | |
636 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
637 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
636 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
637 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
638 | 638 | } |
639 | 639 | |
640 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
640 | + wp_send_json_success(compact('items', 'alert')); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -646,15 +646,15 @@ discard block |
||
646 | 646 | public static function get_invoicing_items() { |
647 | 647 | |
648 | 648 | // Verify nonce. |
649 | - check_ajax_referer( 'wpinv-nonce' ); |
|
649 | + check_ajax_referer('wpinv-nonce'); |
|
650 | 650 | |
651 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
651 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
652 | 652 | exit; |
653 | 653 | } |
654 | 654 | |
655 | 655 | // We need a search term. |
656 | - if ( empty( $_GET['search'] ) ) { |
|
657 | - wp_send_json_success( array() ); |
|
656 | + if (empty($_GET['search'])) { |
|
657 | + wp_send_json_success(array()); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | // Retrieve items. |
@@ -663,8 +663,8 @@ discard block |
||
663 | 663 | 'orderby' => 'title', |
664 | 664 | 'order' => 'ASC', |
665 | 665 | 'posts_per_page' => -1, |
666 | - 'post_status' => array( 'publish' ), |
|
667 | - 's' => trim( $_GET['search'] ), |
|
666 | + 'post_status' => array('publish'), |
|
667 | + 's' => trim($_GET['search']), |
|
668 | 668 | 'meta_query' => array( |
669 | 669 | array( |
670 | 670 | 'key' => '_wpinv_type', |
@@ -674,22 +674,22 @@ discard block |
||
674 | 674 | ) |
675 | 675 | ); |
676 | 676 | |
677 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
677 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
678 | 678 | $data = array(); |
679 | 679 | |
680 | 680 | |
681 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) ); |
|
681 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id'])); |
|
682 | 682 | |
683 | - foreach ( $items as $item ) { |
|
684 | - $item = new GetPaid_Form_Item( $item ); |
|
683 | + foreach ($items as $item) { |
|
684 | + $item = new GetPaid_Form_Item($item); |
|
685 | 685 | $data[] = array( |
686 | 686 | 'id' => (int) $item->get_id(), |
687 | - 'text' => strip_tags( $item->get_name() ), |
|
688 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
687 | + 'text' => strip_tags($item->get_name()), |
|
688 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | |
692 | - wp_send_json_success( $data ); |
|
692 | + wp_send_json_success($data); |
|
693 | 693 | |
694 | 694 | } |
695 | 695 | |
@@ -699,24 +699,24 @@ discard block |
||
699 | 699 | public static function get_aui_states_field() { |
700 | 700 | |
701 | 701 | // Verify nonce. |
702 | - check_ajax_referer( 'wpinv-nonce' ); |
|
702 | + check_ajax_referer('wpinv-nonce'); |
|
703 | 703 | |
704 | 704 | // We need a country. |
705 | - if ( empty( $_GET['country'] ) ) { |
|
705 | + if (empty($_GET['country'])) { |
|
706 | 706 | exit; |
707 | 707 | } |
708 | 708 | |
709 | - $states = wpinv_get_country_states( trim( $_GET['country'] ) ); |
|
710 | - $state = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state(); |
|
709 | + $states = wpinv_get_country_states(trim($_GET['country'])); |
|
710 | + $state = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state(); |
|
711 | 711 | |
712 | - if ( empty( $states ) ) { |
|
712 | + if (empty($states)) { |
|
713 | 713 | |
714 | 714 | $html = aui()->input( |
715 | 715 | array( |
716 | 716 | 'type' => 'text', |
717 | 717 | 'id' => 'wpinv_state', |
718 | 718 | 'name' => 'wpinv_state', |
719 | - 'label' => __( 'State', 'invoicing' ), |
|
719 | + 'label' => __('State', 'invoicing'), |
|
720 | 720 | 'label_type' => 'vertical', |
721 | 721 | 'placeholder' => 'Liège', |
722 | 722 | 'class' => 'form-control-sm', |
@@ -730,9 +730,9 @@ discard block |
||
730 | 730 | array( |
731 | 731 | 'id' => 'wpinv_state', |
732 | 732 | 'name' => 'wpinv_state', |
733 | - 'label' => __( 'State', 'invoicing' ), |
|
733 | + 'label' => __('State', 'invoicing'), |
|
734 | 734 | 'label_type' => 'vertical', |
735 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
735 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
736 | 736 | 'class' => 'form-control-sm', |
737 | 737 | 'value' => $state, |
738 | 738 | 'options' => $states, |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | wp_send_json_success( |
747 | 747 | array( |
748 | 748 | 'html' => $html, |
749 | - 'select' => ! empty ( $states ) |
|
749 | + 'select' => !empty ($states) |
|
750 | 750 | ) |
751 | 751 | ); |
752 | 752 | |
@@ -760,46 +760,46 @@ discard block |
||
760 | 760 | public static function ip_geolocation() { |
761 | 761 | |
762 | 762 | // Check nonce. |
763 | - check_ajax_referer( 'getpaid-ip-location' ); |
|
763 | + check_ajax_referer('getpaid-ip-location'); |
|
764 | 764 | |
765 | 765 | // IP address. |
766 | - if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) { |
|
767 | - _e( 'Invalid IP Address.', 'invoicing' ); |
|
766 | + if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) { |
|
767 | + _e('Invalid IP Address.', 'invoicing'); |
|
768 | 768 | exit; |
769 | 769 | } |
770 | 770 | |
771 | 771 | // Retrieve location info. |
772 | - $location = getpaid_geolocate_ip_address( $_GET['ip'] ); |
|
772 | + $location = getpaid_geolocate_ip_address($_GET['ip']); |
|
773 | 773 | |
774 | - if ( empty( $location ) ) { |
|
775 | - _e( 'Unable to find geolocation for the IP Address.', 'invoicing' ); |
|
774 | + if (empty($location)) { |
|
775 | + _e('Unable to find geolocation for the IP Address.', 'invoicing'); |
|
776 | 776 | exit; |
777 | 777 | } |
778 | 778 | |
779 | 779 | // Sorry. |
780 | - extract( $location ); |
|
780 | + extract($location); |
|
781 | 781 | |
782 | 782 | // Prepare the address. |
783 | 783 | $content = ''; |
784 | 784 | |
785 | - if ( ! empty( $location['city'] ) ) { |
|
786 | - $content .= $location['city'] . ', '; |
|
785 | + if (!empty($location['city'])) { |
|
786 | + $content .= $location['city'] . ', '; |
|
787 | 787 | } |
788 | 788 | |
789 | - if ( ! empty( $location['region'] ) ) { |
|
790 | - $content .= $location['region'] . ', '; |
|
789 | + if (!empty($location['region'])) { |
|
790 | + $content .= $location['region'] . ', '; |
|
791 | 791 | } |
792 | 792 | |
793 | - $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
793 | + $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
794 | 794 | |
795 | 795 | $location['address'] = $content; |
796 | 796 | |
797 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>'; |
|
798 | - $content .= '<p>'. $location['credit'] . '</p>'; |
|
797 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>'; |
|
798 | + $content .= '<p>' . $location['credit'] . '</p>'; |
|
799 | 799 | |
800 | 800 | $location['content'] = $content; |
801 | 801 | |
802 | - wpinv_get_template( 'geolocation.php', $location ); |
|
802 | + wpinv_get_template('geolocation.php', $location); |
|
803 | 803 | |
804 | 804 | exit; |
805 | 805 | } |
@@ -812,11 +812,11 @@ discard block |
||
812 | 812 | public static function payment_form_refresh_prices() { |
813 | 813 | |
814 | 814 | // Check nonce. |
815 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
815 | + check_ajax_referer('getpaid_form_nonce'); |
|
816 | 816 | |
817 | 817 | // ... form fields... |
818 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
819 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
818 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
819 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
820 | 820 | exit; |
821 | 821 | } |
822 | 822 | |
@@ -824,18 +824,18 @@ discard block |
||
824 | 824 | $submission = new GetPaid_Payment_Form_Submission(); |
825 | 825 | |
826 | 826 | // Do we have an error? |
827 | - if ( ! empty( $submission->last_error ) ) { |
|
827 | + if (!empty($submission->last_error)) { |
|
828 | 828 | echo $submission->last_error; |
829 | 829 | exit; |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Prepare the response. |
833 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
833 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
834 | 834 | |
835 | 835 | // Filter the response. |
836 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
836 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
837 | 837 | |
838 | - wp_send_json_success( $response ); |
|
838 | + wp_send_json_success($response); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | |
32 | 32 | <div class='form-group'> |
33 | 33 | <label class="d-block"> |
34 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
34 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
35 | 35 | <input v-model='field.label' class='form-control' type="text"/> |
36 | 36 | </label> |
37 | 37 | </div> |
38 | 38 | |
39 | 39 | <div class='form-group'> |
40 | 40 | <label class="d-block"> |
41 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
41 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
42 | 42 | <input v-model='field.placeholder' class='form-control' type="text"/> |
43 | 43 | </label> |
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <div class='form-group'> |
47 | 47 | <label class="d-block"> |
48 | - <span><?php esc_html_e( 'Width', 'invoicing' ) ?></span> |
|
48 | + <span><?php esc_html_e('Width', 'invoicing') ?></span> |
|
49 | 49 | <select class='form-control custom-select' v-model='field.grid_width'> |
50 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
51 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
52 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
50 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
51 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
52 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
53 | 53 | </select> |
54 | 54 | </label> |
55 | 55 | </div> |
56 | 56 | |
57 | 57 | <div class='form-group'> |
58 | 58 | <label class="d-block"> |
59 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
60 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='field.description' class='form-control' rows='3'></textarea> |
|
59 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
60 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='field.description' class='form-control' rows='3'></textarea> |
|
61 | 61 | </label> |
62 | 62 | </div> |
63 | 63 | |
64 | 64 | <div class='form-group form-check'> |
65 | 65 | <input :id="active_form_element.id + '_edit_required' + index" v-model='field.required' type='checkbox' class='form-check-input' /> |
66 | - <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e( 'Is required', 'invoicing' ); ?></label> |
|
66 | + <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e('Is required', 'invoicing'); ?></label> |
|
67 | 67 | </div> |
68 | 68 | |
69 | 69 | <div class='form-group form-check'> |
70 | 70 | <input :id="active_form_element.id + '_edit_visible' + index" v-model='field.visible' type='checkbox' class='form-check-input' /> |
71 | - <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e( 'Is visible', 'invoicing' ); ?></label> |
|
71 | + <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e('Is visible', 'invoicing'); ?></label> |
|
72 | 72 | </div> |
73 | 73 | |
74 | 74 | </div> |
@@ -7,44 +7,44 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Make sure that the form is active. |
13 | -if ( ! $form->is_active() ) { |
|
13 | +if (!$form->is_active()) { |
|
14 | 14 | echo aui()->alert( |
15 | 15 | array( |
16 | 16 | 'type' => 'warning', |
17 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
17 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
18 | 18 | ) |
19 | 19 | ); |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | 23 | // Fires before displaying a payment form. |
24 | -do_action( 'getpaid_before_payment_form', $form ); |
|
24 | +do_action('getpaid_before_payment_form', $form); |
|
25 | 25 | ?> |
26 | 26 | |
27 | -<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'> |
|
27 | +<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'> |
|
28 | 28 | |
29 | 29 | |
30 | 30 | <?php |
31 | 31 | |
32 | 32 | // Fires when printing the top of a payment form. |
33 | - do_action( 'getpaid_payment_form_top', $form ); |
|
33 | + do_action('getpaid_payment_form_top', $form); |
|
34 | 34 | |
35 | 35 | // And the optional invoice id. |
36 | - if ( ! empty( $form->invoice ) ) { |
|
37 | - echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
36 | + if (!empty($form->invoice)) { |
|
37 | + echo getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // We also want to include the form id. |
41 | - echo getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
41 | + echo getpaid_hidden_field('form_id', $form->get_id()); |
|
42 | 42 | |
43 | 43 | // And an indication that this is a payment form submission. |
44 | - echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
44 | + echo getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
45 | 45 | |
46 | 46 | // Fires before displaying payment form elements. |
47 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
47 | + do_action('getpaid_payment_form_before_elements', $form); |
|
48 | 48 | |
49 | 49 | // Display the elements. |
50 | 50 | ?> |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | <div class="row"> |
53 | 53 | <?php |
54 | 54 | |
55 | - foreach ( $form->get_elements() as $element ) { |
|
55 | + foreach ($form->get_elements() as $element) { |
|
56 | 56 | |
57 | - if ( isset( $element['type'] ) ) { |
|
58 | - $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) ); |
|
57 | + if (isset($element['type'])) { |
|
58 | + $grid_class = esc_attr(getpaid_get_form_element_grid_class($element)); |
|
59 | 59 | echo "<div class='$grid_class'>"; |
60 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
61 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
60 | + do_action('getpaid_payment_form_element', $element, $form); |
|
61 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
62 | 62 | echo "</div>"; |
63 | 63 | } |
64 | 64 | |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | // Fires after displaying payment form elements. |
73 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
73 | + do_action('getpaid_payment_form_after_elements', $form); |
|
74 | 74 | |
75 | 75 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
76 | 76 | |
77 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
77 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
78 | 78 | |
79 | 79 | edit_post_link( |
80 | - __( 'Edit this form.', 'invoicing' ), |
|
80 | + __('Edit this form.', 'invoicing'), |
|
81 | 81 | '<small class="form-text text-muted">', |
82 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
82 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
83 | 83 | $form->get_id(), |
84 | 84 | 'text-danger' |
85 | 85 | ); |
@@ -94,4 +94,4 @@ discard block |
||
94 | 94 | <?php |
95 | 95 | |
96 | 96 | // Fires after displaying a payment form. |
97 | -do_action( 'getpaid_after_payment_form', $form ); |
|
97 | +do_action('getpaid_after_payment_form', $form); |
@@ -7,50 +7,50 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $fields ) ) { |
|
12 | +if (empty($fields)) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Prepare the user's country. |
17 | -$country = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_country', true ) : ''; |
|
18 | -$country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
17 | +$country = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_country', true) : ''; |
|
18 | +$country = empty($country) ? wpinv_get_default_country() : $country; |
|
19 | 19 | |
20 | 20 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
21 | -$uniqid = uniqid( '_' ); |
|
21 | +$uniqid = uniqid('_'); |
|
22 | 22 | |
23 | 23 | echo "<div class='row'>"; |
24 | -foreach ( $fields as $address_field ) { |
|
24 | +foreach ($fields as $address_field) { |
|
25 | 25 | |
26 | 26 | // Skip if it is hidden. |
27 | - if ( empty( $address_field['visible'] ) ) { |
|
27 | + if (empty($address_field['visible'])) { |
|
28 | 28 | continue; |
29 | 29 | } |
30 | 30 | |
31 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
32 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
33 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
34 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
35 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_' . $address_field['name'], true ) : ''; |
|
36 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
31 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
32 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
33 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
34 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
35 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_' . $address_field['name'], true) : ''; |
|
36 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
37 | 37 | |
38 | - if ( ! empty( $address_field['required'] ) ) { |
|
38 | + if (!empty($address_field['required'])) { |
|
39 | 39 | $label .= "<span class='text-danger'> *</span>"; |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Display the country. |
43 | - if ( 'wpinv_country' == $address_field['name'] ) { |
|
43 | + if ('wpinv_country' == $address_field['name']) { |
|
44 | 44 | |
45 | 45 | echo aui()->select( |
46 | 46 | array( |
47 | 47 | 'options' => wpinv_get_country_list(), |
48 | 48 | 'name' => 'wpinv_country', |
49 | 49 | 'id' => 'wpinv_country' . $uniqid, |
50 | - 'value' => sanitize_text_field( $country ), |
|
50 | + 'value' => sanitize_text_field($country), |
|
51 | 51 | 'placeholder' => $placeholder, |
52 | - 'required' => ! empty( $address_field['required'] ), |
|
53 | - 'label' => wp_kses_post( $label ), |
|
52 | + 'required' => !empty($address_field['required']), |
|
53 | + 'label' => wp_kses_post($label), |
|
54 | 54 | 'label_type' => 'vertical', |
55 | 55 | 'help_text' => $description, |
56 | 56 | 'class' => 'getpaid-address-field wpinv_country', |
@@ -63,39 +63,39 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // Display the state. |
66 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
66 | + if ('wpinv_state' == $address_field['name']) { |
|
67 | 67 | |
68 | - if ( empty( $value ) ) { |
|
68 | + if (empty($value)) { |
|
69 | 69 | $value = wpinv_get_default_state(); |
70 | 70 | } |
71 | 71 | |
72 | - echo getpaid_get_states_select_markup ( |
|
72 | + echo getpaid_get_states_select_markup( |
|
73 | 73 | $country, |
74 | 74 | $value, |
75 | 75 | $placeholder, |
76 | 76 | $label, |
77 | 77 | $description, |
78 | - ! empty( $address_field['required'] ), |
|
78 | + !empty($address_field['required']), |
|
79 | 79 | $wrap_class |
80 | 80 | ); |
81 | 81 | |
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
86 | - $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
85 | + $key = str_replace('wpinv_', '', $address_field['name']); |
|
86 | + $key = esc_attr(str_replace('_', '-', $key)); |
|
87 | 87 | echo aui()->input( |
88 | 88 | array( |
89 | - 'name' => esc_attr( $address_field['name'] ), |
|
90 | - 'id' => esc_attr( $address_field['name'] ) . $uniqid, |
|
91 | - 'required' => ! empty( $address_field['required'] ), |
|
89 | + 'name' => esc_attr($address_field['name']), |
|
90 | + 'id' => esc_attr($address_field['name']) . $uniqid, |
|
91 | + 'required' => !empty($address_field['required']), |
|
92 | 92 | 'placeholder' => $placeholder, |
93 | - 'label' => wp_kses_post( $label ), |
|
93 | + 'label' => wp_kses_post($label), |
|
94 | 94 | 'label_type' => 'vertical', |
95 | 95 | 'help_text' => $description, |
96 | 96 | 'type' => 'text', |
97 | 97 | 'value' => $value, |
98 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
98 | + 'class' => 'getpaid-address-field ' . esc_attr($address_field['name']), |
|
99 | 99 | 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
100 | 100 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
101 | 101 | ) |
@@ -9,41 +9,41 @@ discard block |
||
9 | 9 | * @version 1.0.19 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | 14 | return array( |
15 | 15 | |
16 | 16 | array( |
17 | 17 | 'type' => 'heading', |
18 | - 'name' => __( 'Heading', 'invoicing' ), |
|
18 | + 'name' => __('Heading', 'invoicing'), |
|
19 | 19 | 'defaults' => array( |
20 | 20 | 'level' => 'h2', |
21 | - 'text' => __( 'Heading', 'invoicing' ), |
|
21 | + 'text' => __('Heading', 'invoicing'), |
|
22 | 22 | ) |
23 | 23 | ), |
24 | 24 | |
25 | 25 | array( |
26 | 26 | 'type' => 'paragraph', |
27 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
27 | + 'name' => __('Paragraph', 'invoicing'), |
|
28 | 28 | 'defaults' => array( |
29 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
29 | + 'text' => __('Paragraph text', 'invoicing'), |
|
30 | 30 | ) |
31 | 31 | ), |
32 | 32 | |
33 | 33 | array( |
34 | 34 | 'type' => 'alert', |
35 | - 'name' => __( 'Alert', 'invoicing' ), |
|
35 | + 'name' => __('Alert', 'invoicing'), |
|
36 | 36 | 'defaults' => array( |
37 | 37 | 'value' => '', |
38 | 38 | 'class' => 'alert-warning', |
39 | - 'text' => __( 'Alert', 'invoicing' ), |
|
39 | + 'text' => __('Alert', 'invoicing'), |
|
40 | 40 | 'dismissible' => false, |
41 | 41 | ) |
42 | 42 | ), |
43 | 43 | |
44 | 44 | array( |
45 | 45 | 'type' => 'separator', |
46 | - 'name' => __( 'Separator', 'invoicing' ), |
|
46 | + 'name' => __('Separator', 'invoicing'), |
|
47 | 47 | 'defaults' => array( |
48 | 48 | 'value' => '', |
49 | 49 | ), |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | |
52 | 52 | array( |
53 | 53 | 'type' => 'text', |
54 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
54 | + 'name' => __('Text Input', 'invoicing'), |
|
55 | 55 | 'defaults' => array( |
56 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
56 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
57 | 57 | 'value' => '', |
58 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
58 | + 'label' => __('Field Label', 'invoicing'), |
|
59 | 59 | 'description' => '', |
60 | 60 | 'required' => false, |
61 | 61 | ) |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | |
64 | 64 | array( |
65 | 65 | 'type' => 'textarea', |
66 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
66 | + 'name' => __('Textarea', 'invoicing'), |
|
67 | 67 | 'defaults' => array( |
68 | - 'placeholder' => __( 'Enter your text hear', 'invoicing' ), |
|
68 | + 'placeholder' => __('Enter your text hear', 'invoicing'), |
|
69 | 69 | 'value' => '', |
70 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
70 | + 'label' => __('Textarea Label', 'invoicing'), |
|
71 | 71 | 'description' => '', |
72 | 72 | 'required' => false, |
73 | 73 | ) |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | |
76 | 76 | array( |
77 | 77 | 'type' => 'select', |
78 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
78 | + 'name' => __('Dropdown', 'invoicing'), |
|
79 | 79 | 'defaults' => array( |
80 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
80 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
81 | 81 | 'value' => '', |
82 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
82 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
83 | 83 | 'description' => '', |
84 | 84 | 'required' => false, |
85 | 85 | 'options' => array( |
86 | - esc_attr__( 'Option One', 'invoicing' ), |
|
87 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
88 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
86 | + esc_attr__('Option One', 'invoicing'), |
|
87 | + esc_attr__('Option Two', 'invoicing'), |
|
88 | + esc_attr__('Option Three', 'invoicing') |
|
89 | 89 | ), |
90 | 90 | ) |
91 | 91 | ), |
92 | 92 | |
93 | 93 | array( |
94 | 94 | 'type' => 'checkbox', |
95 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
95 | + 'name' => __('Checkbox', 'invoicing'), |
|
96 | 96 | 'defaults' => array( |
97 | 97 | 'value' => '', |
98 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
98 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
99 | 99 | 'description' => '', |
100 | 100 | 'required' => false, |
101 | 101 | ) |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | |
104 | 104 | array( |
105 | 105 | 'type' => 'radio', |
106 | - 'name' => __( 'Radio', 'invoicing' ), |
|
106 | + 'name' => __('Radio', 'invoicing'), |
|
107 | 107 | 'defaults' => array( |
108 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
108 | + 'label' => __('Select one choice', 'invoicing'), |
|
109 | 109 | 'options' => array( |
110 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
111 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
112 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
110 | + esc_attr__('Choice One', 'invoicing'), |
|
111 | + esc_attr__('Choice Two', 'invoicing'), |
|
112 | + esc_attr__('Choice Three', 'invoicing') |
|
113 | 113 | ), |
114 | 114 | ) |
115 | 115 | ), |
116 | 116 | |
117 | 117 | array( |
118 | 118 | 'type' => 'date', |
119 | - 'name' => __( 'Date', 'invoicing' ), |
|
119 | + 'name' => __('Date', 'invoicing'), |
|
120 | 120 | 'defaults' => array( |
121 | 121 | 'value' => '', |
122 | - 'label' => __( 'Date', 'invoicing' ), |
|
122 | + 'label' => __('Date', 'invoicing'), |
|
123 | 123 | 'description' => '', |
124 | 124 | 'required' => false, |
125 | 125 | ) |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | |
128 | 128 | array( |
129 | 129 | 'type' => 'time', |
130 | - 'name' => __( 'Time', 'invoicing' ), |
|
130 | + 'name' => __('Time', 'invoicing'), |
|
131 | 131 | 'defaults' => array( |
132 | 132 | 'value' => '', |
133 | - 'label' => __( 'Time', 'invoicing' ), |
|
133 | + 'label' => __('Time', 'invoicing'), |
|
134 | 134 | 'description' => '', |
135 | 135 | 'required' => false, |
136 | 136 | ) |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | |
139 | 139 | array( |
140 | 140 | 'type' => 'number', |
141 | - 'name' => __( 'Number', 'invoicing' ), |
|
141 | + 'name' => __('Number', 'invoicing'), |
|
142 | 142 | 'defaults' => array( |
143 | 143 | 'placeholder' => '', |
144 | 144 | 'value' => '', |
145 | - 'label' => __( 'Number', 'invoicing' ), |
|
145 | + 'label' => __('Number', 'invoicing'), |
|
146 | 146 | 'description' => '', |
147 | 147 | 'required' => false, |
148 | 148 | ) |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | |
151 | 151 | array( |
152 | 152 | 'type' => 'website', |
153 | - 'name' => __( 'Website', 'invoicing' ), |
|
153 | + 'name' => __('Website', 'invoicing'), |
|
154 | 154 | 'defaults' => array( |
155 | 155 | 'placeholder' => 'http://example.com', |
156 | 156 | 'value' => '', |
157 | - 'label' => __( 'Website', 'invoicing' ), |
|
157 | + 'label' => __('Website', 'invoicing'), |
|
158 | 158 | 'description' => '', |
159 | 159 | 'required' => false, |
160 | 160 | ) |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | |
163 | 163 | array( |
164 | 164 | 'type' => 'email', |
165 | - 'name' => __( 'Email', 'invoicing' ), |
|
165 | + 'name' => __('Email', 'invoicing'), |
|
166 | 166 | 'defaults' => array( |
167 | 167 | 'placeholder' => '[email protected]', |
168 | 168 | 'value' => '', |
169 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
169 | + 'label' => __('Email Address', 'invoicing'), |
|
170 | 170 | 'description' => '', |
171 | 171 | 'required' => false, |
172 | 172 | ) |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | |
175 | 175 | array( |
176 | 176 | 'type' => 'address', |
177 | - 'name' => __( 'Address', 'invoicing' ), |
|
177 | + 'name' => __('Address', 'invoicing'), |
|
178 | 178 | 'defaults' => array( |
179 | 179 | |
180 | 180 | 'fields' => array( |
181 | 181 | array( |
182 | 182 | 'placeholder' => 'Jon', |
183 | 183 | 'value' => '', |
184 | - 'label' => __( 'First Name', 'invoicing' ), |
|
184 | + 'label' => __('First Name', 'invoicing'), |
|
185 | 185 | 'description' => '', |
186 | 186 | 'required' => false, |
187 | 187 | 'visible' => true, |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | array( |
192 | 192 | 'placeholder' => 'Snow', |
193 | 193 | 'value' => '', |
194 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
194 | + 'label' => __('Last Name', 'invoicing'), |
|
195 | 195 | 'description' => '', |
196 | 196 | 'required' => false, |
197 | 197 | 'visible' => true, |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | array( |
202 | 202 | 'placeholder' => '', |
203 | 203 | 'value' => '', |
204 | - 'label' => __( 'Address', 'invoicing' ), |
|
204 | + 'label' => __('Address', 'invoicing'), |
|
205 | 205 | 'description' => '', |
206 | 206 | 'required' => false, |
207 | 207 | 'visible' => true, |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | array( |
212 | 212 | 'placeholder' => '', |
213 | 213 | 'value' => '', |
214 | - 'label' => __( 'City', 'invoicing' ), |
|
214 | + 'label' => __('City', 'invoicing'), |
|
215 | 215 | 'description' => '', |
216 | 216 | 'required' => false, |
217 | 217 | 'visible' => true, |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | ), |
220 | 220 | |
221 | 221 | array( |
222 | - 'placeholder' => __( 'Select your country' ), |
|
222 | + 'placeholder' => __('Select your country'), |
|
223 | 223 | 'value' => '', |
224 | - 'label' => __( 'Country', 'invoicing' ), |
|
224 | + 'label' => __('Country', 'invoicing'), |
|
225 | 225 | 'description' => '', |
226 | 226 | 'required' => false, |
227 | 227 | 'visible' => true, |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | ), |
230 | 230 | |
231 | 231 | array( |
232 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
232 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
233 | 233 | 'value' => '', |
234 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
234 | + 'label' => __('State / Province', 'invoicing'), |
|
235 | 235 | 'description' => '', |
236 | 236 | 'required' => false, |
237 | 237 | 'visible' => true, |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | array( |
242 | 242 | 'placeholder' => '', |
243 | 243 | 'value' => '', |
244 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
244 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
245 | 245 | 'description' => '', |
246 | 246 | 'required' => false, |
247 | 247 | 'visible' => true, |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | array( |
252 | 252 | 'placeholder' => '', |
253 | 253 | 'value' => '', |
254 | - 'label' => __( 'Phone', 'invoicing' ), |
|
254 | + 'label' => __('Phone', 'invoicing'), |
|
255 | 255 | 'description' => '', |
256 | 256 | 'required' => false, |
257 | 257 | 'visible' => true, |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | array( |
262 | 262 | 'placeholder' => '', |
263 | 263 | 'value' => '', |
264 | - 'label' => __( 'Company', 'invoicing' ), |
|
264 | + 'label' => __('Company', 'invoicing'), |
|
265 | 265 | 'description' => '', |
266 | 266 | 'required' => false, |
267 | 267 | 'visible' => false, |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | array( |
272 | 272 | 'placeholder' => '', |
273 | 273 | 'value' => '', |
274 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
274 | + 'label' => __('VAT Number', 'invoicing'), |
|
275 | 275 | 'description' => '', |
276 | 276 | 'required' => false, |
277 | 277 | 'visible' => false, |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | |
284 | 284 | array( |
285 | 285 | 'type' => 'billing_email', |
286 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
286 | + 'name' => __('Billing Email', 'invoicing'), |
|
287 | 287 | 'defaults' => array( |
288 | 288 | 'placeholder' => '[email protected]', |
289 | 289 | 'value' => '', |
290 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
290 | + 'label' => __('Billing Email', 'invoicing'), |
|
291 | 291 | 'description' => '', |
292 | 292 | 'premade' => true, |
293 | 293 | ) |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | |
296 | 296 | array( |
297 | 297 | 'type' => 'discount', |
298 | - 'name' => __( 'Discount Input', 'invoicing' ), |
|
298 | + 'name' => __('Discount Input', 'invoicing'), |
|
299 | 299 | 'defaults' => array( |
300 | 300 | 'value' => '', |
301 | - 'input_label' => __( 'Coupon Code', 'invoicing' ), |
|
302 | - 'button_label' => __( 'Apply Coupon', 'invoicing' ), |
|
303 | - 'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
|
301 | + 'input_label' => __('Coupon Code', 'invoicing'), |
|
302 | + 'button_label' => __('Apply Coupon', 'invoicing'), |
|
303 | + 'description' => __('Have a discount code? Enter it above.', 'invoicing'), |
|
304 | 304 | ) |
305 | 305 | ), |
306 | 306 | |
307 | 307 | array( |
308 | 308 | 'type' => 'items', |
309 | - 'name' => __( 'Items', 'invoicing' ), |
|
309 | + 'name' => __('Items', 'invoicing'), |
|
310 | 310 | 'defaults' => array( |
311 | 311 | 'value' => '', |
312 | 312 | 'items_type' => 'total', |
@@ -318,22 +318,22 @@ discard block |
||
318 | 318 | |
319 | 319 | array( |
320 | 320 | 'type' => 'price_input', |
321 | - 'name' => __( 'Price Input', 'invoicing' ), |
|
321 | + 'name' => __('Price Input', 'invoicing'), |
|
322 | 322 | 'defaults' => array( |
323 | 323 | 'placeholder' => wpinv_format_amount(0), |
324 | 324 | 'value' => wpinv_format_amount(0), |
325 | 325 | 'minimum' => wpinv_format_amount(0), |
326 | - 'label' => __( 'Enter Amount', 'invoicing' ), |
|
326 | + 'label' => __('Enter Amount', 'invoicing'), |
|
327 | 327 | 'description' => '', |
328 | 328 | ) |
329 | 329 | ), |
330 | 330 | |
331 | 331 | array( |
332 | 332 | 'type' => 'price_select', |
333 | - 'name' => __( 'Price Select', 'invoicing' ), |
|
333 | + 'name' => __('Price Select', 'invoicing'), |
|
334 | 334 | 'defaults' => array( |
335 | 335 | 'description' => '', |
336 | - 'label' => __( 'Select Amount', 'invoicing' ), |
|
336 | + 'label' => __('Select Amount', 'invoicing'), |
|
337 | 337 | 'options' => 'Option 1|10, Option 2|20', |
338 | 338 | 'placeholder' => '', |
339 | 339 | 'select_type' => 'select', |
@@ -342,39 +342,39 @@ discard block |
||
342 | 342 | |
343 | 343 | array( |
344 | 344 | 'type' => 'pay_button', |
345 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
345 | + 'name' => __('Payment Button', 'invoicing'), |
|
346 | 346 | 'defaults' => array( |
347 | 347 | 'value' => '', |
348 | 348 | 'class' => 'btn-primary', |
349 | - 'label' => __( 'Pay %price% »', 'invoicing' ), |
|
350 | - 'free' => __( 'Continue »', 'invoicing' ), |
|
351 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
349 | + 'label' => __('Pay %price% »', 'invoicing'), |
|
350 | + 'free' => __('Continue »', 'invoicing'), |
|
351 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
352 | 352 | 'premade' => true, |
353 | 353 | ) |
354 | 354 | ), |
355 | 355 | |
356 | 356 | array( |
357 | 357 | 'type' => 'gateway_select', |
358 | - 'name' => __( 'Gateway Select', 'invoicing' ), |
|
358 | + 'name' => __('Gateway Select', 'invoicing'), |
|
359 | 359 | 'defaults' => array( |
360 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
360 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
361 | 361 | 'premade' => true, |
362 | 362 | ) |
363 | 363 | ), |
364 | 364 | |
365 | 365 | array( |
366 | 366 | 'type' => 'total_payable', |
367 | - 'name' => __( 'Total Payable', 'invoicing' ), |
|
367 | + 'name' => __('Total Payable', 'invoicing'), |
|
368 | 368 | 'defaults' => array( |
369 | - 'text' => __( 'Total to pay:', 'invoicing' ), |
|
369 | + 'text' => __('Total to pay:', 'invoicing'), |
|
370 | 370 | ) |
371 | 371 | ), |
372 | 372 | |
373 | 373 | array( |
374 | 374 | 'type' => 'ip_address', |
375 | - 'name' => __( 'IP Address', 'invoicing' ), |
|
375 | + 'name' => __('IP Address', 'invoicing'), |
|
376 | 376 | 'defaults' => array( |
377 | - 'text' => __( 'Your IP address is:', 'invoicing' ), |
|
377 | + 'text' => __('Your IP address is:', 'invoicing'), |
|
378 | 378 | ) |
379 | 379 | ) |
380 | 380 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission refresh prices class |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
31 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
32 | 32 | ); |
33 | 33 | |
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
34 | + $this->add_totals($submission); |
|
35 | + $this->add_texts($submission); |
|
36 | + $this->add_items($submission); |
|
37 | + $this->add_fees($submission); |
|
38 | + $this->add_discounts($submission); |
|
39 | + $this->add_taxes($submission); |
|
40 | + $this->add_gateways($submission); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param GetPaid_Payment_Form_Submission $submission |
48 | 48 | */ |
49 | - public function add_totals( $submission ) { |
|
49 | + public function add_totals($submission) { |
|
50 | 50 | |
51 | 51 | $this->response = array_merge( |
52 | 52 | $this->response, |
53 | 53 | array( |
54 | 54 | |
55 | 55 | 'totals' => array( |
56 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
56 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
57 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
58 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
59 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
60 | + 'total' => $submission->format_amount($submission->get_total()), |
|
61 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
62 | 62 | ), |
63 | 63 | |
64 | 64 | 'recurring' => array( |
65 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
65 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
66 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
67 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
68 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
69 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
70 | 70 | ), |
71 | 71 | |
72 | 72 | ) |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param GetPaid_Payment_Form_Submission $submission |
81 | 81 | */ |
82 | - public function add_texts( $submission ) { |
|
82 | + public function add_texts($submission) { |
|
83 | 83 | |
84 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
84 | + $payable = $submission->format_amount($submission->get_total()); |
|
85 | 85 | |
86 | - if ( $submission->has_recurring != 0 ) { |
|
86 | + if ($submission->has_recurring != 0) { |
|
87 | 87 | |
88 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
89 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
88 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
89 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
90 | 90 | |
91 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
91 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
92 | 92 | $payable = "$payable / $period"; |
93 | 93 | } else { |
94 | 94 | $payable = sprintf( |
95 | - __( '%1$s (renews at %2$s / %3$s)'), |
|
96 | - $submission->format_amount( $submission->get_total() ), |
|
97 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
95 | + __('%1$s (renews at %2$s / %3$s)'), |
|
96 | + $submission->format_amount($submission->get_total()), |
|
97 | + $submission->format_amount($submission->get_recurring_total()), |
|
98 | 98 | $period |
99 | 99 | ); |
100 | 100 | } |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | '.getpaid-checkout-total-payable' => $payable, |
106 | 106 | ); |
107 | 107 | |
108 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
109 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
110 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
108 | + foreach ($submission->get_items() as $item_id => $item) { |
|
109 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount($item->get_sub_total()); |
|
110 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total()); |
|
111 | 111 | } |
112 | 112 | |
113 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
113 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @param GetPaid_Payment_Form_Submission $submission |
121 | 121 | */ |
122 | - public function add_items( $submission ) { |
|
122 | + public function add_items($submission) { |
|
123 | 123 | |
124 | 124 | // Add items. |
125 | 125 | $items = array(); |
126 | 126 | |
127 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
128 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
127 | + foreach ($submission->get_items() as $item_id => $item) { |
|
128 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->response = array_merge( |
132 | 132 | $this->response, |
133 | - array( 'items' => $items ) |
|
133 | + array('items' => $items) |
|
134 | 134 | ); |
135 | 135 | |
136 | 136 | } |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param GetPaid_Payment_Form_Submission $submission |
142 | 142 | */ |
143 | - public function add_fees( $submission ) { |
|
143 | + public function add_fees($submission) { |
|
144 | 144 | |
145 | 145 | $fees = array(); |
146 | 146 | |
147 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
148 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
147 | + foreach ($submission->get_fees() as $name => $data) { |
|
148 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | $this->response = array_merge( |
152 | 152 | $this->response, |
153 | - array( 'fees' => $fees ) |
|
153 | + array('fees' => $fees) |
|
154 | 154 | ); |
155 | 155 | |
156 | 156 | } |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @param GetPaid_Payment_Form_Submission $submission |
162 | 162 | */ |
163 | - public function add_discounts( $submission ) { |
|
163 | + public function add_discounts($submission) { |
|
164 | 164 | |
165 | 165 | $discounts = array(); |
166 | 166 | |
167 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
168 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
167 | + foreach ($submission->get_discounts() as $name => $data) { |
|
168 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $this->response = array_merge( |
172 | 172 | $this->response, |
173 | - array( 'discounts' => $discounts ) |
|
173 | + array('discounts' => $discounts) |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | } |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param GetPaid_Payment_Form_Submission $submission |
182 | 182 | */ |
183 | - public function add_taxes( $submission ) { |
|
183 | + public function add_taxes($submission) { |
|
184 | 184 | |
185 | 185 | $taxes = array(); |
186 | 186 | |
187 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
188 | - $taxes[$name] = $submission->format_amount( $data['initial_tax'] ); |
|
187 | + foreach ($submission->get_taxes() as $name => $data) { |
|
188 | + $taxes[$name] = $submission->format_amount($data['initial_tax']); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $this->response = array_merge( |
192 | 192 | $this->response, |
193 | - array( 'taxes' => $taxes ) |
|
193 | + array('taxes' => $taxes) |
|
194 | 194 | ); |
195 | 195 | |
196 | 196 | } |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param GetPaid_Payment_Form_Submission $submission |
202 | 202 | */ |
203 | - public function add_gateways( $submission ) { |
|
203 | + public function add_gateways($submission) { |
|
204 | 204 | |
205 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
205 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
206 | 206 | |
207 | - if ( $this->response['has_recurring'] ) { |
|
207 | + if ($this->response['has_recurring']) { |
|
208 | 208 | |
209 | - foreach ( $gateways as $i => $gateway ) { |
|
209 | + foreach ($gateways as $i => $gateway) { |
|
210 | 210 | |
211 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
212 | - unset( $gateways[ $i ] ); |
|
211 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
212 | + unset($gateways[$i]); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | |
220 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
220 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
221 | 221 | $this->response = array_merge( |
222 | 222 | $this->response, |
223 | - array( 'gateways' => $gateways ) |
|
223 | + array('gateways' => $gateways) |
|
224 | 224 | ); |
225 | 225 | |
226 | 226 | } |
@@ -7,44 +7,44 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='form-group'> |
15 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Button Text', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Button Text', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | - <small class="form-text text-muted"><?php _e( '%price% will be replaced by the total payable amount', 'invoicing' ); ?></small> |
|
18 | + <small class="form-text text-muted"><?php _e('%price% will be replaced by the total payable amount', 'invoicing'); ?></small> |
|
19 | 19 | </label> |
20 | 20 | </div> |
21 | 21 | |
22 | 22 | <div class='form-group'> |
23 | 23 | <label class="d-block"> |
24 | - <span><?php esc_html_e( 'Free Checkout Text', 'invoicing' ); ?></span> |
|
24 | + <span><?php esc_html_e('Free Checkout Text', 'invoicing'); ?></span> |
|
25 | 25 | <input v-model='active_form_element.free' class='form-control' type="text"/> |
26 | - <small class="form-text text-muted"><?php _e( 'The text to display if the total payable amount is zero', 'invoicing' ); ?></small> |
|
26 | + <small class="form-text text-muted"><?php _e('The text to display if the total payable amount is zero', 'invoicing'); ?></small> |
|
27 | 27 | </label> |
28 | 28 | </div> |
29 | 29 | |
30 | 30 | <div class='form-group'> |
31 | 31 | <label class="d-block"> |
32 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
33 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
33 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
34 | 34 | </label> |
35 | 35 | </div> |
36 | 36 | |
37 | 37 | <div class='form-group'> |
38 | - <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Button Type', 'invoicing' ) ?></label> |
|
38 | + <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Button Type', 'invoicing') ?></label> |
|
39 | 39 | <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'> |
40 | - <option value='btn-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option> |
|
41 | - <option value='btn-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option> |
|
42 | - <option value='btn-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option> |
|
43 | - <option value='btn-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option> |
|
44 | - <option value='btn-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option> |
|
45 | - <option value='btn-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option> |
|
46 | - <option value='btn-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option> |
|
47 | - <option value='btn-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option> |
|
48 | - <option value='btn-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option> |
|
40 | + <option value='btn-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option> |
|
41 | + <option value='btn-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option> |
|
42 | + <option value='btn-success'><?php esc_html_e('Success', 'invoicing'); ?></option> |
|
43 | + <option value='btn-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option> |
|
44 | + <option value='btn-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option> |
|
45 | + <option value='btn-info'><?php esc_html_e('Info', 'invoicing'); ?></option> |
|
46 | + <option value='btn-light'><?php esc_html_e('Light', 'invoicing'); ?></option> |
|
47 | + <option value='btn-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option> |
|
48 | + <option value='btn-link'><?php esc_html_e('Link', 'invoicing'); ?></option> |
|
49 | 49 | </select> |
50 | 50 | </div> |